---
title: "Extract Data From a Website: Pages, Sites and APIs"
description: "Three ways to extract data from a website: one page as markdown or JSON, every URL on a site with map, or structured records. 1 credit per call."
url: https://perceptlayer.com/blog/extract-data-from-website
---

[Blog](https://perceptlayer.com/blog) / [Data engineering](https://perceptlayer.com/blog/category/data-engineering)

# Extract Data From a Website: Pages, Sites and APIs

31 Oct 2026 Updated 10 Nov 2026 Perceptlayer 8 min read

To extract data from a website, pick the route by what you need back. For one page, call `GET /v1/web-scraper/scrape` with the `url` and `response_type` set to `markdown` or `json`. For the URLs of a whole site, call `GET /v1/web-scraper/map` first, then scrape the pages you keep. For a site with its own endpoints, such as Google Maps, call those and get named fields instead of page text. Every successful call costs 1 credit; failed calls cost nothing.

## Key takeaways

-   `GET /v1/web-scraper/scrape` takes a required `url` (up to 2048 characters) and optional `response_type` ( `json` or `markdown`), `javascript` and `include_html`, for 1 credit per successful call.
-   `GET /v1/web-scraper/map` takes a `url` plus optional `limit`, `search` (up to 200 characters) and `include_subdomains`, so a whole site costs 1 credit to map and 1 credit per page you then scrape.
-   A site with dedicated endpoints skips parsing: the recorded `GET /v1/google-maps/reviews` response returns `items[]` with `rating`, `timestamp`, `review_text` and `review_language`, plus a `nextPage` token.
-   Mapping a site and scraping 500 of its pages is 1 + 500 = 501 credits, inside the Starter pack's 10,000. The 100 free credits you get after verifying an email address cover a map and 99 pages.

## Which route fits the data you want?

The right route depends on the shape of the answer you need, not on the site. If you want the text of one page, for a model or a search index, scrape that page. If you want to know what pages a site has before you decide what to read, map it. If the site is one where you want records, such as places, reviews or listings, check whether it has dedicated endpoints, because named JSON fields save you writing and maintaining a parser.

| You need | Endpoint | Required parameters | Cost per successful call |
| --- | --- | --- | --- |
| One page as markdown or JSON | `GET /v1/web-scraper/scrape` | `url` | 1 credit |
| The URLs of a site | `GET /v1/web-scraper/map` | `url` | 1 credit |
| Places on Google Maps | `GET /v1/google-maps/simple-search` | `query` | 1 credit |
| Reviews of one place | `GET /v1/google-maps/reviews` | `business_id` | 1 credit |

The catalogue covers 707 websites through 3,834 endpoints, all returning JSON, so it's worth a look on the [all APIs page](https://perceptlayer.com/apis) before you build anything generic. When the site you need isn't there, the two Web Scraper endpoints work on any URL you can pass in.

## How do you extract one page as markdown or JSON?

Send the page's address, URL-encoded, in `url` to the scrape endpoint and choose the output with `response_type`. Markdown suits text you'll read or feed to a model, since it keeps headings, lists and links. JSON suits code that processes the result. The call fetches and converts in one request, so you don't run an HTML parser yourself.

```bash
curl "https://api.perceptlayer.com/v1/web-scraper/scrape?url=https%3A%2F%2Fexample.com&response_type=markdown" \
  -H "X-API-Key: $API_KEY"
```

| Parameter | Type | Required | Documented constraint |
| --- | --- | --- | --- |
| `url` | string | yes | Up to 2048 characters |
| `response_type` | string | no | One of `json`, `markdown` |
| `javascript` | boolean | no | No further detail documented |
| `include_html` | boolean | no | No further detail documented |

We haven't recorded a response from this endpoint, so this post doesn't show one. Run the request in the playground on the [Scrape endpoint page](https://perceptlayer.com/apis/web-scraper/scrape) with a URL you care about and look at the output for both `response_type` values before you write code that reads it. The parameter names suggest what `javascript` and `include_html` switch on; the playground shows what they change for your page.

Keys start with `sk_live_` and go in the `X-API-Key` header, or in the `api_key` query parameter where you can't set headers. For what to strip from page text before it reaches a model, see [Website to Markdown: Clean Page Text for LLMs](https://perceptlayer.com/blog/website-to-markdown-for-llms); this post doesn't repeat it.

## How do you find every URL on a site?

Call the map endpoint with the site's address to get the site's URLs in one call, which gives you the list you scrape from. Three optional parameters shape that list. Their names suggest what they do: `search` (up to 200 characters) for a term the URLs should match, `limit` for how many come back, and `include_subdomains` for whether hosts such as `docs.example.com` count. The API documents only their types, so confirm the effect of each in the playground.

```bash
curl "https://api.perceptlayer.com/v1/web-scraper/map?url=https%3A%2F%2Fexample.com&search=docs&limit=100" \
  -H "X-API-Key: $API_KEY"
```

| Parameter | Type | Required | Documented constraint |
| --- | --- | --- | --- |
| `url` | string | yes | Up to 2048 characters |
| `limit` | integer | no | No further constraint documented |
| `search` | string | no | Up to 200 characters |
| `include_subdomains` | boolean | no | No further constraint documented |

There's no recorded map response either, so check the output in the playground on the [Map endpoint page](https://perceptlayer.com/apis/web-scraper/map) before you parse it. Mapping first has a cost benefit: for one credit you see the URL list, so you can decide how many pages to scrape before you spend anything on them.

### How do you scrape the pages you kept?

Once you have the URLs you want, one per line in a text file, the loop is short. This script reads `urls.txt`, scrapes each page as markdown, and writes the response body to a file. It reads no fields from the response, because the response shape isn't recorded here; it saves what comes back so you can inspect it. It waits on 429 and 503 using `Retry-After`.

```python
import os
import pathlib
import time

import requests

API_KEY = os.environ["API_KEY"]
SCRAPE = "https://api.perceptlayer.com/v1/web-scraper/scrape"
out = pathlib.Path("pages")
out.mkdir(exist_ok=True)

urls = [u.strip() for u in open("urls.txt") if u.strip()]
for i, url in enumerate(urls):
    for attempt in range(3):
        r = requests.get(
            SCRAPE,
            params={"url": url, "response_type": "markdown"},
            headers={"X-API-Key": API_KEY},
            timeout=90,
        )
        if r.status_code in (429, 503):
            time.sleep(int(r.headers.get("Retry-After", "5")))
            continue
        break
    if r.ok:
        (out / f"{i:05d}.txt").write_text(r.text)
        print(url, "credits used:", r.headers.get("X-Credits-Used"))
    else:
        print(url, "failed:", r.status_code, r.text[:200])
    time.sleep(1)
```

The one-second pause keeps a free account within its 1 request a second. Paying accounts run at least 5 requests a second, so you can shorten it. [Web Scraping with Python](https://perceptlayer.com/blog/web-scraping-python-guide) covers the do-it-yourself version of this loop, for when you'd rather fetch pages from your own machine.

## When should you use a site's dedicated endpoints instead?

Use dedicated endpoints when you want records with the same fields every time, not page text. A scraped page gives you whatever the page says, in the order it says it, and you still have to find the rating or the date inside it. A dedicated endpoint returns those values as named JSON fields. Google Maps is a good example: it has 11 endpoints, including search, business details, photos and reviews, each 1 credit per call.

The usual path is a search, then a lookup for each place you keep. `simple-search` takes a `query` and its recorded items each carry a `business_id`, and the reviews endpoint takes a parameter with the same name. This is the recorded reviews request:

```bash
curl "https://api.perceptlayer.com/v1/google-maps/reviews?business_id=0x60188b88b7d8f7ab%3A0x2133080e9923eaac" \
  -H "X-API-Key: $API_KEY"
```

The recorded response, trimmed, with reviewer names and profile links left out:

```json
{
  "items": [
    {
      "review_source": "Google",
      "review_id": "Ci9DQUlRQUNvZENodHljRjlvT25kVUxXTmpaamhNWjFac016WTVSMjlqUVRCb1VYYxAB",
      "rating": 5,
      "timestamp": 1779471094452,
      …
      "review_text": [
        "A must do! Easy access via Yamanote line > Shibuya > exit Hachiko exit and walk to the 41 or 42 bus (suica card OK) then four stops to Sugekari Elem Sch > once …"
      ],
      "review_language": [
        "en"
      ],
      …
      "is_google_review": true
    },
    …
  ],
  "nextPage": "CjEIARIpCgoAP7_LADY2____EhBrFsVuDgXaYeq0lg4AAAAAGgn92PQCY8g0lvwYACIA"
}
```

Compare that with scraping the same reviews from a page: no selectors, no guessing which line is the date, and `review_text` and `review_language` come back as arrays. The reviews endpoint also takes `sort` (one of 1, 2, 3 or 4), `search` (up to 100 characters), `limit`, `pages` and a string `page` parameter; see the [Google Maps API page](https://perceptlayer.com/apis/google-maps) for all 11 endpoints. [Google Maps Scraper or Places Data API](https://perceptlayer.com/blog/google-maps-scraper-vs-api) compares this route with building a scraper.

### How do you turn reviews into rows?

This script reads only fields that appear in the recorded response and writes one CSV row per review. The 13-digit `timestamp` values in the recording convert to May and June 2026 when read as milliseconds since the Unix epoch, which is how the script treats them.

```python
import csv
import datetime
import os

import requests

r = requests.get(
    "https://api.perceptlayer.com/v1/google-maps/reviews",
    params={"business_id": "0x60188b88b7d8f7ab:0x2133080e9923eaac"},
    headers={"X-API-Key": os.environ["API_KEY"]},
    timeout=60,
)
r.raise_for_status()
data = r.json()

with open("reviews.csv", "w", newline="") as f:
    w = csv.writer(f)
    w.writerow(["review_id", "rating", "date", "language", "text"])
    for item in data.get("items", []):
        ts = item.get("timestamp")
        date = datetime.datetime.fromtimestamp(ts / 1000, datetime.timezone.utc).date() if ts else ""
        w.writerow([
            item.get("review_id"),
            item.get("rating"),
            date,
            ",".join(item.get("review_language", [])),
            " ".join(item.get("review_text", [])),
        ])

print("nextPage:", data.get("nextPage"))
```

The script prints `nextPage` rather than following it. The endpoint's `page` parameter is a string of up to 4096 characters, which fits a token like this one; test in the playground that passing it returns the next page before you loop on it. [API Pagination: Cursors, Pages and Offsets](https://perceptlayer.com/blog/api-pagination-patterns) covers cursor loops in general.

## What does extracting data from a website cost?

Cost follows calls, not bytes: each successful call costs 1 credit, whether a page converts to a short paragraph or a long document. A failed call costs nothing and returns `X-Credits-Used: 0`, and every successful response reports `X-Credits-Used` and `X-Credits-Remaining`, so a job can log its own spend.

| Job | Arithmetic | Credits |
| --- | --- | --- |
| Read 30 pages a day for a month | 30 × 30 days × 1 credit | 900 |
| Map a site, scrape 500 pages | 1 + 500 × 1 credit | 501 |
| Map a docs site, scrape 20,000 pages | 1 + 20,000 × 1 credit | 20,001 |
| A weekly search plus reviews for 300 places | (300 + 1) × 4 weeks × 1 credit | 1,204 |

The 100 free credits on signup cover a test run: a map and 99 pages, or the first three days of the reading job. The first two jobs and the reviews job each fit the Starter pack's 10,000 credits, and the docs crawl fits the Build pack's 50,000. Purchased credits last 12 months, with no subscription. See [pricing](https://perceptlayer.com/pricing) for what credits cost and the [credits docs](https://docs.perceptlayer.com/credits) for how debits work.

### What should a job do when a call fails?

Every error returns an HTTP status and a JSON body with `code`, `message` and `request_id`. A `rate_limited` (429) or `temporarily_unavailable` (503) response carries `Retry-After` with the seconds to wait. Treat `invalid_parameters` (422) as a bug in your input, often a `url` that's malformed or too long, and `source_error` (502) as a page to retry later. Requests have no idempotency key, so a client timeout can hide a call that succeeded and was billed; keep timeouts generous. The [errors docs](https://docs.perceptlayer.com/errors) list every code.

Before any of this runs at volume, read the terms of the site you're extracting from and pace your requests. Then start small: run `map` on the site you need in the playground on the [Web Scraper API page](https://perceptlayer.com/apis/web-scraper), scrape two of its pages, and [get a free API key](https://perceptlayer.com/signup) when the output fits.

## APIs in this post

-   [Web Scraper **1 credit per call** · 4 endpoints](https://perceptlayer.com/apis/web-scraper)
-   [Google Maps **1 credit per call** · 11 endpoints](https://perceptlayer.com/apis/google-maps)

## Frequently asked questions

### How much does it cost to extract data from a website?

Each successful call costs 1 credit: one page scraped, one site mapped, or one page of reviews. Failed calls cost nothing and return `X-Credits-Used: 0`. Mapping a site and scraping 500 of its pages is 501 credits. Every account gets 100 free credits after verifying an email address, with no credit card. The pricing page lists what packs cost.

### Can I extract data from a whole website at once?

Not in one call. Map the site with `GET /v1/web-scraper/map` to get its URLs, check the list and keep the URLs you need, then scrape each page with `GET /v1/web-scraper/scrape`. That's 1 credit for the map and 1 per page. Pace the loop to your account's request rate and read the site's terms first.

### Should I get a page as markdown or JSON?

Choose markdown when a person or a language model will read the text, because it keeps headings, lists and links. Choose JSON when code will process the result. Both come from the same `GET /v1/web-scraper/scrape` call through `response_type`, at the same 1 credit, so run both in the playground on a page you care about and compare.

### Why use dedicated endpoints instead of scraping the page?

Dedicated endpoints return named fields, so you don't write or maintain a parser. The recorded Google Maps reviews response, for example, has `rating`, `timestamp`, `review_text` and `review_language` per review, plus a `nextPage` token. A scraped page gives you the same information as text that your code has to find again every time the page layout changes.

### How fast can I extract pages?

Request rates are per account, shared by all its keys, and counted per minute. Free accounts get 1 request a second, 60 a minute; paying accounts run at least 5 a second, 300 a minute, depending on the pack. Responses carry `RateLimit-Remaining` and `RateLimit-Reset`, and a 429 carries `Retry-After`. The [rate limits docs](https://docs.perceptlayer.com/rate-limits) have the details.

web scraping data extraction markdown sitemaps google maps

## More from the blog

1.  [Data engineering](https://perceptlayer.com/blog/category/data-engineering) 18 Oct 2026 Perceptlayer 6 min read
    
    ## [Web Scraping in JavaScript with Node.js](https://perceptlayer.com/blog/web-scraping-javascript-node)
    
    Web scraping in JavaScript with Node 22: fetch and cheerio for static pages, Playwright when a page renders in the browser, or one API call at 1 credit a page.
    
2.  [Data engineering](https://perceptlayer.com/blog/category/data-engineering) 18 Oct 2026 Perceptlayer 7 min read
    
    ## [Web Scraping with Python: Requests, Parsing and When to Stop](https://perceptlayer.com/blog/web-scraping-python-guide)
    
    A web scraping Python tutorial: requests and BeautifulSoup for a practice site, robots.txt checks, a 2-second delay, CSV output, and when an API costs less.
    
3.  [Data engineering](https://perceptlayer.com/blog/category/data-engineering) 8 Aug 2026 Updated 10 Nov 2026 Perceptlayer 11 min read
    
    ## [Scraper or API: What Maintaining a Scraper Really Involves](https://perceptlayer.com/blog/scraper-vs-api-maintenance-cost)
    
    What a scraper costs to keep running: selector fixes, proxies, retries and monitoring, set against an API at 1 credit per successful call.
