For the complete documentation index, see llms.txt. This page is also available as Markdown.

Making POST/PUT Requests

In addition to standard GET requests, ScraperAPI lets you send POST/PUT requests as well. This makes it possible to scrape APIs, submit forms and send data to endpoints that require more than just a URL.

  • API REQUEST

# Replace POST with PUT to send a PUT request instead
curl -d 'foo=bar' \
-X POST \
"http://api.scraperapi.com/?api_key=API_KEY&url=https://postman-echo.com/post"

# For form data
curl -H 'Content-Type: application/x-www-form-urlencoded' \
-F 'foo=bar' \
-X POST \
"http://api.scraperapi.com/?api_key=API_KEY&url=https://postman-echo.com/post"
import requests
payload = {'api_key': 'API_KEY', 'url': 'https://postman-echo.com/post'}

r = requests.post('http://api.scraperapi.com', params=payload, data={'foo': 'bar'})
print(r.text)
import fetch from 'node-fetch';

const url = 'http://api.scraperapi.com/?api_key=API_KEY&url=https://postman-echo.com/post';

const options = {
  method: 'POST',
  body: JSON.stringify({ foo: 'bar' }),
  headers: {
    'Content-Type': 'application/json',
  },
};

fetch(url, options)
  .then(response => response.json())
  .then(data => {
    console.log(data);
  })
  .catch(error => {
    console.error('Error:', error);
  });
  • PROXY MODE

# Replace POST with PUT to send a PUT request instead
curl -d 'foo=bar' \
-X POST \
-x "http://scraperapi:API_KEY@proxy-server.scraperapi.com:8001" -k "https://postman-echo.com/post"

# For form data
curl -H 'Content-Type: application/x-www-form-urlencoded' \
-F 'foo=bar' \
-X POST \
-x "http://scraperapi:API_KEY@proxy-server.scraperapi.com:8001" -k "https://postman-echo.com/post"
import requests
proxies = {
  "http": "http://scraperapi:API_KEY@proxy-server.scraperapi.com:8001"
}

r = requests.post('https://postman-echo.com/post', proxies=proxies, data={'foo': 'bar'}, verify=False)
print(r.text)
import axios from 'axios';

axios.post(
  'https://postman-echo.com/post',
  { foo: 'bar' },
  {
    headers: {
      'Content-Type': 'application/json',
    },
    proxy: {
      host: 'proxy-server.scraperapi.com',
      port: 8001,
      auth: {
        username: 'scraperapi',
        password: 'API_KEY',
      },
      protocol: 'http',
    },
  }
)
  .then(response => {
    console.log(response.data);
  })
  .catch(error => {
    console.error('Error:', error.message);
  });

Last updated