Skip to content

docs(readme): show X-Credits-Charged metadata and explain 429 as out of credits - #23

Merged
MudassarTariq merged 1 commit into
masterfrom
docs/credits-not-rate-limits
Nov 4, 2026
Merged

MudassarTariq merged 1 commit into
masterfrom
docs/credits-not-rate-limits

Conversation

@mateen993

@mateen993 mateen993 commented Nov 4, 2026 •

Copy link
Copy Markdown
Collaborator

What

Fixes two README examples that describe IPGeolocation.io as rate-limited.

Response Metadata example

  • Removed firstHeaderValue("x-ratelimit-remaining"). The API never sends this header, so the line prints undefined.
  • Now shows metadata.creditsCharged and the raw x-credits-charged header, which the API returns on every billed call.

Error Handling example

  • RateLimitError (429) now logs "Out of API credits" with error.apiMessage instead of "Rate limit reached".
  • Added a comment: 429 means credits are used up for the period (or the overage limit is reached), not a per-second limit.
  • Kept the class name RateLimitError so existing code keeps working.

Checked

One /v3/ipgeo lookup with the JavaScript SDK 3.0.1 on Node 22 (this SDK has the same header parsing and 429 handling in src/internal/shared.ts) returns:

statusCode: 200
creditsCharged: 1
firstHeaderValue("x-ratelimit-remaining"): undefined
firstHeaderValue("x-credits-charged"): 1

The SDK source agrees: creditsCharged is parsed from X-Credits-Charged, and a 429 response maps to RateLimitError.

Follow-up

Publish this README in the next npm release so the package README matches.

@MudassarTariq
MudassarTariq merged commit 2366d08 into master Nov 4, 2026
3 checks passed
@MudassarTariq
MudassarTariq deleted the docs/credits-not-rate-limits branch November 4, 2026 16:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants