Schema library travel
Return a flight-price snapshot from a public page.
Pass this JSON Schema and a public source URL to/extract/json. Capture a timestamped public itinerary and displayed price.
TEXT
MARKDOWN
LINKS
const res = await client.extract.json({
url: 'https://example.com/pricing',
json_schema: {
type: 'object',
properties: {
plan: { type: 'string' },
price: { type: 'number' },
},
},
})res = client.extract.json(
url='https://example.com/pricing',
json_schema={
'type': 'object',
'properties': {
'plan': {'type': 'string'},
'price': {'type': 'number'},
},
},
)tabstack extract json https://example.com/pricing \
--schema '{"type":"object","properties":{"plan":{"type":"string"},"price":{"type":"number"}}}'What it captures
Fields in this flight-price snapshot.
Point-in-time price snapshot for a flight itinerary from an OTA or airline website.
| Field | Type | What it holds |
|---|---|---|
origin_iata | string, required | IATA code for the origin airport. |
origin_city | string | City name for the origin airport. |
destination_iata | string, required | IATA code for the destination airport. |
destination_city | string | City name for the destination airport. |
outbound_date | string, required | Date of the outbound flight. |
return_date | string | Date of the return flight (for roundtrip). |
trip_type | string, required | Type of trip. |
airline | string, required | Operating airline name. |
flight_number | string | Flight number. |
cabin_class | string, required | Cabin class of the booking. |
stops | number, required | Number of stops (0 = nonstop). |
layover_airports | array | IATA codes of layover airports. |
total_duration_minutes | number | Total flight duration in minutes. |
outbound_departure | string | Departure datetime for outbound flight. |
outbound_arrival | string | Arrival datetime for outbound flight. |
price_usd | number, required | Total price in USD. |
price_currency | string | Currency code for the price. |
taxes_fees_usd | number | Total taxes and fees in USD. |
base_fare_usd | number | Base fare before taxes in USD. |
booking_url | string | URL to book this flight. |
seats_remaining | number | Number of seats remaining at this price. |
refundable | boolean | Whether the ticket is refundable. |
snapshot_at | string, required | ISO 8601 timestamp of the price snapshot. |
page_title | string | Title of the source page. Tabstack auto-fills this from page metadata when left empty. |
favicon | string | Favicon URL of the source page. Tabstack auto-fills this from page metadata when left empty. |
Example
Inspect and validate the response shape.
The example below is generated from the schema to demonstrate its structure. Edit the object or paste a real response to validate it in your browser.
What it checks
Pass or fail, and the first reason why.
Whether the text parses as JSON, whether the top level is an object, and whether each field the schema requires is present at the declared type. A null is allowed anywhere. Every key you ask for is present. A field the page does not state can come back null, empty, a placeholder number, or a guessed value. Validate values, not just keys.
Usage
Send the schema with your source URL.
The schema travels with the request rather than living on your account, so the same call can send a trimmed version for one page and the full one for another. Every key you ask for is present. A field the page does not state can come back null, empty, a placeholder number, or a guessed value. Validate values, not just keys.
import schema from './flight-price-snapshot.json'
const res = await client.extract.json({
url: 'https://example.com/pricing',
json_schema: schema,
})tabstack extract json 'https://example.com/pricing' \
--schema @./flight-price-snapshot.jsonAdaptation
Make the schema match your application.
The schema is a starting point, not a guarantee that every source page contains every field. Three things are worth doing before you write one into your system, and the schema-authoring guide covers the rest.
Remove what you do not need
A shorter schema is a smaller response and fewer fields to handle.
Describe the ambiguous ones
A description tells Extract what to look for when a label could mean two things.
Validate before you store
Check the returned object against the schema rather than trusting it.
Related
Related schemas
Other schemas in this category.
- Same category: attraction & experience.
- Same category: hotel listing.
- Same category: restaurant listing.
- The job rather than the object: the Extract API.