STAT-API

Read your quota off a response

Every response is metered and stamped with X-Quota-Limit / X-Quota-Used / X-Quota-Remaining. The SDK parses them into a Quota on every list page, so you can watch your monthly budget without a second request.

  1. 1. List a page and read its quota

    The quota is null only when the server omitted the headers (never on a normal list response).

    const page = await api.nba.teams.list({ limit: 3 })
    if (page.quota) {
      console.log(`quota: ${page.quota.remaining} of ${page.quota.limit} records left this month`)
    } else {
      console.log('no quota headers on this response')
    }