Request configuration
Set the endpoint and request headers when you create the table:
CREATE VIRTUAL TABLE links USING vttp (
URL ('https://api.example.com/links'),
id INTEGER,
headers TEXT PATH '$.headers',
HEADERS ('Accept', 'application/json'),
url TEXT PATH '$.url'
);
URL (...) configures the request, while url TEXT declares a column from the
payload. Same name, different jobs. headers and body are also available as
ordinary column names now; VTTP doesn't add hidden columns to your schema.
The configuration names aren't case-sensitive, so URL, url, and UrL all work.
You can put them anywhere among the columns and use whitespace or comments between
tokens. Leave the directive names unquoted, and use single-quoted SQL strings for
their arguments. An apostrophe inside a value needs to be doubled: 'it''s a value'.
Unknown directives, extra arguments, and trailing tokens fail at table creation.
Exactly one URL is required. HEADERS is optional and repeatable. Response selection uses column PATH mappings and ordinary JSON queries.
To change the endpoint or headers, drop and recreate the table. There are no
OPTIONS blocks or per-query configuration arguments.
Coming from Hidden Columns
Older versions used url, headers, and body as hidden control columns. If you
have an existing table, drop and recreate it with the new declaration syntax:
| Previously | Now |
|---|---|
url TEXT DEFAULT '...' or WHERE url = '...' | URL ('...') in the declaration |
| Request headers supplied in a query | One HEADERS ('name', 'value') per header |
city TEXT GENERATED ALWAYS AS (address->'city') | city TEXT PATH '$.address.city' |
WHERE body = ... to select nested rows | A JSON text column and json_each |
todos('https://...') | Set URL ('...') when creating todos, then query todos |