Fetching Data

Nested JSON Paths

Use path when an API wraps the list you need inside another JSON key.

Wrapped Lists#

Some APIs return JSON like this:

json
{  "items": [    { "title": "First review" },    { "title": "Second review" }  ]}

The list is not the whole response. It lives inside items.

Use path="items" to fetch that list:

php
{{ fetch "https://api.example.com/reviews" path="items" }}  <article>{{ title }}</article>{{ /fetch }}

Deeper Paths#

For deeper JSON, separate keys with dots:

json
{  "data": {    "items": [      { "title": "First review" }    ]  }}
php
{{ fetch "https://api.example.com/reviews" path="data.items" }}  <article>{{ title }}</article>{{ /fetch }}

What Path Selects#

path chooses the JSON value that the fetch block should render.

If the path points to a list, the block repeats for each item. If it points to one object, the block renders once. If the path does not exist, the fetch block is empty.