# Extract pricing to JSON

Turn a public pricing page into structured plan rows with verbatim evidence for each extracted field.

[Canonical HTML page](<https://developers.datasea.io/docs/extract-pricing-to-json>)

Submit the pricing page to `POST /v1/scrape` with `options.formats: ["json"]` and your schema under `options.json.schema`. JSON extraction is asynchronous. The API returns a job ID, and the completed job contains extracted values, source evidence, and missing-field details.

Use a named DataSea API key with `web:scrape` and `web:jobs:read` in the `X-API-Key` header. Choose a public HTTP(S) page you are authorized to access.

## Run the pricing extractor

Set DATASEA\_API\_KEY in your shell. Either client runs a live API job against the public pricing fixture by default. To extract current DataSea plans, run `python3 extract.py https://datasea.io/pricing/web-context`. Pass a JSON Schema file as the second argument to extract different fields.

### Python 3.10+

```bash
curl -fsSLO https://developers.datasea.io/examples/extract.py
python3 extract.py
```

### Node.js 22.18+

```bash
curl -fsSLO https://developers.datasea.io/examples/extract.ts
node extract.ts
```

## Read and verify the extraction

Read `data.result.outputs.json.data` on the completed job. Its sibling `evidence` array has `field` (a JSON Pointer into the extracted data), `quote` (verbatim source text), and `sourceUrl`. The scripts collect these fields together with the job ID, final URL, capture time, and usage.

Keep quote-only plans as rows, use explicit `null` for unstated prices or intervals, and inspect `missingFields`. Verify important prices against their cited excerpts and the source page before publishing or acting on them. Choose browser rendering if the page inserts its prices with JavaScript. Rendering increases the credit estimate.

## Illustrative extraction

This hand-written excerpt uses the fictional Harbor Notes pricing fixture. The download contains example rows and one evidence entry. It carries no live usage data.

```json
{
  "sourceUrl": "https://developers.datasea.io/examples/benchmark/fixtures/pricing-v1.html",
  "data": {
    "rows": [
      { "plan": "Harbor Starter", "price": "USD 19", "billingInterval": "month" },
      { "plan": "Harbor Team", "price": "USD 190", "billingInterval": "year" },
      { "plan": "Harbor Enterprise", "price": null, "billingInterval": null }
    ]
  },
  "evidence": [
    {
      "field": "/rows/0/price",
      "quote": "Harbor Starter costs USD 19 per month.",
      "sourceUrl": "https://developers.datasea.io/examples/benchmark/fixtures/pricing-v1.html"
    }
  ]
}
```

## Credits for a live run

The scripts set `render: "never"` and bypass the derived-output cache so the job acquires the page again. The maximum reservation is 7 credits (1 base plus up to 6 for JSON extraction). A delivered page that sends up to 40,000 characters to the model settles at 3 credits on these settings. A larger model input can settle at 5 or 7.

Use `usage.estimatedCredits` for the job estimate and `usage.settledCredits` after `usage.status` is `final` for the actual charge. Failed extraction has an explicit job error. Reuse the original `Idempotency-Key` with the identical request after a lost response.

## Additional resources

- [Sample extraction JSON](<https://developers.datasea.io/examples/samples/pricing-extraction.json>) — Download the illustrated rows and source evidence.
- [Python extractor](<https://developers.datasea.io/examples/extract.py>) — Run with Python 3.10 or later and the standard library.
- [TypeScript extractor](<https://developers.datasea.io/examples/extract.ts>) — Run with Node.js 22.18 or later.
- [Reproducible extraction benchmark](<https://developers.datasea.io/examples/benchmark/README.md>) — Fixture labels, scoring rules, and how to record live credit usage.
- [Web Context operations and outputs](<https://developers.datasea.io/docs/web-context-operations>) — Request fields, terminal states, credit costs, and error codes.
- [OpenAPI specification](<https://developers.datasea.io/openapi.yaml>) — Request and response schemas for the public API.

Last reviewed 2026-11-19
