Skip to content

Usage API ​

Endpoints for tenant‑level usage and quota tracking.

Overview ​

The Usage API returns a lightweight monthly roll‑up of operations and storage for the authenticated tenant. Use this for dashboards, billing checks, and monitoring quotas.

Usage API Flow

Monthly rollups, recent activity, and quota status

Get Usage Summary ​

Retrieve recent monthly usage plus current quota state.

http
GET /api/usage

Query Parameters ​

ParameterTypeDefaultDescription
limitinteger12Number of recent months to return (max: 24)

Request ​

bash
curl -X GET "https://gobananasai.com/api/usage?limit=6" \
  -H "X-API-Key: sk_live_xxx"

Response ​

json
{
  "data": {
    "months": [
      {
        "month": "2024-01",
        "total_operations": 1523,
        "total_images": 2891,
        "total_bytes": 3019898880,
        "total_mb": 2880,
        "avg_duration_ms": 3421
      },
      {
        "month": "2023-12",
        "total_operations": 1245,
        "total_images": 2156,
        "total_bytes": 2454857216,
        "total_mb": 2340,
        "avg_duration_ms": 3605
      }
    ],
    "recent": {
      "bytes": 93323264,
      "images": 89
    },
    "quota": {
      "monthlyQuotaMb": 10240,
      "monthlyUsedMb": 2880,
      "monthlyRemainingMb": 7360,
      "rateLimitPerMinute": 60
    }
  }
}

Notes ​

  • months are ordered newest‑first and use snake_case fields from the monthly view.
  • recent is a rolling 30‑day aggregate.
  • Quotas are returned in the same shape as /api/profile.

Error Responses ​

400 Invalid Limit ​

json
{ "error": "Invalid limit" }

401 Unauthorized ​

json
{ "error": "Invalid or missing API key" }

Next Steps ​

Released under the MIT License.