API reference
Account and billing
Three routes: the calls you have left, the history of your balance, and a payment page for more calls.
In short
- Three routes: the account of your key, the ledger and a payment page.
- All three need a key and cost nothing.
The samples continue from the quick start: they use its helper call.
The routes
GET /v1/account
Calls left, limits and usage of the key.
The calls you have left, the limits in force, and the usage of the key you send.
Request
curl -sS "$GECKO_API/v1/account" -H "Authorization: Bearer $GECKO_KEY"
me = call("GET", "/v1/account", headers=AUTH)
print(me["credits"], me["limits"]["key"], me["usage"])
const me = await call("GET", "/v1/account");
console.log(me.credits, me.limits.key, me.usage);
Answer
{
"id": "acct_00VcT0dVK9hYwgNL7TOtz",
"name": "Rivertown Poker Labs",
"status": "active",
"credits": 14547,
"plan": null,
"limits": {
"account": {"max_concurrent": 1, "monthly_credits": null, "max_credits_per_request": 20000, "expand_all": true},
"key": {"rpm": 120, "daily_credits": 5000, "monthly_credits": null}
},
"usage": {"account_month": 453, "key_day": 12, "key_month": 453},
"key": {"id": "key_00VcT0dVWUNMMpSY2DTbJ", "name": "Production server", "env": "live", "hint": "gecko_live_qfP...evB1"}
}
credits is the calls you have left. usage counts calls: this month for the account, today and this month for the key. Days and months are in UTC.
ErrorsThe errors of the key and the account.
GET /v1/ledger
Every change of the balance.
Every change of the balance, newest first: solves, calls returned for failed solves, packs, plans and grants.
Parameters
| Name | Where and type | Required | Meaning and limits |
|---|---|---|---|
limit | query · whole number | No | 1 to 500. Default 100. |
after | query · number | No | The next value of the page before. Stop when next is null. |
Request
curl -sS "$GECKO_API/v1/ledger?limit=2" -H "Authorization: Bearer $GECKO_KEY"
lines = call("GET", "/v1/ledger", headers=AUTH, params={"limit": 2})
print([(line["type"], line["credits"], line["balance"]) for line in lines["data"]], lines["next"])
const lines = await call("GET", "/v1/ledger?limit=2");
console.log(lines.data.map((line) => [line.type, line.credits, line.balance]), lines.next);
Answer
{
"data": [
{"id": "led_00VcT5fj2aQmW1xYb7Tn4", "type": "solve", "credits": -1, "balance": 14999, "ts": 1796049035.03,
"solve_id": "slv_00VcT0iMuhDqPySfwtq2K", "root_id": "slv_00VcT0iMuhDqPySfwtq2K", "key_id": "key_00VcT0dVWUNMMpSY2DTbJ", "street": "flop"},
{"id": "led_5c1f0e3a9b7d4c2e8f6a1b3d5e7f", "type": "topup", "credits": 2500, "balance": 15000, "ts": 1796040000.0,
"ref": "cs_...", "note": "2,500 calls", "amount": 25000, "currency": "usd"}
],
"next": null
}
type is solve, refund, topup, plan or grant. amount is in cents. A test key makes no ledger lines.
Errorsinvalid_request, and the errors of the key and the account.
POST /v1/billing/checkout
A payment page for a pack or a plan.
The address of a payment page for one pay-per-call pack or one monthly plan. Calls are added after the payment is confirmed to us.
Parameters
| Name | Where and type | Required | Meaning and limits |
|---|---|---|---|
pack | body · string | One of the two | The id of a pack from GET /v1/pricing, such as calls-2500. |
plan | body · string | One of the two | The id of a plan, such as builder. An account has one plan at a time. |
code | body · string | No | A discount code, with plan only. A code that does not apply to the plan is refused: 422 invalid_request. |
success_url, cancel_url | body · string | No | Where the payment page sends the buyer after it. |
Request
curl -sS -X POST "$GECKO_API/v1/billing/checkout" \
-H "Authorization: Bearer $GECKO_KEY" -H "Content-Type: application/json" \
-d '{"pack": "calls-2500"}'
page = requests.post(f"{API}/v1/billing/checkout", json={"pack": "calls-2500"}, headers=AUTH, timeout=40)
print(page.status_code, page.json().get("url") or page.json()["code"])
const pay = await fetch(`${API}/v1/billing/checkout`, {
method: "POST",
headers: { ...auth, "Content-Type": "application/json" },
body: JSON.stringify({ pack: "calls-2500" }),
});
const payment = await pay.json();
console.log(pay.status, payment.url ?? payment.code);
Answer
{"id": "cs_...", "url": "https://checkout.stripe.com/..."}
A payment started this way does not save the card for automatic top-up. More in Payments.
Errorsinvalid_request, billing_unavailable, and the errors of the key and the account.