BazaarLinkBazaarLink
Sign in
DocsAPI ReferenceSDK ReferenceAgentic UsageAI Skills
Account

Get usage insights

Returns everything the /insights page needs in one round-trip: trend series for all 3 metrics (tokens/spend/requests), top 3 models per metric, prompt-cache hit stats, token breakdown, a year heatmap (with streak), credit/free-model usage, and filter-panel options. Cached for 5 minutes per (user, period, heatmap_metric, filters) combination.

GET/api/v1/insights

Authorizations

Authorizationrequired
string · header

API key as bearer token in the Authorization header.

Query parameters

period
string

Drives the whole page's time window, defaults to 7d. An unrecognized value returns 400.

7d30dytdall
Example: "30d"
heatmap_metric
string

Which metric the year heatmap displays (the heatmap is always a full calendar year, independent of period), defaults to spend. An unrecognized value returns 400.

spendtokensrequests
Example: "tokens"
model
string

Page-wide filter — only count usage for this model. Omitted means unfiltered.

api_key_id
string

Page-wide filter — only count usage for this API key. Omitted means unfiltered.

app
string

Page-wide filter — only count usage tagged with this app name (x-title / HTTP-Referer). Omitted means unfiltered.

GET /api/v1/insights
curl "https://bazaarlink.ai/api/v1/insights?period=30d&heatmap_metric=tokens" \
  -H "Authorization: Bearer $BAZAARLINK_API_KEY"
Response examples

Success. trend/topModels/heatmap always return the full data for all three metrics (tokens, spend, requests) so the frontend toggle needs no refetch; caching and breakdown are bucketed by period (daily ≤120 days, weekly ≤730 days, otherwise monthly). The example below is truncated — the real buckets/heatmap.days arrays hold many entries depending on the period length.

{
  "period": "30d",
  "bucketUnit": "day",
  "trend": {
    "tokens": {
      "total": 152000,
      "prevTotal": 98000,
      "changePct": 55.1,
      "buckets": [
        {
          "date": "2026-07-01",
          "segs": [
            {
              "model": "openai/gpt-4.1",
              "value": 5200
            }
          ]
        }
      ]
    },
    "spend": {
      "total": 4.82,
      "prevTotal": 3.1,
      "changePct": 55.5,
      "buckets": [
        {
          "date": "2026-07-01",
          "segs": [
            {
              "model": "openai/gpt-4.1",
              "value": 0.16
            }
          ]
        }
      ]
    },
    "requests": {
      "total": 340,
      "prevTotal": 210,
      "changePct": 61.9,
      "buckets": [
        {
          "date": "2026-07-01",
          "segs": [
            {
              "model": "openai/gpt-4.1",
              "value": 12
            }
          ]
        }
      ]
    }
  },
  "topModels": {
    "tokens": [
      {
        "model": "openai/gpt-4.1",
        "provider": "openai",
        "value": 152000,
        "unit": "tokens"
      }
    ],
    "spend": [
      {
        "model": "openai/gpt-4.1",
        "provider": "openai",
        "value": 4.82,
        "unit": "spend"
      }
    ],
    "requests": [
      {
        "model": "openai/gpt-4.1",
        "provider": "openai",
        "value": 340,
        "unit": "requests"
      }
    ]
  },
  "caching": {
    "buckets": [
      {
        "date": "2026-07-01",
        "hit": 3200,
        "write": 800
      }
    ],
    "totalHit": 96000,
    "totalWrite": 24000
  },
  "breakdown": {
    "buckets": [
      {
        "date": "2026-07-01",
        "prompt": 4000,
        "completion": 1200,
        "reasoning": 0,
        "cached": 3200
      }
    ],
    "totals": {
      "prompt": 120000,
      "completion": 32000,
      "reasoning": 0,
      "cached": 96000
    }
  },
  "heatmap": {
    "spend": {
      "days": [
        {
          "date": "2026-01-01",
          "value": 0.02
        }
      ],
      "streak": {
        "current": 5,
        "longest": 21
      },
      "avgDay": 0.16,
      "avgWeek": 1.12,
      "total": 58.4
    },
    "tokens": {
      "days": [
        {
          "date": "2026-01-01",
          "value": 640
        }
      ],
      "streak": {
        "current": 5,
        "longest": 21
      },
      "avgDay": 5066,
      "avgWeek": 35462,
      "total": 1850000
    },
    "requests": {
      "days": [
        {
          "date": "2026-01-01",
          "value": 4
        }
      ],
      "streak": {
        "current": 5,
        "longest": 21
      },
      "avgDay": 11.3,
      "avgWeek": 79,
      "total": 4130
    }
  },
  "credit": {
    "today": 0.16,
    "thisWeek": 1.12,
    "thisMonth": 4.82
  },
  "freeModel": {
    "today": 0,
    "thisWeek": 0,
    "thisMonth": 0
  },
  "facets": {
    "models": [
      "openai/gpt-4.1"
    ],
    "apiKeys": [
      {
        "id": "key_abc123",
        "name": "default"
      }
    ],
    "apps": [
      "my-app"
    ]
  }
}
Support
Support
Hi! How can we help you?
Send a message and we'll get back to you soon.
Get usage insights — BazaarLink API