News API for agents

Kokoah’s live news for your own agents and scripts: a key, three endpoints, filters, limits and examples.

What it gives you

The News API gives your own agents and scripts Kokoah’s live news stream as JSON: the same cards as the News column. Order flow from Hyperliquid (big trades and orders, TWAPs, liquidation waves, sharp moves, open interest and funding), Hyperliquid’s announcements, and headlines, listings, macro news and the calendar, each with its importance, coins and sources.

There are three endpoints: the newest cards, the searchable history, and a live stream of new and updated cards. All three take the same filters, applied on Kokoah’s servers, so your agent only gets what it asked for.

For market data (liquidation maps, order flow, whale moves, wallet records) and the MCP server for AI assistants, see the Intelligence API and MCP server.

The cards are information, not advice. Order flow comes from Hyperliquid’s own data; headlines are summaries that can be wrong. Check before your agent trades on them.

Get a key

  1. Sign in and open Settings → News API.
  2. Type a name that says what the key is for, then choose Create key.
  3. Copy the key (it starts with kk_) and keep it somewhere safe. Kokoah shows it only once and stores only a fingerprint of it, never the key itself.

An account can hold up to 5 active keys. The list shows each key’s name, its first characters, when it was created and when it was last used. Revoke a key there: requests with it stop working within a minute, and its open streams end within about a minute and a half. A linked phone can list and revoke keys, but not create them.

Treat a key like a password. Keep it on your server or computer, never in a web page, a shared app or a public code repository. If a key leaks, revoke it and create a new one.

Send your key

Send the key with every request in the Authorization header, as Bearer kk_…. An X-API-Key header with the key works too. Every path starts at https://api.kokoah.com.

The API is for servers and scripts: web pages on other sites can’t call it. Errors are JSON with a code and a message:

400
A parameter is wrong (invalid_request): an unknown kind, something that isn’t a coin name, more than 20 coins or a value out of range. Fix the request: sending it again won’t help.
401
No key (api_key_required), or a key that is wrong or was revoked (invalid_api_key).
429
Too many requests or streams for this key. Wait as many seconds as the Retry-After header says.
503
The News API is paused for now (news_api_disabled), or a search took too long (search_timeout). Try again later.

The three endpoints

GET /v1/agent/news/live
The newest cards, newest first, as { items }. limit: 1 to 100 (50 if you leave it out). With a filter, only cards first seen in the last 24 hours (the history has older ones). When you ask for news and order flow together, order flow fills at most half the list, so a busy market never pushes the headlines out.
GET /v1/agent/news/history
Older cards, newest first, a page at a time, as { items, next }. q: words every card must hold (up to 100 characters). before: read from this time back (in ms), the previous page’s next; next is null on the last page. limit: 1 to 100 (50).
GET /v1/agent/news/stream
A live stream of server-sent events: a card event for each new or updated card, and a heartbeat event every 25 seconds.

Each card has these fields:

id
Stable: when a card changes, it comes again with the same id. Replace the one you have.
kind
Order flow: bigTrade, bigOrder, twap, liquidations, move, oiFunding, oracleGap, marketMove, flowRoundup. Hyperliquid’s announcements: hyperliquid. News: listing, delisting, macro, calendar, headline.
coins
The Hyperliquid coins it is about (empty for broad macro news).
importance
1, 2 or 3. 3 is rare: news worth everyone’s attention at once.
confirmed
Always true for order flow. A headline is confirmed once a second independent source or an official one reports it.
at · firstSeenAt · updatedAt
When it happened, when Kokoah first saw it (the order of every list) and when it last changed, in milliseconds since 1 January 1970 UTC.
text
Kokoah’s own one or two sentences in English for news and Hyperliquid’s announcements. Null for order flow, whose facts are in data, and for a post on X that Kokoah hasn’t summarized yet: open its link.
data
The facts of an order-flow card: the coin, side, size, price and more, by kind. Fields ending in Usd are whole dollars, those ending in Pct are percents (1.25 means 1.25%).
sources
Where it comes from: name and url, and for a post on X the account’s handle and the post’s postId.
state
live while the card follows something still going on (a large order, a TWAP, a liquidation wave), then ended.
Cards carry Kokoah’s own summary and a link to each source, never a post’s own text or pictures. To read a post on X, open the original on X.

The stream and resuming

Each card event has an id: its change number. When a connection drops, connect again with the last id you got in a Last-Event-ID header: you get the newest 200 changes you missed that pass your filter (from about the last day of changes). Without it, the stream starts with the last minute’s changes.

EventSource clients send the last id on their own. Expect a heartbeat at least every 25 seconds, and connect again when nothing comes for a minute. A stream also ends when its key is revoked.

Filters

All three endpoints take the same filters. A card must pass every one you give; on the stream they apply to live cards and to what a reconnect sends.

minImportance
1 to 3: only cards of at least this importance, order flow included.
kinds
Kinds separated by commas, for example kinds=headline,listing,liquidations.
coins
Up to 20 coin names separated by commas, exactly as Hyperliquid writes them (BTC, kPEPE, xyz:TSLA): cards about at least one of them. Broad macro news has no coins, so a coin filter leaves it out.

Limits and fair use

  • 120 requests a minute per key. A stream counts once, when it opens.
  • 3 open streams per key, 5 per account and 30 per network (one IP address).
  • 30 history searches or coin filters a minute per account, all its keys together.
  • 5 active keys per account.

Use the stream for live news rather than asking for the newest cards again and again. After a 429, wait as long as Retry-After says. Kokoah can pause the News API for everyone while it protects the service (503).

Examples

Each example reads important news (importance 2 or 3) about BTC and ETH, with your key in the KOKOAH_KEY environment variable. The Python and Node.js ones follow the stream, connect again after a drop and resume where they left off.

curl
curl -H "Authorization: Bearer $KOKOAH_KEY" \
  "https://api.kokoah.com/v1/agent/news/live?minImportance=2&coins=BTC,ETH"

curl -N -H "Authorization: Bearer $KOKOAH_KEY" \
  "https://api.kokoah.com/v1/agent/news/stream?minImportance=2&coins=BTC,ETH"
Python (requests)
import json, os, time
import requests

URL = "https://api.kokoah.com/v1/agent/news/stream"
PARAMS = {"minImportance": 2, "coins": "BTC,ETH"}
KEY = os.environ["KOKOAH_KEY"]
last_id = None

while True:
    headers = {"Authorization": "Bearer " + KEY}
    if last_id:
        headers["Last-Event-ID"] = last_id
    try:
        with requests.get(URL, headers=headers, params=PARAMS, stream=True, timeout=(10, 60)) as r:
            if r.status_code in (400, 401):
                raise SystemExit(r.json()["error"]["message"])
            if r.status_code != 200:
                time.sleep(int(r.headers.get("Retry-After", "5")))
                continue
            event, data = None, []
            for line in r.iter_lines(decode_unicode=True):
                if line.startswith("id:"):
                    last_id = line[3:].strip()
                elif line.startswith("event:"):
                    event = line[6:].strip()
                elif line.startswith("data:"):
                    data.append(line[5:].strip())
                elif line == "":
                    if event == "card":
                        card = json.loads("\n".join(data))
                        print(card["importance"], card["kind"], card["coins"], card["text"] or card["data"])
                    event, data = None, []
    except requests.RequestException:
        pass
    time.sleep(5)
Node.js 20+ (news.mjs)
const URL = "https://api.kokoah.com/v1/agent/news/stream?minImportance=2&coins=BTC,ETH";
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
let lastId;

for (;;) {
  const silent = new AbortController();
  let timer = setTimeout(() => silent.abort(), 60_000);
  try {
    const res = await fetch(URL, {
      headers: { Authorization: `Bearer ${process.env.KOKOAH_KEY}`, ...(lastId ? { "Last-Event-ID": lastId } : {}) },
      signal: silent.signal,
    });
    if (res.status === 400 || res.status === 401) throw new Error((await res.json()).error.message, { cause: "key" });
    if (!res.ok) {
      await sleep(1000 * Number(res.headers.get("retry-after") ?? 5));
      continue;
    }
    const decoder = new TextDecoder();
    let buffer = "";
    for await (const chunk of res.body) {
      clearTimeout(timer);
      timer = setTimeout(() => silent.abort(), 60_000);
      buffer += decoder.decode(chunk, { stream: true });
      let end;
      while ((end = buffer.indexOf("\n\n")) >= 0) {
        const event = {};
        for (const line of buffer.slice(0, end).split("\n")) {
          const colon = line.indexOf(":");
          if (colon > 0) event[line.slice(0, colon)] = line.slice(colon + 1).trim();
        }
        buffer = buffer.slice(end + 2);
        if (event.id) lastId = event.id;
        if (event.event === "card") {
          const card = JSON.parse(event.data);
          console.log(card.importance, card.kind, card.coins, card.text ?? card.data);
        }
      }
    }
  } catch (err) {
    if (err.cause === "key") throw err;
  } finally {
    clearTimeout(timer);
  }
  await sleep(5000);
}