The result union
No SDK method throws for API or network errors. Every scraping method returns anApiResult, a discriminated union you narrow on the type field:
type narrows the rest of the object — in the success branch
data, timeMs, and creditsCost are all available and typed; in the error
branch you get status and message.
Error status codes
Thestatus field carries the HTTP status code. Branch on it rather than
parsing the message string.
| Status | Meaning | What to do |
|---|---|---|
400 | The request failed validation. | Check the field values against the endpoint schema. |
401 | Missing, malformed, or revoked API key. | Verify the key you passed to new Bridgly(...). |
402 | Out of credits. | Top up from the dashboard or with client.billing.buyCredits. |
404 | The requested resource wasn’t found. | Confirm the identifier exists and is public. |
500 | The scrape failed unexpectedly. | Retry after a short delay. |
0 | Network error — the request never completed. | Check connectivity; the message has the detail. |