Tree News API
The live feed over a WebSocket and the archive over HTTP. Both answer without an account. A key adds what your plan includes.
Access and keys
No key is needed for the public feed. Your key is on your Account page and carries your plan.
| No key | With your key | |
|---|---|---|
| Exchange announcements | Live | Live |
| X and Truth Social posts | Live | Live |
| Blogs and US government pages | 5 seconds late | Live on any plan |
| Headlines (the wires) | Economic data releases only | On a plan |
| Cases, Filings, Onchain, Scrapers | No | On a plan |
| Importance floor and scores | No | On a plan, or with 10,000 TREE held |
| History | Public sources | The sources of your plan |
Plans lists what each plan includes.
- HTTP: send the key in the
tree-api-keyheader. - WebSocket: send
login YOUR_API_KEYas a text message once connected.
Live feed
Open wss://tree.news/ws. Items start arriving at once: there is nothing to subscribe to. Every message is a text frame holding one JSON object, except the answer to ping.
const ws = new WebSocket("wss://tree.news/ws");
ws.onopen = () => {
ws.send("login YOUR_API_KEY"); // leave out for the public feed
};
ws.onmessage = (event) => {
if (event.data === "pong") return;
const message = JSON.parse(event.data);
if (!message._id) return; // an answer to a command, not an item
console.log(message.time, message.source || message.type, message.title);
};
ws.onclose = () => {
// reconnect here, after a short wait that grows
};import asyncio, json import websockets # pip install websockets async def main(): async for ws in websockets.connect("wss://tree.news/ws"): # reconnects by itself try: await ws.send("login YOUR_API_KEY") # leave out for the public feed async for raw in ws: if raw == "pong": continue message = json.loads(raw) if "_id" not in message: # an answer to a command, not an item continue print(message["time"], message.get("source") or message.get("type"), message["title"]) except websockets.ConnectionClosed: continue asyncio.run(main())
After login the socket answers {"time": ..., "user": {...}}, or {"time": ..., "success": false} for a key that is not valid. Nothing is sent while the login is being checked. What was published meanwhile follows in order.
Messages
An item always has _id and time. It comes in one of two shapes.
A news item has source, title and url: an exchange announcement, a blog article, a headline.
{
"_id": "1796303249805WBPtTLoMCSF",
"time": 1796303249805,
"source": "Blogs",
"sourceName": "WSJ",
"title": "WSJ: Bitcoin Plunges to Two-Year Low on Mounting Cryptography Security Fears",
"en": "WSJ: Bitcoin Plunges to Two-Year Low on Mounting Cryptography Security Fears",
"url": "https://www.wsj.com/finance/investing/bitcoin-sinks-below-56-000-as-cryptography-fears-grow-678bbc1c",
"symbols": [],
"suggestions": [
{"coin": "BTC", "found": ["Bitcoin"], "supply": 20119925, "symbols": [
{"exchange": "binance-futures", "symbol": "BTCUSDT"},
{"exchange": "binance", "symbol": "BTCUSDT"},
{"exchange": "bybit-perps", "symbol": "BTCUSDT"}]}
],
"stockSuggestions": [{"ticker": "IBIT", "found": ["bitcoin"]}],
"delay": 5000,
"show_feed": true,
"show_notif": true
}A post has "type": "direct": the account in title, the text in body, the post in link. Its _id is the post's own number. The post below also named ETH, USDC, ARB and CRV: they are left out here.
{
"_id": "2128475404679712979",
"time": 1796303056692,
"type": "direct",
"title": "1inch (@1inch)",
"body": "What are intent-based swaps? Intent-based swaps let you state the trade you want, then let independent resolvers ...",
"link": "https://x.com/1inch/status/2128475404679712979#",
"icon": "https://pbs.twimg.com/profile_images/2008094233266376705/gypmfWbU_400x400.jpg",
"image": "https://pbs.twimg.com/media/HYdzUdiWwAANagY.jpg",
"info": {"twitterId": "1137038394503114753", "isReply": false, "isRetweet": false, "isQuote": false, "truthId": null, "isSelfReply": false},
"coin": "1INCH",
"suggestions": [
{"coin": "1INCH", "found": ["1INCH", "1inch"], "supply": 1500000000, "symbols": [
{"exchange": "binance-futures", "symbol": "1INCHUSDT"},
{"exchange": "binance", "symbol": "1INCHUSDT"},
{"exchange": "bybit-perps", "symbol": "1INCHUSDT"}]}
],
"stockSuggestions": [],
"show_feed": true,
"show_notif": true
}Every field is in Item fields. Anything without _id is an answer to a command, a score follow-up or a heartbeat.
Commands
Commands are plain text messages you send. Each one is answered at once.
| Send | Answer | |
|---|---|---|
login KEY | {"time", "user"} | Your plan on this socket. |
ping | pong | Plain text, not JSON. |
user | {"time", "user"} | The name you are logged in as, or Not Logged In. |
heartbeat on | {"time", "heartbeat", "every", "seq"} | Then {"type": "heartbeat", "time", "seq"} every 5 seconds. heartbeat off stops it. |
min 7 | {"time", "filter": {"min"}} | Only items scored 7 or more. min off removes it, min asks. |
scores on | {"time", "scores"} | The score of each item, sent after it. scores off stops it. |
The same options work in the address, so they hold from the first message: wss://tree.news/ws?heartbeat=on&min=7.
Importance floor and scores
Each item is scored from 1 to 10 for how much it matters to traders. The floor and the scores come with a plan, or with 10,000 TREE held. Without either the answer carries a note saying so and the feed stays as it was.
- No floor: an item is sent the moment it is published, before it is scored.
minfrom 5 to 10: an item is sent once scored, about 0.3 seconds later, withimportancein it, and only at or above the floor. An item that tells again one you already received is skipped.scores onwithout a floor: items arrive at once, and each is followed by{"id", "importance"}. A repeat also carries"old": trueand"repeatOf", the_idof the earlier item.
{"id": "1796283087508SSIGPLoMbM2", "importance": 5.8}
{"id": "1796302675196TBcb5htlaAcfscm", "importance": 5.1, "old": true, "repeatOf": "2128164797464158537", "mainStock": "IBIT"}Staying connected
- The server pings every socket. A client that answers pings, as every WebSocket library does, stays open.
- Sockets close when we restart. Reconnect after a short wait that grows with each failed try.
- Ask for the heartbeat. No heartbeat for 15 seconds means the stream has stalled: close and reconnect.
seqin the heartbeat counts the items and score follow-ups pushed to your socket so far. If your own count is lower, you missed some.- After a reconnect,
GET /api/news?limit=100returns the latest items so you can fill the gap by_id.
History
GET https://tree.news/api/history answers a JSON array of items, newest first. It holds every item of the public feed since July 2020. An item appears here about a minute after it is published.
| Parameter | |
|---|---|
limit | How many items. 5,000 at most, and 5,000 when left out. |
before | Only items published before this time, in milliseconds. |
after | Only items published after this time, in milliseconds. |
coin | Only items tagged with this coin: coin=BTC. |
source | Only this source, any case: source=blogs. |
query | Text that the headline or the link contains, any case. |
match | Like query, and it can be given up to 12 times: every one must be found. match=etf|fund finds either word. |
not | Words that must not be found. Can be repeated. |
minImportance | Scored at least this, and not a repeat of an earlier item. |
minMove | A tagged coin moved at least this many percent, up or down, within the hour after. Items younger than an hour never match. |
sort | time for oldest first, -move for the biggest movers first, -importance for the highest scores first. |
# the 20 latest items about ETH curl "https://tree.news/api/history?coin=ETH&limit=20" # Binance announcements that say "will list", with your plan's sources curl -H "tree-api-key: YOUR_API_KEY" "https://tree.news/api/history?source=binance%20en&match=will%20list&limit=50" # everything published on 21 November 2024 (UTC), oldest first curl "https://tree.news/api/history?after=1732147199999&before=1732233600000&sort=time"
Paging
An answer stops at limit. For the next page, pass before with the time of the last item you received, and repeat until the answer is empty.
let before = Date.now(), all = [];
while (true) {
const answer = await fetch("https://tree.news/api/history?coin=SOL&limit=1000&before=" + before);
const page = await answer.json();
if (!page.length) break;
all.push(...page);
before = page[page.length - 1].time;
}To walk the archive forward, take it one window at a time with after and before together, a day or a week each.
One item, and the latest items
| Request | |
|---|---|
GET /api/news?id=ID | One item by its _id, from any year. |
GET /api/news?limit=100 | The latest items, 10 seconds behind the live feed. |
curl "https://tree.news/api/news?id=1732193907594BUNLPwBC"
Times, for backtests
timeis the millisecond we published the item, in UTC. The live feed sent it then. The HTTP routes show it from 10 seconds later.- There is one
timeper item. A later telling of the same story is a new item with its owntime. - Known at
time:title,source,url, the coin tags andfirstPrice. - Added within about a second:
importance,old,repeatOf. Added afterwards:kind. A blog's coin tags can be trimmed after it is published. - Added about an hour later:
impactandreaction. They describe what the price did after the item, so keep them out of anything that decides attime. - Items carry a score from late September 2026 on.
Item fields
| Field | |
|---|---|
_id | The item's id, a string. For a news item it starts with the millisecond it was published. For an X post it is the post's number. |
time | When we published it, in milliseconds since 1970, UTC. |
source | Where it came from. See Sources. |
sourceName | The outlet or project behind a blog item. |
title | The headline. For a post in the history: the account, then the text. |
en | The headline in English when it was published in another language. Otherwise the same as title, or null. |
url | The original article, announcement or post. |
suggestions | The coins it is about. Each has coin, found (the words that matched), symbols (the pairs, each with exchange and symbol) and supply. |
stockSuggestions | The stocks it is about, each with ticker. |
firstPrice | The Binance price of each tagged coin when the item was published: {"BTCUSDT": 52747.4}. |
importance | The score, 1 to 10. null when it could not be scored. |
old, repeatOf | old is true when the item tells again an earlier one. repeatOf is that item's _id. |
kind, venue | What kind of story it is: listing, delisting, launch, hack, etf, macro, policy, earnings, opinion and more. venue is the exchange of a listing or delisting. |
traders | Who it matters to: crypto, stocks, both or neither. |
mainStock | The stock it moves most, when there is one. |
impact | The move in the hour after: coin, symbol, pct (the larger of the two swings), up, down, peakAt. |
reaction | The first coin's minute-by-minute price around the item, as the site charts it. |
big | True for a Big story, picked by the news desk. |
icon, image, info | On posts: the account's picture, the post's first image, and info with twitterId, isReply, isRetweet, isQuote, isSelfReply. A Truth Social post has truthId. A quote has quotedUser. |
On the live feed only:
| Field | |
|---|---|
type, body, link | A post: "type": "direct", its text, its address. The account is in title. |
coin, video | On a post: the first coin it is about, and its video when it has one. |
delay | How long the item was held for a socket without a plan, in milliseconds. |
show_feed, show_notif | Whether your Settings show this source in the feed and alert on it. Both true without a login. |
Sources
The value of source on an item, and what source= takes in the history.
| Source | Needs | |
|---|---|---|
Binance EN Upbit Bithumb Exchanges | Exchange announcements. Exchanges covers the other exchanges. | Nothing |
Twitter Truth Social | Posts of the accounts Tree News follows for everyone. | Nothing |
Blogs | News outlets, project blogs and press releases. | Nothing |
usGov | US government pages. | Nothing |
Terminal | Headlines: the wires. | A plan |
Cases Filings | US court cases and SEC filings that carry news. | A plan |
Onchain Scrapers | Suspected thefts read off the chains, and Tree News' own scrapers. | A plan |
Headlines+, the second and larger wire feed, comes with Sapling or a Tree NFT.
Limits
| Live connections from one address | 5 without a plan, 7 with one. One more is refused when it connects. |
| Messages you send on a socket | 200 a minute. Past that they are not read. Far past that the socket is closed. |
| Size of a message you send | 16 KB. |
| A socket that does not read | Closed once it is 2 MB behind for 15 seconds. |
/api/news | 30 requests a minute from one address. |
/api/history | 5,000 items an answer. |
For new items, listen on the socket. Polling the history is slower and shows each item later.
Questions go to the Tree Discord.
