> ## Documentation Index
> Fetch the complete documentation index at: https://platform.trendlinelabs.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Getting started

The TrendlineLabs Public API serves read-only prediction-market data across Polymarket, Kalshi, Limitless
and predict.fun: events, markets, prices, order books, price history and trades, with every answer
carrying its own freshness signal.

## 1. Get a key

API access is free, and our team approves each account.

1. Sign in at [trendlinelabs.ai](https://trendlinelabs.ai) and open **API keys** from your account menu
   ([trendlinelabs.ai/developer](https://trendlinelabs.ai/developer)).
2. Choose **Request API access**. You can add a short note about what you are building.
3. Once we approve it, the same page shows the key manager. Choose **Create key**, pick its scopes and copy
   the key.

Keys look like `tl_live_` plus a secret. The secret is shown once, at creation, so store it somewhere safe.
You can list and revoke your keys on the same page.

Until access is granted, creating a key answers 403 access\_not\_granted.

## 2. Make your first request

Every request sends the key as a bearer token. Set it once:

```sh theme={null}
export TRENDLINE_API_KEY=...            # your key
export TRENDLINE_API_BASE=https://systems.trendlinelabs.ai
```

Read your own key back, which needs no scope:

* curl: [`examples/getKey.sh`](#getkey)
* Python: [`examples/getKey.py`](#getkey)
* JavaScript (Node 18+, an ES module): [`examples/getKey.mjs`](#getkey)

The answer is [`examples/getKey.response.json`](#getkey): the key's id, scopes, tier, and its `limit` per
`window_s` seconds.

## 3. Walk from an event to a book

1. List events: [`examples/listEvents.sh`](#listevents) (`.py`, `.mjs`). Each event carries its `universal_id`.
2. Read one event: [`examples/getEvent.sh`](#getevent). Its `markets` list carries each market's `universal_id`.
3. Read a market's order book on one venue: [`examples/getOrderbook.sh`](#getorderbook).

Every example reads `TRENDLINE_API_BASE` and `TRENDLINE_API_KEY` from the environment, so the same file
runs against any base you point it at.

## 4. What every answer carries

* `X-Request-Id`: this request's id. Send your own `X-Request-Id` and it is echoed; the error envelope's
  `request_id` is the same value. Quote it when you ask for help.
* `Cache-Control: no-store` on every operation's answer (not on the reference document itself).
* `X-RateLimit-Limit`, `X-RateLimit-Remaining` and `X-RateLimit-Reset` once your key has passed the
  rate limiter (see [Rate limits](/guides/rate-limits)).

Next: [Authentication](/guides/authentication), [Errors](/guides/errors), [Freshness](/guides/freshness).

## Examples on this page

### getKey

```bash cURL theme={null}
#!/bin/sh
# getKey: Get the calling key. Needs TRENDLINE_API_KEY; TRENDLINE_API_BASE overrides the base.
curl -sS "${TRENDLINE_API_BASE:-https://systems.trendlinelabs.ai}/public/v1/key" \
  -H "Authorization: Bearer $TRENDLINE_API_KEY"
```

```python Python theme={null}
"""getKey: Get the calling key. Needs TRENDLINE_API_KEY; TRENDLINE_API_BASE overrides the base."""
import os

import requests

BASE = os.environ.get("TRENDLINE_API_BASE", "https://systems.trendlinelabs.ai")
KEY = os.environ["TRENDLINE_API_KEY"]

r = requests.get(f"{BASE}/public/v1/key", params={},
                 headers={"Authorization": f"Bearer {KEY}"}, timeout=10)
r.raise_for_status()
print(r.json())
```

```javascript JavaScript theme={null}
// getKey: Get the calling key. Needs TRENDLINE_API_KEY; TRENDLINE_API_BASE overrides the base.
const BASE = process.env.TRENDLINE_API_BASE ?? "https://systems.trendlinelabs.ai";
const KEY = process.env.TRENDLINE_API_KEY;
const r = await fetch(`${BASE}/public/v1/key`, { headers: { Authorization: `Bearer ${KEY}` } });
console.log(r.status, await r.json());
```

```json Response theme={null}
{
  "key_id": "6720f0c1a2b3c4d5e6f70812",
  "name": "research-bot",
  "prefix": "tl_live_",
  "last4": "Qx7k",
  "scopes": [
    "market:read"
  ],
  "tier": "FREE",
  "limit": 100,
  "window_s": 60,
  "created_at": "2026-10-01T09:00:00+00:00",
  "expires_at": "2027-10-01T09:00:00+00:00",
  "last_used_at": "2026-10-06T05:59:58+00:00"
}
```

### listEvents

```bash cURL theme={null}
#!/bin/sh
# listEvents: List active events. Needs TRENDLINE_API_KEY; TRENDLINE_API_BASE overrides the base.
curl -sS "${TRENDLINE_API_BASE:-https://systems.trendlinelabs.ai}/public/v1/events?limit=1" \
  -H "Authorization: Bearer $TRENDLINE_API_KEY"
```

```python Python theme={null}
"""listEvents: List active events. Needs TRENDLINE_API_KEY; TRENDLINE_API_BASE overrides the base."""
import os

import requests

BASE = os.environ.get("TRENDLINE_API_BASE", "https://systems.trendlinelabs.ai")
KEY = os.environ["TRENDLINE_API_KEY"]

r = requests.get(f"{BASE}/public/v1/events", params={"limit": "1"},
                 headers={"Authorization": f"Bearer {KEY}"}, timeout=10)
r.raise_for_status()
print(r.json())
```

```javascript JavaScript theme={null}
// listEvents: List active events. Needs TRENDLINE_API_KEY; TRENDLINE_API_BASE overrides the base.
const BASE = process.env.TRENDLINE_API_BASE ?? "https://systems.trendlinelabs.ai";
const KEY = process.env.TRENDLINE_API_KEY;
const r = await fetch(`${BASE}/public/v1/events?limit=1`, { headers: { Authorization: `Bearer ${KEY}` } });
console.log(r.status, await r.json());
```

```json Response theme={null}
{
  "events": [
    {
      "universal_id": "ev-btc-100k-2026",
      "title": "Bitcoin price at year end",
      "category_group": "crypto",
      "categories": [
        "crypto",
        "bitcoin"
      ],
      "platform_count": 2,
      "venues": [
        "kalshi",
        "polymarket"
      ],
      "kalshi_event_ticker": "KXBTC-26DEC31",
      "poly_event_slug": "bitcoin-above-100k-on-december-31",
      "limitless_event_id": null,
      "predictfun_event_id": null,
      "image_url": null,
      "resolution_date": "2026-12-31T23:59:59.000Z",
      "first_seen_at": "2026-09-01T12:00:00.000Z",
      "last_seen_at": "2026-10-06T05:59:30.000Z"
    }
  ],
  "next_cursor": "eyJ2IjoxLCJhZnRlciI6ImV2LWJ0Yy0xMDBrLTIwMjYiLCJmcCI6IjAwMDAwMDAwMDAwMDAwMDAifQ==",
  "universe_last_seen_at": "2026-10-06T05:59:30.000Z",
  "universe_age_s": 30
}
```

### getEvent

```bash cURL theme={null}
#!/bin/sh
# getEvent: Get one event with its markets. Needs TRENDLINE_API_KEY; TRENDLINE_API_BASE overrides the base.
curl -sS "${TRENDLINE_API_BASE:-https://systems.trendlinelabs.ai}/public/v1/events/ev-btc-100k-2026" \
  -H "Authorization: Bearer $TRENDLINE_API_KEY"
```

```python Python theme={null}
"""getEvent: Get one event with its markets. Needs TRENDLINE_API_KEY; TRENDLINE_API_BASE overrides the base."""
import os

import requests

BASE = os.environ.get("TRENDLINE_API_BASE", "https://systems.trendlinelabs.ai")
KEY = os.environ["TRENDLINE_API_KEY"]

r = requests.get(f"{BASE}/public/v1/events/ev-btc-100k-2026", params={},
                 headers={"Authorization": f"Bearer {KEY}"}, timeout=10)
r.raise_for_status()
print(r.json())
```

```javascript JavaScript theme={null}
// getEvent: Get one event with its markets. Needs TRENDLINE_API_KEY; TRENDLINE_API_BASE overrides the base.
const BASE = process.env.TRENDLINE_API_BASE ?? "https://systems.trendlinelabs.ai";
const KEY = process.env.TRENDLINE_API_KEY;
const r = await fetch(`${BASE}/public/v1/events/ev-btc-100k-2026`, { headers: { Authorization: `Bearer ${KEY}` } });
console.log(r.status, await r.json());
```

```json Response theme={null}
{
  "universal_id": "ev-btc-100k-2026",
  "title": "Bitcoin price at year end",
  "category_group": "crypto",
  "categories": [
    "crypto",
    "bitcoin"
  ],
  "status": "active",
  "is_live": false,
  "first_seen_at": "2026-09-01T12:00:00.000Z",
  "last_seen_at": "2026-10-06T05:59:30.000Z",
  "resolution_date": "2026-12-31T23:59:59.000Z",
  "image_url": null,
  "total_volume_usd": 1834201.5,
  "liquidity_usd": 412000.0,
  "platform_count": 2,
  "source_lanes": [
    "kalshi",
    "polymarket"
  ],
  "kalshi_event_ticker": "KXBTC-26DEC31",
  "poly_event_slug": "bitcoin-above-100k-on-december-31",
  "limitless_event_id": null,
  "predictfun_event_id": null,
  "markets": [
    {
      "universal_id": "mk-btc-100k-2026",
      "title": "Bitcoin above $100k on December 31?",
      "status": "active",
      "yes_subject": "Bitcoin above $100k",
      "deadline_at": "2026-12-31T23:59:59.000Z",
      "kalshi_market_ticker": "KXBTC-26DEC31-B100000",
      "poly_market_slug": "bitcoin-above-100k-on-december-31",
      "limitless_market_id": null,
      "predictfun_market_id": null,
      "volume_usd": 1834201.5,
      "volume_24h_usd": 50211.0,
      "volume_by_platform": {
        "kalshi": 734201.5,
        "polymarket": 1100000.0
      },
      "volume_24h_by_platform": {
        "kalshi": 20211.0,
        "polymarket": 30000.0
      },
      "price_24h_change_by_platform": {
        "kalshi": 0.02,
        "polymarket": 0.01
      },
      "source_lanes": [
        "kalshi",
        "polymarket"
      ],
      "venue_details": {
        "kalshi": {
          "rules_primary": "Resolves YES if the reference price is above $100,000 at the close.",
          "rules_secondary": null,
          "open_time": "2026-09-01T12:00:00Z",
          "close_time": "2026-12-31T23:59:59Z",
          "yes_sub_title": "Above $100,000",
          "liquidity_raw": 152000.0,
          "volume_24h": 20211.0,
          "url": "https://kalshi.com/markets/kxbtc"
        },
        "polymarket": {
          "description": "Resolves YES if Bitcoin trades above $100,000 on December 31.",
          "resolution_source": "https://example.com/btc-index",
          "start_date": "2026-09-01T12:00:00Z",
          "end_date": "2026-12-31T23:59:59Z",
          "best_bid": 0.44,
          "liquidity": 260000.0,
          "volume_24h": 30000.0,
          "url": "https://polymarket.com/event/bitcoin-above-100k-on-december-31"
        },
        "limitless": null,
        "predictfun": null
      }
    }
  ]
}
```

### getOrderbook

```bash cURL theme={null}
#!/bin/sh
# getOrderbook: Get a market's order book on one venue. Needs TRENDLINE_API_KEY; TRENDLINE_API_BASE overrides the base.
curl -sS "${TRENDLINE_API_BASE:-https://systems.trendlinelabs.ai}/public/v1/markets/mk-btc-100k-2026/orderbook?venue=kalshi&depth=2" \
  -H "Authorization: Bearer $TRENDLINE_API_KEY"
```

```python Python theme={null}
"""getOrderbook: Get a market's order book on one venue. Needs TRENDLINE_API_KEY; TRENDLINE_API_BASE overrides the base."""
import os

import requests

BASE = os.environ.get("TRENDLINE_API_BASE", "https://systems.trendlinelabs.ai")
KEY = os.environ["TRENDLINE_API_KEY"]

r = requests.get(f"{BASE}/public/v1/markets/mk-btc-100k-2026/orderbook", params={"venue": "kalshi", "depth": "2"},
                 headers={"Authorization": f"Bearer {KEY}"}, timeout=10)
r.raise_for_status()
print(r.json())
```

```javascript JavaScript theme={null}
// getOrderbook: Get a market's order book on one venue. Needs TRENDLINE_API_KEY; TRENDLINE_API_BASE overrides the base.
const BASE = process.env.TRENDLINE_API_BASE ?? "https://systems.trendlinelabs.ai";
const KEY = process.env.TRENDLINE_API_KEY;
const r = await fetch(`${BASE}/public/v1/markets/mk-btc-100k-2026/orderbook?venue=kalshi&depth=2`, { headers: { Authorization: `Bearer ${KEY}` } });
console.log(r.status, await r.json());
```

```json Response theme={null}
{
  "universal_id": "mk-btc-100k-2026",
  "venue": "kalshi",
  "venue_market_id": "KXBTC-26DEC31-B100000",
  "yes": {
    "bids": [
      {
        "price": 0.4,
        "size": 150
      },
      {
        "price": 0.39,
        "size": 400
      }
    ],
    "asks": [
      {
        "price": 0.41,
        "size": 310
      },
      {
        "price": 0.42,
        "size": 90
      }
    ]
  },
  "no": {
    "bids": [
      {
        "price": 0.59,
        "size": 310
      }
    ],
    "asks": [
      {
        "price": 0.6,
        "size": 150
      }
    ]
  },
  "no_source": "book",
  "ts_ms": 1791266398500,
  "age_ms": 1500,
  "max_age_s": 1200,
  "as_of_ms": 1791266400000
}
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.