WebScrapingAPI Docs
Web Scraping APIBasic API Requests

GET Request

Send a basic WebScrapingAPI GET request with your API key and target URL.

Web scraping via GET requests requires users to pass two mandatory parameters to our API's endpoint:

  • api_key - used to authenticate the request on our servers
  • url - used to indicate the targeted URL that you want to scrape

Please make sure to escape the url parameter's value!

The most basic URL example for an authorised request on our API is:

https://api.webscrapingapi.com/v2?api_key=<YOUR_API_KEY>&url=<TARGETED_URL>

Basic GET Request Example

Do not call WebScrapingAPI directly from browser code. Send requests from your backend, worker, or another trusted server-side environment.

curl --get "https://api.webscrapingapi.com/v2" \
  --data-urlencode "api_key=<YOUR_API_KEY>" \
  --data-urlencode "url=https://webscrapingapi.com/"
const API_KEY = "<YOUR_API_KEY>";
const SCRAPER_URL = "https://api.webscrapingapi.com/v2";
const TARGET_URL = "https://webscrapingapi.com/";

const params = new URLSearchParams({
  api_key: API_KEY,
  url: TARGET_URL,
});

const response = await fetch(`${SCRAPER_URL}?${params}`);
const data = await response.text();

console.log(data);
import requests

API_KEY = '<YOUR_API_KEY>'
SCRAPER_URL = 'https://api.webscrapingapi.com/v2'

TARGET_URL = 'https://webscrapingapi.com/'

PARAMS = {
    "api_key": API_KEY,
    "url": TARGET_URL,
}

response = requests.get(SCRAPER_URL, params=PARAMS)

print(response.text)
<?php

$apiKey = '<YOUR_API_KEY>';
$scraperUrl = 'https://api.webscrapingapi.com/v2';
$targetUrl = 'https://webscrapingapi.com/';

$query = http_build_query([
    'api_key' => $apiKey,
    'url' => $targetUrl,
]);

$response = file_get_contents($scraperUrl . '?' . $query);

echo $response;
package main

import (
	"fmt"
	"io"
	"log"
	"net/http"
	"net/url"
)

func main() {
	params := url.Values{}
	params.Add("api_key", "<YOUR_API_KEY>")
	params.Add("url", "https://webscrapingapi.com/")

	requestURL := "https://api.webscrapingapi.com/v2?" + params.Encode()

	response, err := http.Get(requestURL)
	if err != nil {
		log.Fatal(err)
	}
	defer response.Body.Close()

	body, err := io.ReadAll(response.Body)
	if err != nil {
		log.Fatal(err)
	}

	fmt.Println(string(body))
}
import java.net.URI;
import java.net.URLEncoder;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.nio.charset.StandardCharsets;

public class Main {
    public static void main(String[] args) throws Exception {
        String apiKey = "<YOUR_API_KEY>";
        String targetUrl = "https://webscrapingapi.com/";

        String query = "api_key=" + URLEncoder.encode(apiKey, StandardCharsets.UTF_8)
            + "&url=" + URLEncoder.encode(targetUrl, StandardCharsets.UTF_8);

        HttpRequest request = HttpRequest.newBuilder()
            .uri(URI.create("https://api.webscrapingapi.com/v2?" + query))
            .GET()
            .build();

        HttpResponse<String> response = HttpClient.newHttpClient()
            .send(request, HttpResponse.BodyHandlers.ofString());

        System.out.println(response.body());
    }
}
using System;
using System.Net.Http;
using System.Threading.Tasks;

class Program
{
    static async Task Main()
    {
        var apiKey = "<YOUR_API_KEY>";
        var targetUrl = Uri.EscapeDataString("https://webscrapingapi.com/");
        var requestUrl = $"https://api.webscrapingapi.com/v2?api_key={apiKey}&url={targetUrl}";

        using var client = new HttpClient();
        var response = await client.GetStringAsync(requestUrl);

        Console.WriteLine(response);
    }
}
require 'net/http'
require 'uri'

api_key = '<YOUR_API_KEY>'
target_url = 'https://webscrapingapi.com/'

uri = URI('https://api.webscrapingapi.com/v2')
uri.query = URI.encode_www_form(
  api_key: api_key,
  url: target_url
)

response = Net::HTTP.get(uri)

puts response

Parameters

NameRequiredDescription
api_keyYour WebScrapingAPI key. Keep it server-side.
urlTarget page URL. URL-encode this value when building the query manually.
json_responseSet to 1 to return a JSON wrapper around the scraped response.

Response

For an HTML target, WebScrapingAPI returns the target HTML body.

<!doctype html>
<html>
  <head>
    <title>Example Domain</title>
  </head>
  <body>
    <h1>Example Domain</h1>
  </body>
</html>

For JSON or other content types, the response follows the target resource type or the feature enabled on the request.

JSON Response Sample

When json_response=1 is enabled, WebScrapingAPI returns a JSON wrapper around the target response.

{
  "headers": {
    "content-type": "text/html; charset=UTF-8"
  },
  "cost": 1,
  "initial-status-code": 200,
  "body": "<!doctype html><html>...</html>",
  "type": "html",
  "metadata": {
    "microdata": {
      "items": []
    },
    "json-ld": []
  }
}

Notes

For authentication setup, see Access the API. For rendering, geolocation, extraction rules, and other request controls, see Advanced API Features.

On this page