# Web scraping API for any URL

> Point us at a URL. We deal with the wall.

- Endpoint: `POST https://scrapenest.dev/v1/scrape/url`
- Price: 1 – 40 credits (+5 with AI extraction)
- Category: Utilities
- Reference: https://scrapenest.dev/docs#ep-scrape-url
- Web page: https://scrapenest.dev/catalog/scrape-url
- Updated: 2026-11-04

A general-purpose fetcher with automatic escalation. We pick the cheapest method that works for each target and escalate through tougher anti-bot handling as needed, so you see one response and one tier-aware bill, not three retries.

## The hard part

Generic scrapers make you pick a tier up front (datacenter or residential, render JS or not) and bill the same whether the page came back or not. Pick wrong and you're either burning credits on soft targets or staring at blocked pages on hard ones. We pick the right level per site and only charge for what actually succeeded.

## Web scraping API: what you get

- `render=auto|direct|browser|stealth`: pick how much firepower you want.
- `force_proxy=true` routes through residential proxies for soft-blocked targets.
- Returns cleaned title/description/text and the original status_code, proxy_used, and elapsed_ms.
- `include_html=true` returns the raw page source alongside the cleaned text. Same call, no extra credits.
- `return_markdown=true` adds a `markdown` field, clean for LLM input. No extra credits.
- `extract_rules={"price":".price","links":{"selector":"a","attr":"href","all":true}}` returns a typed `extracted` object. No extra credits.
- `wait_for_selector`, `wait_ms`, `block_ads`, `device=mobile`, custom viewport: all available, all free.
- `country=us` routes through an in-country residential exit (billed at the residential tier).
- Pages we can't deliver (timeout, block, upstream error) don't bill. A delivered 404 'not found' bills 1 credit.

## Web scraping API use cases

- **Feed pages to an LLM**: `return_markdown: true` returns clean Markdown, and `max_chars` with `offset` or `focus` keeps long pages inside your context window.
- **Price and product monitoring**: `structured.product` carries the declared name, price, currency and rating, and `extract_rules` pulls any field by CSS selector.
- **JavaScript-heavy sites**: `render: "browser"` runs the page in a headless browser, with `wait_for_selector` and `wait_ms` for late content.
- **Geo-specific content**: `country` fetches through a residential exit in that country and reports it in `exit_country`.

## Web scraping API quickstart

Install an SDK with `pip install scrapenest` or `npm install scrapenest`, or call the HTTP API directly with your key in the `Authorization: Bearer` header. No key yet? Sign up free at https://scrapenest.dev/signup, verify your email, then create a key in your dashboard.

### Python SDK

```python
import os
from scrapenest import Client

client = Client(os.environ["SCRAPENEST_API_KEY"], timeout=120)
page = client.scrape_url("https://www.zillow.com/homes/Austin-TX", render="auto")
if page.success:
    print(page.status_code, page.method, page.credits_charged, "credits")
    print((page.text or "")[:500])
else:
    print(page.error_code, page.error)
```

### Node SDK

```javascript
import { ScrapeNest } from "scrapenest";

const client = new ScrapeNest({ apiKey: process.env.SCRAPENEST_API_KEY, timeout: 120_000 });
const page = await client.scrapeUrl({
  url: "https://www.zillow.com/homes/Austin-TX",
  render: "auto",
});
if (page.success) console.log(page.status_code, page.method, (page.text ?? "").slice(0, 500));
else console.log(page.error_code, page.error);
```

### curl

```bash
curl -X POST https://scrapenest.dev/v1/scrape/url \
  -H "Authorization: Bearer sn_••••" \
  -H "Content-Type: application/json" \
  -d '{ "url": "https://www.zillow.com/homes/Austin-TX", "render": "auto" }'
```

### Python (httpx)

```python
import httpx

r = httpx.post(
    "https://scrapenest.dev/v1/scrape/url",
    headers={"Authorization": "Bearer sn_••••"},
    json={"url": "https://www.zillow.com/homes/Austin-TX", "render": "auto"},
    timeout=90,
)
page = r.json()
print(page["status_code"], page["method"], len(page["text"] or ""))
```

### JavaScript (fetch)

```javascript
const r = await fetch("https://scrapenest.dev/v1/scrape/url", {
  method: "POST",
  headers: {
    "Authorization": "Bearer sn_••••",
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    url: "https://www.zillow.com/homes/Austin-TX",
    render: "auto",
  }),
});
const page = await r.json();
```

### Go

```go
package main

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

func main() {
    body, _ := json.Marshal(map[string]any{
        "url":    "https://www.zillow.com/homes/Austin-TX",
        "render": "auto",
    })
    req, _ := http.NewRequest("POST",
        "https://scrapenest.dev/v1/scrape/url", bytes.NewReader(body))
    req.Header.Set("Authorization", "Bearer sn_••••")
    req.Header.Set("Content-Type", "application/json")
    resp, _ := http.DefaultClient.Do(req)
    defer resp.Body.Close()
    var page struct {
        StatusCode int    `json:"status_code"`
        Method     string
        Text       string
    }
    json.NewDecoder(resp.Body).Decode(&page)
    fmt.Println(page.StatusCode, page.Method, len(page.Text))
}
```

## Web scraping API request and response

### Request body

```json
{
  "url": "https://www.zillow.com/homes/Austin-TX",
  "render": "auto"
}
```

### Response

```json
{
  "success": true,
  "url": "https://www.zillow.com/homes/Austin-TX",
  "final_url": "https://www.zillow.com/homes/Austin-TX/",
  "status_code": 200,
  "method": "stealth",
  "proxy_used": "residential",
  "elapsed_ms": 13790,
  "title": "Austin TX Real Estate | Zillow",
  "description": "1,284 homes for sale in Austin, TX. See pricing and listing details.",
  "text": "1,284 homes for sale in Austin, TX …",
  "text_total_chars": 18240,
  "cache_hit": false,
  "escalated": false,
  "credits_charged": 40
}
```

Fields with no value are left out of the JSON rather than sent as `null`, so read optional fields defensively. `proxy_used` is the exception: it is always present, `null` included.

## Web scraping API pricing

Tiered by what it takes to render the page. A simple HTML fetch is the floor; a full JS render with anti-bot handling is the ceiling. You only pay the tier that actually succeeded. Adding `ai_query` for AI extraction adds 5 credits when the extraction runs on a delivered page.

## Web scraping API limits

- `timeout_seconds`: 1 to 120, default about 100. Auto-escalation needs at least 20 s left on the budget.
- `max_chars`: 200 to 2,000,000. `focus`: up to 500 characters.
- `extract_rules`: up to 50 rules. `cookies`: up to 50. `headers`: up to 30.
- `wait_ms`: up to 10,000. `wait_for_timeout_ms`: 100 to 30,000. Viewport: 320 to 3840 wide, 240 to 2160 tall.
- `session_id` keeps the same residential exit for about 10 minutes and turns caching off for the request.
- Cache: 15 minutes by default, set with `cache_ttl_seconds` (0 to 86400).

## Web scraping API error codes

| HTTP | Code | Meaning |
| --- | --- | --- |
| 200 (in body) | `anti_bot_block` | The target's anti-bot refused the fetch, after one stealth retry unless `auto_escalate` is false. Not billed. |
| 200 (in body) | `timeout` | The fetch ran past `timeout_seconds`. Not billed. |
| 200 (in body) | `not_found` | The target returned 404 or 410. Bills the 1-credit floor. |
| 200 (in body) | `empty_response` | The page had no usable content. Not billed. |
| 200 (in body) | `rate_limited` | The target answered 429 without a challenge. Not billed. |
| 200 (in body) | `connection_failed` | The host doesn't resolve, or `render: "direct"` couldn't connect. Not billed. |
| 400 | `unsafe_url` | The URL is malformed or points at a private host. |
| 422 | `country_unavailable` | No residential exit is available for `country` right now. Not billed. |
| 429 | `render_capacity` | Every browser-render slot is busy. Retry after 15 s. Not billed. |
| 503 | `upstream_failed` | The fetch service couldn't run the request. Not billed. |

Every endpoint can also return `401 unauthorized` (missing or wrong key), `402 insufficient_credits` (balance used up), `403 email_not_verified` (an email signup must verify its address before its key works) and `429 rate_limited` or `concurrency_limit_exceeded`. All errors share one JSON envelope; see the [error reference](https://scrapenest.dev/docs#errors).

## Web scraping API FAQ

### Can it scrape JavaScript-rendered pages?

Yes. `render: "auto"` (the default) picks a plain fetch or a headless browser per site, and `render: "browser"` forces a full render. Add `wait_for_selector` or `wait_ms` for content that loads late.

### What happens when a site blocks the request?

With `auto_escalate` on (the default), a refused `auto` or `browser` fetch is retried once in stealth mode, and you pay the stealth rate only if that retry succeeds. A request that stays blocked returns `success: false` with `error_code: "anti_bot_block"` and costs nothing.

### How much does a scrape cost?

It depends on the tier that delivered the page: 1 credit for a plain fetch, 5 with a browser render, 10 through a residential proxy, and 40 for a residential browser render or stealth. `ai_query` extraction adds 5, a cache hit bills 1, and a delivered 404 bills 1.

### Can I get Markdown or the raw HTML?

Yes, at no extra cost. `return_markdown: true` adds a `markdown` field and `include_html: true` adds the raw `html`. `markdown_mode: "main"` (the default) keeps only the main content.

### How do I read a very long page?

Set `max_chars`. The response reports `text_total_chars` and a `next_offset` you send back as `offset` to read the next window. With `focus`, you get the passages that best match your terms instead of only the beginning.

## Related endpoints

- [Batch scraping API](https://scrapenest.dev/catalog/scrape-batch.md): `POST /v1/scrape/batch`. Fetch up to 10 URLs in a single request — the same engine as Any URL, run concurrently.
- [Website screenshot API](https://scrapenest.dev/catalog/screenshot.md): `POST /v1/scrape/screenshot`. Capture a screenshot of any public URL and get back base64-encoded PNG or JPEG. Viewport or full-page, with auto-fallback for hostile sites.
- [HTML to PDF API for any URL](https://scrapenest.dev/catalog/pdf.md): `POST /v1/scrape/pdf`. Render any URL to a print-ready PDF — Letter, A4, Legal, and more. Base64 back, anti-bot handled.
- [Deep Search API for RAG](https://scrapenest.dev/catalog/search-deep.md): `POST /v1/search/deep`. Search plus auto-fetch the top N pages with extracted text. One round-trip for RAG.

## Get 1,000 free credits

Every account starts on the Free plan: 1,000 credits a month, no card. Verify your email, then mint an API key and make this call. Sign up at https://scrapenest.dev/signup.
