POST, PUT & PATCH Requests
Browser API is not limited to GET requests. You can send POST, PUT, or PATCH requests as well.
Browser API is not limited to GET requests. You can now easily scrape the internet by sending POST, PUT or PATCH requests as well.
Currently in BETA version, the POST, PUT and PATCH requests are sent to the same base API URL. The only requirement for such requests is to pass the data (payload) alongside your request.
As you will see in the examples below, the only difference in implementation between the three is the HTTP method used. Apart from that, both requests are similar with respect to the endpoint and parameters passed.
Please make sure to update <YOUR_API_KEY> with your own API key. Find out how to obtain an API key.
POST Request
POST https://api.webscrapingapi.com/v1?api_key=<YOUR_API_KEY>&url=https://httpbin.org/post
Query Parameters
| Name | Type | Description |
|---|---|---|
api_key | string | <YOUR_API_KEY> |
url | string | https://httpbin.org/post/ |
Request Body
| Name | Type | Description |
|---|---|---|
foo | Any | bar |
Code Samples
curl --request POST \
--url "https://api.webscrapingapi.com/v1?api_key=<YOUR_API_KEY>&url=https%3A%2F%2Fhttpbin.org%2Fpost" \
--data '{"foo": "bar"}'const response = await fetch("https://api.webscrapingapi.com/v1?api_key=<YOUR_API_KEY>&url=https%3A%2F%2Fhttpbin.org%2Fpost", {
method: "POST",
body: "{\n \"foo\": \"bar\"\n}"
});
const data = await response.text();
console.log(data);import requests
API_KEY = '<YOUR_API_KEY>'
SCRAPER_URL = 'https://api.webscrapingapi.com/v1'
TARGET_URL = 'https://httpbin.org/post'
PARAMS = {
"api_key": API_KEY,
"url": TARGET_URL,
}
HEADERS = {
'WSA-Content-Type': 'application/json',
'WSA-Accept': 'application/json'
}
DATA = {
"foo": "bar"
}
response = requests.post(SCRAPER_URL, data=DATA, params=PARAMS, headers=HEADERS)
print(response.text)<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.webscrapingapi.com/v1?api_key=<YOUR_API_KEY>&url=https%3A%2F%2Fhttpbin.org%2Fpost",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "{\n \"foo\": \"bar\"\n}",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"io/ioutil"
"net/http"
"strings"
)
func main() {
url := "https://api.webscrapingapi.com/v1?api_key=<YOUR_API_KEY>&url=https%3A%2F%2Fhttpbin.org%2Fpost"
payload := strings.NewReader("{\n \"foo\": \"bar\"\n}")
req, _ := http.NewRequest("POST", url, payload)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.webscrapingapi.com/v1?api_key=<YOUR_API_KEY>&url=https%3A%2F%2Fhttpbin.org%2Fpost")
.body("{\n \"foo\": \"bar\"\n}")
.asString();var client = new RestClient("https://api.webscrapingapi.com/v1?api_key=<YOUR_API_KEY>&url=https%3A%2F%2Fhttpbin.org%2Fpost");
var request = new RestRequest(Method.POST);
request.AddParameter("undefined", "{\n \"foo\": \"bar\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);require 'uri'
require 'net/http'
require 'openssl'
url = URI("https://api.webscrapingapi.com/v1?api_key=<YOUR_API_KEY>&url=https%3A%2F%2Fhttpbin.org%2Fpost")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
request = Net::HTTP::Post.new(url)
request.body = "{\n \"foo\": \"bar\"\n}"
response = http.request(request)
puts response.read_bodyResponse example
{
"form": {
"foo": "bar"
},
"url": "https://httpbin.org/post"
}PUT Request
PUT https://api.webscrapingapi.com/v1?api_key=<YOUR_API_KEY>&url=https://httpbin.org/put
Query Parameters
| Name | Type | Description |
|---|---|---|
api_key | string | <YOUR_API_KEY> |
url | string | https://httpbin.org/put/ |
Request Body
| Name | Type | Description |
|---|---|---|
foo | Any | bar |
Code Samples
curl --request PUT \
--url "https://api.webscrapingapi.com/v1?api_key=<YOUR_API_KEY>&url=https%3A%2F%2Fhttpbin.org%2Fput" \
--data '{"foo": "bar"}'const response = await fetch("https://api.webscrapingapi.com/v1?api_key=<YOUR_API_KEY>&url=https%3A%2F%2Fhttpbin.org%2Fput", {
method: "PUT",
body: "{\n \"foo\": \"bar\"\n}"
});
const data = await response.text();
console.log(data);import requests
API_KEY = '<YOUR_API_KEY>'
SCRAPER_URL = 'https://api.webscrapingapi.com/v1'
TARGET_URL = 'https://httpbin.org/put'
PARAMS = {
"api_key": API_KEY,
"url": TARGET_URL,
}
HEADERS = {
'WSA-Content-Type': 'application/json',
'WSA-Accept': 'application/json'
}
DATA = {
"foo": "bar"
}
response = requests.put(SCRAPER_URL, data=DATA, params=PARAMS, headers=HEADERS)
print(response.text)<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.webscrapingapi.com/v1?api_key=<YOUR_API_KEY>&url=https%3A%2F%2Fhttpbin.org%2Fput",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => "{\n \"foo\": \"bar\"\n}",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"io/ioutil"
"net/http"
"strings"
)
func main() {
url := "https://api.webscrapingapi.com/v1?api_key=<YOUR_API_KEY>&url=https%3A%2F%2Fhttpbin.org%2Fput"
payload := strings.NewReader("{\n \"foo\": \"bar\"\n}")
req, _ := http.NewRequest("PUT", url, payload)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.put("https://api.webscrapingapi.com/v1?api_key=<YOUR_API_KEY>&url=https%3A%2F%2Fhttpbin.org%2Fput")
.body("{\n \"foo\": \"bar\"\n}")
.asString();var client = new RestClient("https://api.webscrapingapi.com/v1?api_key=<YOUR_API_KEY>&url=https%3A%2F%2Fhttpbin.org%2Fput");
var request = new RestRequest(Method.PUT);
request.AddParameter("undefined", "{\n \"foo\": \"bar\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);require 'uri'
require 'net/http'
require 'openssl'
url = URI("https://api.webscrapingapi.com/v1?api_key=<YOUR_API_KEY>&url=https%3A%2F%2Fhttpbin.org%2Fput")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
request = Net::HTTP::Put.new(url)
request.body = "{\n \"foo\": \"bar\"\n}"
response = http.request(request)
puts response.read_bodyResponse example
{
"form": {
"foo": "bar"
},
"url": "https://httpbin.org/put"
}PATCH Request
PATCH https://api.webscrapingapi.com/v1?api_key=<YOUR_API_KEY>&url=https://reqres.in/api/users/2
Query Parameters
| Name | Type | Description |
|---|---|---|
api_key | string | <YOUR_API_KEY> |
url | string | https://reqres.in/api/users/2 |
Request Body
| Name | Type | Description |
|---|---|---|
foo | Any | bar |
Code Samples
curl --request PATCH \
--url "https://api.webscrapingapi.com/v1?api_key=<YOUR_API_KEY>&url=https://reqres.in/api/users/2" \
--data '{"foo": "bar"}'const response = await fetch("https://api.webscrapingapi.com/v1?api_key=<YOUR_API_KEY>&url=https://reqres.in/api/users/2", {
method: "PATCH",
body: "{\n \"foo\": \"bar\"\n}"
});
const data = await response.text();
console.log(data);import requests
API_KEY = '<YOUR_API_KEY>'
SCRAPER_URL = 'https://api.webscrapingapi.com/v1'
TARGET_URL = 'https://reqres.in/api/users/2'
PARAMS = {
"api_key": API_KEY,
"url": TARGET_URL,
}
HEADERS = {
'WSA-Content-Type': 'application/json',
'WSA-Accept': 'application/json'
}
DATA = {
"foo": "bar"
}
response = requests.patch(SCRAPER_URL, data=DATA, params=PARAMS, headers=HEADERS)
print(response.text)<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.webscrapingapi.com/v1?api_key=<YOUR_API_KEY>&url=https://reqres.in/api/users/2",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PATCH",
CURLOPT_POSTFIELDS => "{\n \"foo\": \"bar\"\n}",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"io/ioutil"
"net/http"
"strings"
)
func main() {
url := "https://api.webscrapingapi.com/v1?api_key=<YOUR_API_KEY>&url=https://reqres.in/api/users/2"
payload := strings.NewReader("{\n \"foo\": \"bar\"\n}")
req, _ := http.NewRequest("PATCH", url, payload)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.patch("https://api.webscrapingapi.com/v1?api_key=<YOUR_API_KEY>&url=https://reqres.in/api/users/2")
.body("{\n \"foo\": \"bar\"\n}")
.asString();var client = new RestClient("https://api.webscrapingapi.com/v1?api_key=<YOUR_API_KEY>&url=https://reqres.in/api/users/2");
var request = new RestRequest(Method.PATCH);
request.AddParameter("undefined", "{\n \"foo\": \"bar\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);require 'uri'
require 'net/http'
require 'openssl'
url = URI("https://api.webscrapingapi.com/v1?api_key=<YOUR_API_KEY>&url=https://reqres.in/api/users/2")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
request = Net::HTTP::Patch.new(url)
request.body = "{\n \"foo\": \"bar\"\n}"
response = http.request(request)
puts response.read_bodyResponse example
{
"name": "morpheus",
"job": "zion resident",
"updatedAt": "2024-07-09T06:47:34.063Z"
}