Skip to content
Get started

JSON

generate.json(GenerateJsonParams**kwargs) -> GenerateJsonResponse
POST/generate/json

Fetches URL content, extracts data, and transforms it using AI based on custom instructions. Use this to generate new content, summaries, or restructured data.

ParametersExpand Collapse
instructions: str

Instructions describing how to transform the data

json_schema: object

JSON schema defining the structure of the transformed output

url: str

URL to fetch content from

formaturi
effort: Optional[Literal["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: Optional[GeoTarget]

Optional geotargeting parameters for proxy requests

country: Optional[str]

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: Optional[bool]

Bypass cache and force fresh data retrieval

ReturnsExpand Collapse
Dict[str, object]

JSON

import os
from tabstack import Tabstack

client = Tabstack(
    api_key=os.environ.get("TABSTACK_API_KEY"),  # This is the default and can be omitted
)
response = client.generate.json(
    instructions="For each story, categorize it (tech/business/science/other) and write a one-sentence summary explaining what it's about in simple terms.",
    json_schema={
        "properties": {
            "summaries": {
                "items": {
                    "properties": {
                        "category": {
                            "description": "Story category (tech/business/science/etc)",
                            "type": "string",
                        },
                        "summary": {
                            "description": "One-sentence summary of the story",
                            "type": "string",
                        },
                        "title": {
                            "description": "Story title",
                            "type": "string",
                        },
                    },
                    "type": "object",
                },
                "type": "array",
            }
        },
        "type": "object",
    },
    url="https://news.ycombinator.com",
)
print(response)
{
  "error": "invalid JSON request body"
}
{
  "error": "failed to fetch URL"
}
Returns Examples
{
  "error": "invalid JSON request body"
}
{
  "error": "failed to fetch URL"
}