Guide 2.21: Developer Guide

Monitoring API Usage

While you can always log into the SdashAPI Developer Dashboard to view your beautiful traffic graphs, you should ideally monitor your quota usage programmatically so your application can warn users when they are about to run out of credits.

Inspecting Response Headers

2.21.1

Every successful HTTP response from SdashAPI includes custom headers that contain your current rate limit status. Instead of just parsing the JSON body, you can read these headers directly in your code.

const response = await fetch(url, { headers: { "AccessToken": "YOUR_KEY" } });

// Extract the custom rate limit headers
const limit = response.headers.get('X-RateLimit-Limit');
const remaining = response.headers.get('X-RateLimit-Remaining');

console.log(`You have ${remaining} out of ${limit} credits left this month.`);

Graceful Degradation

2.21.2

By monitoring the X-RateLimit-Remaining header, your frontend app can detect when you drop below 50 credits. You can then trigger a UI banner telling the user "Daily limit almost reached" or temporarily disable high-cost features like V4 AI hints until the billing cycle resets.

Network acting up?

Next, we will show you how to build automatic retry logic for failed requests.

Next Guide: Building Retry Logic →
Avatar

How can we help?

We reply immediately

Hello! 👋 How can we help you today?