ManticDocs
Find forecasts

Filter and sort forecasts

List forecasts with chosen tags, ordered by latest run or creation time.

List tags

Tags are topic labels on forecasts, such as Economics. List them with GET /tags:

curl "https://api.mantic.com/tags" \
  -H "Authorization: Bearer $ACCESS_TOKEN"
{
  "tags": [
    {"label": "Economics"},
    {"label": "Energy"}
  ],
  "next": {"label": "Energy"}
}

The list is paginated. To collect every label in Python:

from mantic_client import ManticClient, paginate

client = ManticClient()
try:
    labels = [tag["label"] for tag in paginate(client, "/tags", "tags")]
finally:
    client.close()

Filter by tag

Pass labels, exactly as GET /tags returns them, in the JSON-encoded filter parameter of GET /questions. A forecast matches if it has any of them:

curl --get "https://api.mantic.com/questions" \
  -H "Authorization: Bearer $ACCESS_TOKEN" \
  --data-urlencode 'filter={"tags":["Economics","Energy"]}' \
  --data-urlencode "show_forecasts=true"

An empty tags list matches no forecasts.

Sort

Set the JSON-encoded sort parameter. key is latest_forecast.date (when the latest run completed; the default) or created_at (when the forecast was created), and order is desc (the default) or asc:

curl --get "https://api.mantic.com/questions" \
  -H "Authorization: Bearer $ACCESS_TOKEN" \
  --data-urlencode 'sort={"key":"created_at","order":"desc"}' \
  --data-urlencode "show_forecasts=true"

latest_forecast.date orders by when a forecast last ran, not by how much it moved; for movement, see Compare forecast runs over time. sort is ignored when you send search.

Page through the results

With paginate(), put filter and sort in params so every page uses the same values:

import json

from mantic_client import ManticClient, paginate

params = {
    "filter": json.dumps({"tags": ["Economics"]}),
    "sort": json.dumps({"key": "created_at", "order": "desc"}),
    "show_forecasts": "true",
}
client = ManticClient()
try:
    for question in paginate(client, "/questions", "questions", params):
        print(question["id"], question["title"])
finally:
    client.close()

On this page