Extract pricing to JSON

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

  • Pricing plans
  • Schema-constrained JSON
  • Source evidence
View as Markdown

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.

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

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