Fetches a URL and extracts structured data according to a provided JSON schema
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.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",
)
print(response){
"error": "invalid JSON request body"
}{
"error": "failed to fetch URL"
}Returns Examples
{
"error": "invalid JSON request body"
}{
"error": "failed to fetch URL"
}