Skip to main content
GET
/
api
/
onchain
/
stats
Get Onchain Stats
curl --request GET \
  --url https://api.example.com/api/onchain/stats
{
  "total_permits_signed": 42,
  "total_permits_denied": 3,
  "spent_today_usd": 1250.50,
  "last_permit_at": 1700000000
}
Retrieves aggregated statistics about onchain permit activity.

Authentication

Requires a valid session token in the Authorization header:
Authorization: Bearer <session_token>

Response

total_permits_signed
integer
Total number of approved permits signed
total_permits_denied
integer
Total number of denied permit requests
spent_today_usd
number
Total value spent today in USD (resets daily at midnight UTC)
last_permit_at
integer | null
Unix timestamp of the last permit request, or null if no permits have been requested
{
  "total_permits_signed": 42,
  "total_permits_denied": 3,
  "spent_today_usd": 1250.50,
  "last_permit_at": 1700000000
}

Error Responses

error
string
Error message

Status Codes

  • 200 - Success
  • 401 - Unauthorized (missing or invalid session token)
  • 500 - Database error

Examples

curl https://localhost:3978/api/onchain/stats \
  -H "Authorization: Bearer fn_sess_abc123..."

Implementation Notes

  • spent_today_usd is calculated from all approved permits with status = 'approved' since midnight UTC
  • Stats are derived from the permits table in the spend tracking database
  • The daily spend counter is used for enforcing the daily_spend_cap_usd limit

Build docs developers (and LLMs) love