Skip to main content

Overview

Grantex tracks API usage in real-time using Redis counters with periodic PostgreSQL rollup. Monitor token exchanges, authorizations, and verifications per developer.

Enabling Usage Metering

Set the environment variable:
USAGE_METERING_ENABLED=true

API Endpoints

Current Period Usage

curl https://api.grantex.dev/v1/usage \
  -H "Authorization: Bearer $GRANTEX_KEY"
Response:
{
  "developerId": "dev_...",
  "period": "2026-03-02",
  "tokenExchanges": 42,
  "authorizations": 18,
  "verifications": 7,
  "totalRequests": 67
}

Usage History

curl "https://api.grantex.dev/v1/usage/history?days=30" \
  -H "Authorization: Bearer $GRANTEX_KEY"

SDK Usage

// TypeScript
const usage = await grantex.usage.current();
console.log(`Today: ${usage.totalRequests} requests`);

const history = await grantex.usage.history({ days: 7 });
for (const day of history.entries) {
  console.log(`${day.date}: ${day.totalRequests}`);
}
# Python
usage = grantex.usage.current()
print(f"Today: {usage.total_requests} requests")

history = grantex.usage.history(days=7)
for day in history.entries:
    print(f"{day.date}: {day.total_requests}")

Plan Limits

MetricFreeProEnterprise
Token exchanges/month1,000100,000Unlimited
Authorizations/month1,000100,000Unlimited