Skip to main content

Automate weekly reports

Use the Customer API to pull visibility data into weekly reports, spreadsheets, or email summaries. You only need an API key (Custom plan).

Example: Weekly Brands Report (Node.js)

const API_KEY = process.env.GEOARK_API_KEY;
const BASE = 'https://api.geoark.ai/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;
}

Example: Python

import os
import requests
from datetime import datetime, timedelta

API_KEY = os.environ["GEOARK_API_KEY"]
BASE = "https://api.geoark.ai/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"]

Cron / scheduler

Run this weekly via cron, GitHub Actions, or your scheduler:
0 9 * * 1 /path/to/weekly-report-script.sh