Check your Weir credits with Python, Node.js and cURL

See how many credits your account has left before a large job. This call is free.

It is one call to GET /v1/usage, which costs nothing. Every snippet below ran against the live API on 27 October 2026, and the output is what the Python printed.

Set your key first. Create one at https://weirapp.io/dashboard/keys; every account gets 5,000 free credits a month.

export WEIR_API_KEY=weir_live_...

Python

import os

import requests

response = requests.get(
    "https://api.weirapp.io/v1/usage",
    headers={"Authorization": f"Bearer {os.environ['WEIR_API_KEY']}"},
    timeout=60,
)
response.raise_for_status()
page = response.json()

print(sorted(page["data"].keys()))
print("credits charged:", response.headers["X-Credits-Charged"])

Node.js

// Node.js 18 or later, as an ES module (save as example.mjs).
const response = await fetch("https://api.weirapp.io/v1/usage", {
  headers: { Authorization: `Bearer ${process.env.WEIR_API_KEY}` },
});
if (!response.ok) throw new Error(`${response.status}: ${await response.text()}`);
const page = await response.json();

console.log(Object.keys(page.data).sort());
console.log("credits charged:", response.headers.get("x-credits-charged"));

cURL

curl --request GET \
  --url 'https://api.weirapp.io/v1/usage' \
  --header "Authorization: Bearer $WEIR_API_KEY"

Output

['available', 'balance', 'freeGrant', 'reserved', 'spendingPaused', 'tier']
credits charged: 0

If a call fails

Failed calls are free. A 429 means too many requests a minute: wait the seconds in Retry-After and send it again. A 402 means the account is out of credits. A 503 means the source is busy and is safe to retry. Every code is on Errors, and paging is on Pagination.

View this page as Markdown