Skip to content
Get started

JSON

client.extract.json(ExtractJsonParams { json_schema, url, effort, 2 more } body, RequestOptionsoptions?): ExtractJsonResponse
POST/extract/json

Fetches a URL and extracts structured data according to a provided JSON schema

ParametersExpand Collapse
body: ExtractJsonParams { json_schema, url, effort, 2 more }
json_schema: unknown

JSON schema definition that describes the structure of data to extract.

url: string

URL to fetch and extract data from

formaturi
effort?: "min" | "standard" | "max"

Fetch effort level controlling speed vs. capability tradeoff. "min": fastest, no fallback (1-5s). "standard": balanced with enhanced reliability (default, 3-15s). "max": full browser rendering for JS-heavy sites (15-60s).

Accepts one of the following:
"min"
"standard"
"max"
geo_target?: GeoTarget

Optional geotargeting parameters for proxy requests

country?: string

Country code using ISO 3166-1 alpha-2 standard (2 letters, e.g., "US", "GB", "JP"). See: https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2

nocache?: boolean

Bypass cache and force fresh data retrieval

ReturnsExpand Collapse
ExtractJsonResponse = Record<string, unknown>

JSON

import Tabstack from '@tabstack/sdk';

const client = new Tabstack({
  apiKey: process.env['TABSTACK_API_KEY'], // This is the default and can be omitted
});

const response = await client.extract.json({
  json_schema: {
    properties: {
      stories: {
        items: {
          properties: {
            author: { description: 'Author username', type: 'string' },
            points: { description: 'Story points', type: 'number' },
            title: { description: 'Story title', type: 'string' },
          },
          type: 'object',
        },
        type: 'array',
      },
    },
    type: 'object',
  },
  url: 'https://news.ycombinator.com',
});

console.log(response);
{
  "error": "invalid JSON request body"
}
{
  "error": "failed to fetch URL"
}
Returns Examples
{
  "error": "invalid JSON request body"
}
{
  "error": "failed to fetch URL"
}