Examples
Copy-paste starter snippets for the three most common stacks. All examples call
GET /public/news?symbol=AAPL&minImpact=0.5 — swap the query string as needed.
curl
bash
curl -H "Authorization: Bearer ak_live_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" \
"http://localhost:3003/public/news?symbol=AAPL&minImpact=0.5"JavaScript (fetch)
Works in Node 18+ and modern browsers. Keep the key on a server — never embed it in frontend code.
javascript
const res = await fetch(
'http://localhost:3003/public/news?symbol=AAPL&minImpact=0.5',
{
headers: {
Authorization: `Bearer ${process.env.QUANTSTREAM_API_KEY}`,
},
},
);
if (!res.ok) {
throw new Error(`QuantStream ${res.status}: ${await res.text()}`);
}
const articles = await res.json();
console.log(`Got ${articles.length} articles`);Python (requests)
python
import os
import requests
res = requests.get(
"http://localhost:3003/public/news",
params={"symbol": "AAPL", "minImpact": 0.5},
headers={"Authorization": f"Bearer {os.environ['QUANTSTREAM_API_KEY']}"},
timeout=10,
)
res.raise_for_status()
for article in res.json():
print(article["publishedAt"], article["sentiment"], article["title"])Common pitfalls
- Don't ship keys to browsers. If you need to display news in a web UI, proxy through your own server so the key stays on the backend.
- Handle
429withRetry-After. Don't hammer the endpoint — back off for the number of seconds the header tells you. analysiscan benull. Freshly-ingested articles haven't been processed by the LLM yet. Filter or retry.- Respect the 7-day window.
/public/newsonly serves the last 7 days; older ids return404.