xtract.bot
POST /api/jsonpath

Query a JSON document with a JSONPath expression (`$.users[*].name`). Supports filters, slices, recursive descent, and array indices.

Evaluates a JSONPath expression against a JSON document and returns the matching values. JSONPath is the JSON analogue of XPath — useful when you want a single value or array of values from a deeply-nested structure without writing code. Supported features: dot-notation property access, array indices and slices, recursive descent (`..`), wildcards (`*`), and filter expressions (`[?(@.price > 10)]`). Two response modes: `values` (default) returns the matching values; `paths` returns the JSONPath strings instead — useful when you need to know *where* a match was found.

Inputs

NameTypeDefaultDescription
document*stringThe JSON document to query, as a string.
query*stringThe JSONPath expression (e.g. $.store.book[*].author).
resultModeenum (values | paths | both)"values"What to return for each match.
maxResultsnumber (1…100000)10000Cap on the number of matches returned.

Response

Modes: json. Cache: yes (24h TTL).

Code samples

Built from the store-authors example.


curl -X POST https://api.xtract.bot/api/jsonpath \
  -H "Content-Type: application/json" \
  -H "Accept: application/json" \
  -H "X-Account-Id: $XTRACT_ACCOUNT_ID" \
  -H "X-Api-Key: $XTRACT_API_KEY" \
  -d '{
  "document": "{\"store\":{\"book\":[{\"author\":\"Tolkien\"},{\"author\":\"Pratchett\"}],\"bicycle\":{\"color\":\"red\"}}}",
  "query": "$.author",
  "resultMode": "values",
  "maxResults": 100
}'