prompt, the AI decides the shape of the answer: field names, types and nesting can change between pages and runs, and prices come back as text like "£51.77". Add a schema and every result has exactly the fields and types you define. Use one whenever code reads the result.
Schemas work on Scrape, Batch scrape, Crawl and Parse.
A first schema
result.content:
priceis the number51.77; the£moved intocurrency.in_stockis a real boolean, not the text “In stock”.ratingisnull: the site shows its stars as an image, and Spidra reads the page’s text.
Every field comes back
Every field in your schema is in the result. When the page doesn’t have a value, the field isnull; it’s never left out. On a book page with no ISBN:
required listed the fields or not, so code can always read every key. Give fields that may be missing a nullable type, as below, so null is a valid value.
Nullable fields
Write the type as a list that includes"null":
["number", "null"], ["boolean", "null"], ["array", "null"].
Lists of items
The root of a schema is always an object. To get a list, put an array inside it:Fixed choices with enum
enum limits a field to the values you list. Include null for “none of these”:
stars is null because the rating isn’t in the page’s text.
Nested objects
Defineproperties inside a property:
Prompt and schema together
The schema sets the shape; theprompt tells the AI what to pick and how to write it. Here the prompt filters the quotes and lowercases the tags:
Generate a schema from Zod or Pydantic
Spidra takes standard JSON Schema, so you can generate it from the models you already have.What a schema can contain
Supported keywords:type (including lists with "null"), properties, required, items, enum, description and nullable. A description on a field is a good place for hints (“price without the currency symbol”).
Keywords Spidra can’t use, such as $ref, oneOf, allOf, not and if, are ignored, and the submit response lists them in schema_warnings:
Optional fields as anyOf with null, which shows this warning; those fields still come back, as null when missing.
Schema errors
A schema with a structural problem is refused with422 before anything runs, and nothing is charged:
- The root
typemust be"object". Wrap lists in an object property, as above. - Nesting goes 5 levels deep at most.
- The schema can be up to 10 KB.
Sites that come back structured already
Links from supported sites such as Amazon, Google Maps and LinkedIn have the site’s own fields instructuredData, and with "output": "json" and no prompt or schema those fields are the content, with no AI. Add a schema only if you want to reshape them.
