Beyond scraping, the client exposes two account namespaces: client.apiKeys for
managing your keys and client.billing for credits. Both authenticate with the
API key you constructed the client with.
client.apiKeys
Mint, list, and revoke API keys programmatically — handy for provisioning a key
per environment or per customer.
// Create a key — the raw secret is returned exactly once. Store it now.
const created = await client.apiKeys.create({ name: 'production' });
if (created.type === 'success') {
console.log(created.data.rawKey);
}
// List active keys, newest first.
const keys = await client.apiKeys.list();
// Revoke a key by id.
await client.apiKeys.revoke({ id: 'key_123' });
| Method | Description |
|---|
create({ name? }) | Mint a new key. Returns the raw secret once — it can never be retrieved again. |
list() | List the account’s active keys, newest first. |
revoke({ id }) | Revoke a key by id. Succeeds with no body. |
create returns the key’s secret a single time. Store it the moment you
receive it — Bridgly keeps only a hash and can never show it again.
client.billing
Read your balance and top up credits.
// Current balance and billing settings.
const info = await client.billing.getInfo();
if (info.type === 'success') {
console.log(info.data.credits);
}
// Start a credit purchase — returns a Stripe Checkout URL to open.
const checkout = await client.billing.buyCredits({ amountUsd: 20 });
if (checkout.type === 'success') {
console.log(checkout.data); // redirect the browser here
}
// Configure auto top-up.
await client.billing.updateAutoTopUp({
enabled: true,
thresholdCredits: 500,
amountUsd: 20,
});
| Method | Description |
|---|
getInfo() | The account’s live credit balance and auto-top-up settings. |
buyCredits({ amountUsd }) | Start a purchase. Returns a Stripe Checkout URL to redirect to. |
updateAutoTopUp({ enabled, thresholdCredits, amountUsd }) | Update auto-top-up settings. Returns the refreshed billing snapshot. |
Result shape
Account methods return a slightly simpler result than scraping methods — a
data payload on success, or a status and message on error, with no credit
envelope:
type AccountResult<T> =
| { type: 'success'; data: T }
| { type: 'error'; status: number; message: string };
revoke returns a VoidResult — success carries no body:
type VoidResult =
{ type: 'success' } | { type: 'error'; status: number; message: string };