Use the API to automate AI visibility reports
const API_KEY = process.env.GEOARK_API_KEY; const BASE = 'https://api.yourdomain.com/api/customer/v1'; async function getWeeklyBrandsReport() { const end = new Date(); const start = new Date(); start.setDate(start.getDate() - 7); const res = await fetch(`${BASE}/reports/brands`, { method: 'POST', headers: { 'X-API-Key': API_KEY, 'Content-Type': 'application/json', }, body: JSON.stringify({ start_date: start.toISOString().slice(0, 10), end_date: end.toISOString().slice(0, 10), }), }); const { data } = await res.json(); return data; }
import os import requests from datetime import datetime, timedelta API_KEY = os.environ["GEOARK_API_KEY"] BASE = "https://api.yourdomain.com/api/customer/v1" def get_weekly_brands_report(): end = datetime.now() start = end - timedelta(days=7) r = requests.post( f"{BASE}/reports/brands", headers={"X-API-Key": API_KEY, "Content-Type": "application/json"}, json={ "start_date": start.strftime("%Y-%m-%d"), "end_date": end.strftime("%Y-%m-%d"), }, ) return r.json()["data"]
0 9 * * 1 /path/to/weekly-report-script.sh