---
title: "Web Scraping API: URL to HTML, JSON, or Markdown | IPRoyal"
description: "Send a URL and get HTML, JSON, or Markdown back. IPRoyal handles proxies, browser rendering, and retries. $0.99 per 1,000 successful requests."
url: "https://iproyal.com/web-scraping-api/"
---

# Web Scraping API: From URL to HTML, JSON, or Markdown in One Request

Send a URL or a search keyword. We handle proxy rotation, browser rendering, CAPTCHAs, and retries. Test it on your own targets.

- $0.99 per 1,000 successful requests · 500 free credits until December 31, 2026

[Claim 500 Free Credits](https://dashboard.iproyal.com/me/scraper/)

[Talk to Sales](https://iproyal.com/request-a-demo/)

As seen on

## Tested on 739,000 Real-World URLs

A large technology company ran its own crawl list through our Web Scraping API on default settings from one account.

97.4%

URLs answered

2.4 s

Median response time

0

Rate-limit (429) responses

\~30K

URLs per hour

## Results by Site Type

Share of requests that returned the full page, by type of site.

Video & Social Platforms

99.6%+ delivered

Collect titles, descriptions, and metadata from public pages.

Large E-Commerce Marketplaces

99.7%+ delivered

Removed listings return the site's own not-found page, so you know what to drop.

Job & Review Sites

98.7%+ delivered

Monitor public job listings and review pages.

## Your Scraper, Before and After

Proxy rotation, headless browsers, and retry logic move to our side. Your code keeps only the request.

cURL  Python  PHP  Node.js  Java  Go  C#

```bash
#!/usr/bin/env bash

MAX_ATTEMPTS=5
mapfile -t PROXIES < <(load_proxy_pool proxies.txt)

fetch() {
  local url="$1" proxy html
  for ((attempt = 0; attempt < MAX_ATTEMPTS; attempt++)); do
    proxy="${PROXIES[RANDOM % ${#PROXIES[@]}]}"
    html=$(timeout 60 chromium --headless --disable-gpu \
      --proxy-server="$proxy" \
      --user-agent="$(random_ua)" \
      --dump-dom "$url" 2>/dev/null)
    # Chromium exits with 0 even when the page fails to load
    if [[ -n "$html" && "$html" != *"<body></body>"* && "$html" != *'"errorCode":"ERR_'* ]]; then
      if detect_captcha <<< "$html"; then
        html=$(handle_captcha "$url" "$proxy")
      fi
      printf '%s\n' "$html"
      return 0
    fi
    sleep $((2 ** attempt))
  done
  echo "All retries failed" >&2
  return 1
}

html=$(fetch https://example.com)
```

```
import random, time
from playwright.sync_api import sync_playwright

PROXIES = load_proxy_pool("proxies.txt")

def fetch(url, retries=5):
    for attempt in range(retries):
        proxy = random.choice(PROXIES)
        try:
            with sync_playwright() as p:
                browser = p.chromium.launch(proxy={"server": proxy})
                page = browser.new_page(user_agent=random_ua())
                page.goto(url, timeout=60000)
                if detect_captcha(page):
                    handle_captcha(page)
                html = page.content()
                browser.close()
                return html
        except Exception:
            time.sleep(2 ** attempt)
    raise RuntimeError("All retries failed")

html = fetch("https://example.com")
```

```
<?php

use HeadlessChromium\BrowserFactory;
use HeadlessChromium\Page;

$proxies = loadProxyPool('proxies.txt');

function fetchPage(string $url, array $proxies, int $retries = 5): string
{
    for ($attempt = 0; $attempt < $retries; $attempt++) {
        $proxy = $proxies[array_rand($proxies)];
        $browser = null;
        try {
            $browser = (new BrowserFactory())->createBrowser([
                'customFlags' => ['--proxy-server=' . $proxy],
                'userAgent' => randomUa(),
            ]);
            $page = $browser->createPage();
            $page->navigate($url)->waitForNavigation(Page::LOAD, 60000);
            if (detectCaptcha($page)) {
                handleCaptcha($page);
            }
            return $page->getHtml();
        } catch (Exception $e) {
            sleep(2 ** $attempt);
        } finally {
            $browser?->close();
        }
    }
    throw new RuntimeException('All retries failed');
}

$html = fetchPage('https://example.com', $proxies);
```

```
import { chromium } from 'playwright';

const PROXIES = loadProxyPool('proxies.txt');
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));

async function fetchPage(url, retries = 5) {
  for (let attempt = 0; attempt < retries; attempt++) {
    const proxy = PROXIES[Math.floor(Math.random() * PROXIES.length)];
    let browser;
    try {
      browser = await chromium.launch({ proxy: { server: proxy } });
      const page = await browser.newPage({ userAgent: randomUa() });
      await page.goto(url, { timeout: 60_000 });
      if (await detectCaptcha(page)) {
        await handleCaptcha(page);
      }
      return await page.content();
    } catch {
      await sleep(2 ** attempt * 1000);
    } finally {
      await browser?.close();
    }
  }
  throw new Error('All retries failed');
}

const html = await fetchPage('https://example.com');
```

```
import com.microsoft.playwright.*;
import com.microsoft.playwright.options.Proxy;
import java.util.List;
import java.util.concurrent.ThreadLocalRandom;

public class OwnScraper {
    static final int MAX_ATTEMPTS = 5;
    static final List<String> PROXIES = loadProxyPool("proxies.txt");

    static String fetch(String url) throws InterruptedException {
        for (int attempt = 0; attempt < MAX_ATTEMPTS; attempt++) {
            String proxy = PROXIES.get(ThreadLocalRandom.current().nextInt(PROXIES.size()));
            try (Playwright playwright = Playwright.create();
                 Browser browser = playwright.chromium().launch(
                     new BrowserType.LaunchOptions().setProxy(new Proxy(proxy)))) {
                Page page = browser.newPage(new Browser.NewPageOptions().setUserAgent(randomUa()));
                page.navigate(url, new Page.NavigateOptions().setTimeout(60000));
                if (detectCaptcha(page)) {
                    handleCaptcha(page);
                }
                return page.content();
            } catch (PlaywrightException e) {
                Thread.sleep((1L << attempt) * 1000);
            }
        }
        throw new RuntimeException("All retries failed");
    }

    public static void main(String[] args) throws InterruptedException {
        String html = fetch("https://example.com");
    }
}
```

```
package main

import (
	"errors"
	"fmt"
	"math/rand"
	"time"

	"github.com/mxschmitt/playwright-go"
)

const maxAttempts = 5

var proxies = loadProxyPool("proxies.txt")

func fetch(url string) (string, error) {
	pw, err := playwright.Run()
	if err != nil {
		return "", err
	}
	defer pw.Stop()

	for attempt := 0; attempt < maxAttempts; attempt++ {
		proxy := proxies[rand.Intn(len(proxies))]
		html, err := tryFetch(pw, url, proxy)
		if err == nil {
			return html, nil
		}
		time.Sleep(time.Duration(1<<attempt) * time.Second)
	}
	return "", errors.New("all retries failed")
}

func tryFetch(pw *playwright.Playwright, url, proxy string) (string, error) {
	browser, err := pw.Chromium.Launch(playwright.BrowserTypeLaunchOptions{
		Proxy: &playwright.Proxy{Server: proxy},
	})
	if err != nil {
		return "", err
	}
	defer browser.Close()

	page, err := browser.NewPage(playwright.BrowserNewPageOptions{
		UserAgent: playwright.String(randomUA()),
	})
	if err != nil {
		return "", err
	}
	if _, err := page.Goto(url, playwright.PageGotoOptions{Timeout: playwright.Float(60000)}); err != nil {
		return "", err
	}
	if detectCaptcha(page) {
		handleCaptcha(page)
	}
	return page.Content()
}

func main() {
	html, err := fetch("https://example.com")
	if err != nil {
		fmt.Println("request failed:", err)
		return
	}
	fmt.Println(html)
}
```

```
using Microsoft.Playwright;

var proxies = LoadProxyPool("proxies.txt");

async Task<string> Fetch(string url, int retries = 5)
{
    using var playwright = await Playwright.CreateAsync();
    for (var attempt = 0; attempt < retries; attempt++)
    {
        var proxy = proxies[Random.Shared.Next(proxies.Count)];
        try
        {
            await using var browser = await playwright.Chromium.LaunchAsync(new() { Proxy = new Proxy { Server = proxy } });
            var page = await browser.NewPageAsync(new() { UserAgent = RandomUa() });
            await page.GotoAsync(url, new() { Timeout = 60000 });
            if (await DetectCaptcha(page))
            {
                await HandleCaptcha(page);
            }
            return await page.ContentAsync();
        }
        catch (Exception e) when (e is PlaywrightException or TimeoutException)
        {
            await Task.Delay(TimeSpan.FromSeconds(Math.Pow(2, attempt)));
        }
    }
    throw new Exception("All retries failed");
}

var html = await Fetch("https://example.com");
```

### Before: Your Own Scraper

You load and rotate a proxy pool, launch a headless browser for every attempt, and detect CAPTCHAs yourself. Failed attempts wait and retry up to five times. The helper functions for proxies, user agents, and CAPTCHAs are more code you also maintain.

cURL  Python  PHP  Node.js  Java  Go  C#

```bash
curl -X POST https://scrape.iproyal.com/v1/scrape \
  -H "Authorization: Bearer $WEB_SCRAPING_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"source": "universal", "url": "https://example.com"}' \
  --max-time 90
```

```
import os

import requests

response = requests.post(
    "https://scrape.iproyal.com/v1/scrape",
    headers={"Authorization": f"Bearer {os.environ['WEB_SCRAPING_API_TOKEN']}"},
    json={"source": "universal", "url": "https://example.com"},
    timeout=90,
)

if response.ok:
    result = response.json()["results"][0]
    print(result["status_code"], result["job_id"])
    html = result["content"]
else:
    error = response.json()["error"]
    print(response.status_code, error["code"], error["message"])
```

```
<?php

$ch = curl_init('https://scrape.iproyal.com/v1/scrape');

curl_setopt_array($ch, [
    CURLOPT_POST => true,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_TIMEOUT => 90,
    CURLOPT_HTTPHEADER => [
        'Authorization: Bearer ' . getenv('WEB_SCRAPING_API_TOKEN'),
        'Content-Type: application/json',
    ],
    CURLOPT_POSTFIELDS => json_encode([
        'source' => 'universal',
        'url' => 'https://example.com',
    ]),
]);

$body = json_decode(curl_exec($ch), true);
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);

if ($status === 200) {
    $result = $body['results'][0];
    echo $result['status_code'] . ' ' . $result['job_id'] . PHP_EOL;
    $html = $result['content'];
} else {
    echo $status . ' ' . $body['error']['code'] . ': ' . $body['error']['message'] . PHP_EOL;
}
```

```
const response = await fetch('https://scrape.iproyal.com/v1/scrape', {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.WEB_SCRAPING_API_TOKEN}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({ source: 'universal', url: 'https://example.com' }),
  signal: AbortSignal.timeout(90_000),
});

const body = await response.json();

if (response.ok) {
  const [result] = body.results;
  console.log(result.status_code, result.job_id);
  const html = result.content;
} else {
  console.error(response.status, body.error.code, body.error.message);
}
```

```
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.time.Duration;
import java.util.Map;

public class ScrapeExample {
    public static void main(String[] args) throws Exception {
        ObjectMapper mapper = new ObjectMapper();
        String payload = mapper.writeValueAsString(Map.of(
            "source", "universal",
            "url", "https://example.com"
        ));

        HttpRequest request = HttpRequest.newBuilder()
            .uri(URI.create("https://scrape.iproyal.com/v1/scrape"))
            .header("Authorization", "Bearer " + System.getenv("WEB_SCRAPING_API_TOKEN"))
            .header("Content-Type", "application/json")
            .timeout(Duration.ofSeconds(90))
            .POST(HttpRequest.BodyPublishers.ofString(payload))
            .build();

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

        if (response.statusCode() == 200) {
            JsonNode result = body.get("results").get(0);
            System.out.println(result.get("status_code").asInt() + " " + result.get("job_id").asText());
            String html = result.get("content").asText();
        } else {
            JsonNode error = body.get("error");
            System.out.println(response.statusCode() + " " + error.get("code").asText() + ": " + error.get("message").asText());
        }
    }
}
```

```
package main

import (
	"bytes"
	"encoding/json"
	"fmt"
	"net/http"
	"os"
	"time"
)

type apiResponse struct {
	Results []struct {
		Content    json.RawMessage `json:"content"`
		JobID      string          `json:"job_id"`
		StatusCode int             `json:"status_code"`
	} `json:"results"`
	Error struct {
		Code    string `json:"code"`
		Message string `json:"message"`
	} `json:"error"`
}

func main() {
	payload, _ := json.Marshal(map[string]any{
		"source": "universal",
		"url":    "https://example.com",
	})

	req, _ := http.NewRequest(http.MethodPost, "https://scrape.iproyal.com/v1/scrape", bytes.NewReader(payload))
	req.Header.Set("Authorization", "Bearer "+os.Getenv("WEB_SCRAPING_API_TOKEN"))
	req.Header.Set("Content-Type", "application/json")

	client := &http.Client{Timeout: 90 * time.Second}
	resp, err := client.Do(req)
	if err != nil {
		fmt.Println("request failed:", err)
		return
	}
	defer resp.Body.Close()

	var body apiResponse
	if err := json.NewDecoder(resp.Body).Decode(&body); err != nil {
		fmt.Println("unexpected response:", err)
		return
	}

	if resp.StatusCode != http.StatusOK {
		fmt.Println(resp.StatusCode, body.Error.Code, body.Error.Message)
		return
	}

	result := body.Results[0]
	fmt.Println(result.StatusCode, result.JobID)

	var html string
	json.Unmarshal(result.Content, &html)
}
```

```
using System.Net.Http.Headers;
using System.Net.Http.Json;
using System.Text.Json;

using var client = new HttpClient { Timeout = TimeSpan.FromSeconds(90) };
client.DefaultRequestHeaders.Authorization =
    new AuthenticationHeaderValue("Bearer", Environment.GetEnvironmentVariable("WEB_SCRAPING_API_TOKEN"));

var response = await client.PostAsJsonAsync(
    "https://scrape.iproyal.com/v1/scrape",
    new { source = "universal", url = "https://example.com" });

using var body = JsonDocument.Parse(await response.Content.ReadAsStringAsync());

if (response.IsSuccessStatusCode)
{
    var result = body.RootElement.GetProperty("results")[0];
    Console.WriteLine($"{result.GetProperty("status_code").GetInt32()} {result.GetProperty("job_id").GetString()}");
    var html = result.GetProperty("content").GetString();
}
else
{
    var error = body.RootElement.GetProperty("error");
    Console.WriteLine($"{(int)response.StatusCode} {error.GetProperty("code").GetString()}: {error.GetProperty("message").GetString()}");
}
```

### After: IPRoyal Web Scraping API

One POST request with your API token and the target URL. Everything else runs on our side. Blocked pages count as failed, and you pay nothing for them.

## From Token to Data in 3 Steps

- Copy your API token from the IPRoyal dashboard.

- Send the target URL or keyword, plus the country you need.

- Receive HTML, JSON, or Markdown. Each successful request uses one credit.

[Read the Quick-Start Guide](https://iproyal.com/quick-start-guides/web-scraping-api/)

Launch price until December 31, 2026

## Web Scraping API Pricing

Try the Web Scraping API at no cost. After that, you pay $0.99 per 1,000 successful requests.\*

- 500 free credits, valid for 14 days
- Failed requests cost nothing
- Purchased credits never expire

[Claim 500 Free Credits](https://dashboard.iproyal.com/me/scraper/)

## Trusted By

Built for data teams of every size

## Your Targets, Tested Before You Commit

Scraping at scale? Book a short call with our team and share the sites you need. We run a sample through the API and send you the results, so you decide with real data, and discuss pricing for your volume.\*\*

[Book a Test Call](https://iproyal.com/request-a-demo/?interest=wsapi-custom-test)

## Frequently Asked Questions

### What is a web scraping API?

A web scraping API is a service that collects website content for you. You send the page you need and get its content back, while the technical side of scraping runs in the background.

IPRoyal's version covers public web pages, Google search results, and images through a single endpoint. Call it from your own script or tool, such as Python, Node.js, cURL, or Postman. Proxies, browser rendering, CAPTCHAs, and retries are handled for you, and the output arrives as HTML, structured JSON, or Markdown.

### How is the Web Scraping API different from using proxies?

With proxies, you get the IPs and your scraper does the rest: rotating them, running headless browsers, detecting failed pages, and retrying. Here you send a URL and get the page back. All of that work moves to our side.

### What do I need to get started with the Web Scraping API?

An IPRoyal account and your own scraping setup. There is no visual crawler or no-code interface: you call the endpoint from your code. In the dashboard you manage your API token and send your first call with cURL, Python, Node.js, or any tool that makes HTTP requests.

### Where can I find the Web Scraping API documentation?

The [documentation](https://docs.iproyal.com/scraping-tools/web-scraper-api-beta/) covers every endpoint, parameter, error code, and supported country. The [Quick-Start Guide](https://iproyal.com/quick-start-guides/web-scraping-api/) shows how to find your token, test in the dashboard, and run a working Python example.

### How does Web Scraping API pricing work?

The launch price is $0.99 per 1,000 successful requests until December 31, 2026. From January 1, 2027, it starts at $1.25.

One successful request uses one credit, whether you ask for a web page, Google search results, or an image. You are charged only when the content is delivered. Otherwise the credit returns to your balance. Calls rejected before scraping starts, such as those with an invalid token or over your concurrency limit, are free.

You buy credits in the dashboard, starting at 1,000. They never expire, so anything bought at the launch price stays yours after it changes.

### Can I try it for free?

Yes. Until December 31, 2026, you can claim 500 free credits without approval or a waitlist. Select 'Web Scraping API' under 'Scraping products' in the left menu of your dashboard. They are valid for 14 days from that moment.

### What formats do I get back?

Web pages come back as HTML by default, or as structured JSON or Markdown, which is useful for AI data pipelines. Google search results arrive as JSON, and images as a Base64 string. Every successful response also includes the HTTP status code the target website returned.

### Which websites can I collect data from?

Publicly available data, as defined in our [Acceptable Use Policy](https://iproyal.com/acceptable-use-policy/): public web pages, Google search results, and images at a known URL. Pages that require a login are not supported, and some website categories are restricted. You are responsible for following each website's terms and the laws that apply to your data collection.

### What happens when a request fails?

It costs nothing. For short-term failures, such as a website being briefly unavailable, IPRoyal retries once before responding. If the second attempt also fails, you get an error code and a message explaining what went wrong.

Some errors can be retried as they are, such as reaching your concurrency limit. Others need a fix first, such as an invalid token or an empty balance. The [documentation](https://docs.iproyal.com/scraping-tools/web-scraper-api-beta/api/) lists every code.

### Is IPRoyal certified for security and compliance?

IPRoyal’s ISO 27001 and SOC 2 certifications are in progress. In addition, here's how we keep our network secure:

- Every new supply partner passes a five-step review
- Partners complete KYC and KYB before they join
- Identity and consent are verified independently
- Identity verified by an independent third party
- The IP pool is scanned daily against public abuse databases
- We don't work with reseller clients or unverifiable private networks

###### \* Minimum order is 1,000 credits. Pricing changes from $0.99 to $1.25 per 1,000 credits from January 1, 2027. Open access is subject to our [Terms of Service](https://iproyal.com/terms-of-service/) and [Acceptable Use Policy](https://iproyal.com/acceptable-use-policy/).

###### \*\* Some website categories are restricted. We confirm your targets during the call.
