ManticDocs
Get started

Page through results

Follow the after and next cursor contract without skipping results or looping forever.

Paginated list endpoints return a next cursor with each page. Request the first page of GET /questions:

curl --get "https://api.mantic.com/questions" \
  -H "Authorization: Bearer $ACCESS_TOKEN" \
  --data-urlencode "show_forecasts=true"

An abridged response looks like this:

{
  "questions": [
    {
      "id": 123,
      "title": "Will UK CPI inflation be below 2.5% in December 2026?"
    }
  ],
  "next": {
    "date": "2026-09-18T10:42:31Z",
    "id": 123
  }
}

Send next back as the after parameter until next is null. The last page can be empty; stop only on null, and never build a cursor yourself. By default next is a JSON object: send it JSON-encoded. If URL-encoded cursors are enabled for your organisation, next is a string: send it unchanged.

Page until next is null

mantic_client.py includes a paginate() helper that handles both cursor forms:

def paginate(
    client: ManticClient, path: str, key: str, params: dict[str, Any] | None = None
) -> Iterator[dict[str, Any]]:
    """Yield every item under `key`, following `next` cursors until it is null."""
    params = dict(params or {})
    while True:
        page = client.request("GET", path, params=params).json()
        yield from page[key]
        cursor = page["next"]
        if cursor is None:
            return
        params["after"] = cursor if isinstance(cursor, str) else json.dumps(cursor)
  • key is the response field that holds the items, such as questions, forecasts or releases.
  • params are sent with every request. Keep filters, sort and show_forecasts the same on every page.

Call it with the endpoint path and collection key:

from mantic_client import ManticClient, paginate

client = ManticClient()
try:
    for question in paginate(client, "/questions", "questions", {"show_forecasts": "true"}):
        print(question["id"], question["title"])
finally:
    client.close()

Search results are a single page

Search results are ranked by relevance and returned as a single page, so next is null. Don't combine search with after: GET /questions returns 422 and GET /dashboards/{dashboard_id}/questions returns 400.

On this page