Skip to content
Start free

API examples

Call the GetIntel API from curl, JavaScript and Python, and export your topic scores to a CSV file every day.

Terminal window
curl "https://app.getintel.ai/api/v1/topics?days=30" \
-H "Authorization: Bearer $GETINTEL_API_KEY"
const api = (path) =>
fetch(`https://app.getintel.ai/api/v1/${path}`, {
headers: { Authorization: `Bearer ${process.env.GETINTEL_API_KEY}` },
}).then((r) => r.json())
const { data: brands } = await api('brands')
for (const brand of brands) {
const { data } = await api(`overview?brand_id=${brand.id}&days=7`)
console.log(brand.name, data.visibility)
}

Run this once a day (for example from cron after 10am IST, once the daily scan has finished) to keep a history in your own storage:

import csv, datetime, os
import requests
res = requests.get(
"https://app.getintel.ai/api/v1/topics",
params={"days": 1},
headers={"Authorization": f"Bearer {os.environ['GETINTEL_API_KEY']}"},
timeout=30,
)
res.raise_for_status()
today = datetime.date.today().isoformat()
with open("topic_scores.csv", "a", newline="") as f:
writer = csv.writer(f)
for topic in res.json()["data"]["topics"]:
writer.writerow([today, topic["name"], topic["visibility"]])

Check the error code, and back off on 429:

async function getintel(path, tries = 3) {
const res = await fetch(`https://app.getintel.ai/api/v1/${path}`, {
headers: { Authorization: `Bearer ${process.env.GETINTEL_API_KEY}` },
})
if (res.status === 429 && tries > 0) {
const body = await res.json()
if (body.error.code === 'quota_exceeded') throw new Error(body.error.message) // wait for next month
const wait = Number(res.headers.get('Retry-After') || 30)
await new Promise((r) => setTimeout(r, wait * 1000))
return getintel(path, tries - 1)
}
return res.json()
}