---
title: "API Documentation"
description: "Complete API reference for WebScraping.AI. Learn how to scrape websites, extract data with AI, and integrate with your applications."
url: https://webscraping.ai/docs#data
markdown_index: https://webscraping.ai/llms.txt
---
## Structured Data

Get structured JSON for any public web page from its normal URL. WebScraping.AI works out what kind of page it is and returns its key values under consistent snake\_case names, for example a product's title, price and rating, or an article's headline, author and date. Pages of the same kind on a site always come back in the same shape.

Some popular sites have dedicated parsers with fixed fields. For other sites, the first request for a new kind of page also has an AI model learn the page's structure, so it can take up to about 45 seconds; keep your client timeout above that. From then on, pages of that kind on that site return data without the wait, for every user. If learning takes longer, the request returns `503` with `error_code: "structure_processing"` and `retry_after` (seconds, also sent as the `Retry-After` header). That request is not charged: retry after `retry_after` seconds. If no structured data can be found (an empty page or a login wall, for example), the request returns `422` with `error_code: "structure_unavailable"`, also not charged; use [`/ai/fields`](https://webscraping.ai/docs/ai-fields.md) to name the values you want instead. On those sites, redirects within the site (for example `http` to `https`) are followed, but redirects to another site aren't: those return `500` with `error_code: "target_redirect"` and the redirect target in `message` (not charged). Starting too many new kinds of pages in an hour returns `429` with `error_code: "rate_limited"`. If loading the page or extracting the data runs out of time, the request returns `500` with `error_code: "timeout"` (not charged); try again. If the AI model is busy, the request returns `500` with `error_code: "ai_unavailable"` (not charged); try again.

Pricing: the price per request varies depending on the site. Pages without a dedicated parser are always fetched with `proxy=auto` (the cheapest proxy tier that works for the site). Requests that fail to fetch are not charged; pages that parse empty or don't exist are.

`GET /data`

##### Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| url required | string | URL of any public page, e.g. `https://books.toscrape.com/catalogue/a-light-in-the-attic_1000/index.html` |
| api\_key required | string | Your API key |
| country | string | Country of the proxy used to fetch the page, one of the [proxy countries](https://webscraping.ai/docs#param-country). Without it, Indeed country sites (e.g. `uk.indeed.com`) use that site's country and everything else uses `us` |
| transcript | boolean | Video pages on sites with a dedicated parser only. Also fetch the transcript into `data.transcript` (null when no matching captions are available). If the transcript fetch fails, the whole request fails with a 500 and is not charged |
| transcript\_language | string | With `transcript=true`. Caption language to pick, e.g. `de`. Without it, English is preferred, then the first available track |
| timeout, js\_timeout, wait\_for, device | various | Page-scraping options, as in [Parameters](https://webscraping.ai/docs/parameters.md). Used only for pages without a dedicated parser. There are no `js` or `proxy` options: `/data` renders pages with JavaScript where the site needs it and always uses `proxy=auto` |

##### Example

**cURL**

```bash
curl -G "https://api.webscraping.ai/data" \
  --data-urlencode "api_key=YOUR_API_KEY" \
  --data-urlencode "url=https://books.toscrape.com/catalogue/a-light-in-the-attic_1000/index.html"
```

**Python**

```python
# pip install webscraping_ai
# https://pypi.org/project/webscraping-ai/
from webscraping_ai import Client

client = Client(api_key="YOUR_API_KEY")
result = client.data("https://books.toscrape.com/catalogue/a-light-in-the-attic_1000/index.html")
print(result["request_parameters"]["provider"], result["parse_status"])
if result["data"]:
    print(result["data"]["title"])
```

**JavaScript**

```javascript
// npm install webscraping-ai
// https://www.npmjs.com/package/webscraping-ai
import { WebScrapingAI } from 'webscraping-ai';

const client = new WebScrapingAI({ apiKey: 'YOUR_API_KEY' });
const result = await client.data({ url: 'https://books.toscrape.com/catalogue/a-light-in-the-attic_1000/index.html' });
console.log(result.request_parameters.provider, result.parse_status);
console.log(result.data?.title);
```

**PHP**

```php
<?php
// composer require webscraping-ai/webscraping-ai-php
// https://packagist.org/packages/webscraping-ai/webscraping-ai-php
require 'vendor/autoload.php';

use WebScrapingAI\Client;

$client = new Client('YOUR_API_KEY');
$result = $client->data(url: 'https://books.toscrape.com/catalogue/a-light-in-the-attic_1000/index.html');
echo $result['request_parameters']['provider'], ' ', $result['parse_status'], "\n";
echo $result['data']['title'] ?? '', "\n";
```

**Ruby**

```ruby
# gem install webscraping_ai
# https://rubygems.org/gems/webscraping_ai
require 'webscraping_ai'

client = WebScrapingAI::Client.new(api_key: 'YOUR_API_KEY')
result = client.data('https://books.toscrape.com/catalogue/a-light-in-the-attic_1000/index.html')
puts "#{result['request_parameters']['provider']} #{result['parse_status']}"
puts result['data']&.dig('title')
```

**Go**

```go
// go get github.com/webscraping-ai/webscraping-ai-go/v4
// https://pkg.go.dev/github.com/webscraping-ai/webscraping-ai-go/v4
package main

import (
    "context"
    "encoding/json"
    "fmt"

    webscrapingai "github.com/webscraping-ai/webscraping-ai-go/v4"
)

func main() {
    client, _ := webscrapingai.NewClient(&webscrapingai.Config{APIKey: "YOUR_API_KEY"})
    res, _ := client.Data(context.Background(), &webscrapingai.DataOptions{
        URL: "https://books.toscrape.com/catalogue/a-light-in-the-attic_1000/index.html",
    })
    fmt.Println(res.RequestParameters.Provider, res.ParseStatus)

    // Data is raw JSON whose shape depends on the site and page type
    var page struct {
        Title string `json:"title"`
    }
    if res.Data != nil {
        json.Unmarshal(res.Data, &page)
    }
    fmt.Println(page.Title)
}
```

**Java**

```java
// Maven: ai.webscraping:webscraping-ai:4.3.1
// https://central.sonatype.com/artifact/ai.webscraping/webscraping-ai
import ai.webscraping.Client;
import ai.webscraping.Config;
import ai.webscraping.option.DataOptions;
import ai.webscraping.result.DataResult;

Client client = new Client(Config.builder().apiKey("YOUR_API_KEY").build());
DataResult result = client.data(DataOptions.builder()
    .url("https://books.toscrape.com/catalogue/a-light-in-the-attic_1000/index.html")
    .build());
System.out.println(result.getRequestParameters().getProvider() + " " + result.getParseStatus());
if (result.getData() != null) {
    System.out.println(result.getData().path("title").asText());
}
```

**C#**

```csharp
// dotnet add package WebScrapingAI
// https://www.nuget.org/packages/WebScrapingAI
using WebScrapingAI;

var client = new WebScrapingAIClient(new WebScrapingAIClientOptions { ApiKey = "YOUR_API_KEY" });
var result = await client.DataAsync(new DataRequest {
    Url = "https://books.toscrape.com/catalogue/a-light-in-the-attic_1000/index.html",
});
Console.WriteLine($"{result.RequestParameters.Provider} {result.ParseStatus}");
if (result.Data is { } data) {
    Console.WriteLine(data.GetProperty("title").GetString());
}
```

##### Response

```json
{
  "request_parameters": {
    "url": "https://books.toscrape.com/catalogue/a-light-in-the-attic_1000/index.html",
    "provider": "toscrape.com",
    "type": "book"
  },
  "parse_status": "ok",
  "data": {
    "title": "A Light in the Attic",
    "price": 51.77,
    "currency": "£",
    "availability": "In stock (22 available)",
    ...
  }
}
```

Trimmed. `provider` is the site and `type` the kind of page; the fields in `data` depend on both. They use snake\_case, and values a page doesn't expose are null (some flags come back `false`, and lists come back empty). Pages without a dedicated parser get the fields chosen when their structure was learned.

**parse\_status:** `ok` when the page was parsed, `parse_failed` when it was fetched but couldn't be parsed (`data` may be null or partial), `not_found` when the page doesn't exist. All three are successful, billed requests; only failed fetches are free. A `503` (`structure_processing`, not charged) carries no `data`: retry after `retry_after` seconds.
