Check affordability
Confirm whether your current balance covers an upcoming request.
curl -X POST https://api.chuger.com/v1/credits/can-afford \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-H "Content-Type: application/json" \
-d '{"service_type": "content", "quantity": 50}'
const res = await fetch('https://api.chuger.com/v1/credits/can-afford', {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.CHUGER_TOKEN}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({ service_type: 'content', quantity: 50 }),
});
const { can_afford } = await res.json();
{
"can_afford": true,
"preview": {
"service_type": "content",
"service_name": "Content Extraction",
"credit_cost_per_request": 2,
"quantity": 50,
"total_cost": 100,
"current_balance": 18675,
"remaining_after": 18575,
"can_afford": true
}
}
A thin convenience wrapper around /preview-cost that promotes the affordability flag to the top level — handy for in-app gating where you don't need the full cost breakdown.
POST https://api.chuger.com/v1/credits/can-afford
No credits are deducted by this endpoint.
All /v1/credits/* endpoints are free to call and not subject to per-minute rate limits.
Authentication
Bearer token in the Authorization header. See Authentication.
Request body
Same shape as /preview-cost:
body
service_typestring
RequiredOne of scrape, content, serp, prompt.
body
quantityinteger
Integer between 1 and 100. Defaults to 1.
Example
Response fields
can_affordboolean
Requiredtrue if the current balance covers the previewed cost.
previewobject
RequiredFull preview payload — identical shape to /preview-cost so a single response can drive both gating and display.
Errors
| Status | When |
|---|---|
401 | Missing or invalid token |
422 | service_type missing/invalid, or quantity out of range |
See Errors for the full reference.
Was this page helpful?