Documentation

JavaScript library

The official library for Node 20 or newer, Deno and Bun: TypeScript types included, no dependencies. Use it on a server only: in a browser everyone could read your key.

npm install gimmepage

Quick start

import { Gimmepage } from "gimmepage";

const client = new Gimmepage(); // reads GIMMEPAGE_API_KEY; or new Gimmepage({ apiKey: "YOUR_API_KEY" })
const page = await client.fetch("https://example.com/");
console.log(page.siteStatus, page.finalUrl, page.cost, page.balance);
console.log(page.text);

Your key is on your account page. One client serves many requests at once; reuse it.

Options

const page = await client.fetch("https://example.com/", {
  render: true,          // as a browser shows it (5 credits)
  proxy: "residential",  // from a home connection (10 credits, 25 rendered)
  country: "de",         // with residential: "us" (default) or "de"
  output: "markdown",    // Markdown for language models, same price
  maxChars: 20_000,      // cut the Markdown
  timeout: 30,           // seconds, 2 to 60
  signal,                // an AbortSignal of your own
});

Client options: apiKey, baseUrl, timeout (default 60 seconds, the service's limit; the connection waits 5 seconds longer), retries (default 0).

The result

A Page has content (Uint8Array), text (decoded with the page's charset; throws for content that is not text), siteStatus, finalUrl, contentType, output, proxy, country, cost, balance, requestId, cachedAge, truncated and fullLength. A site's own "not found" page is a page with siteStatus === 404, and it is charged.

await client.balance() returns your balance and the prices, for free.

Your account runs 2 requests at once, and one at a time per site; more are refused at once and free (Limits).

Errors

A failed request rejects with a GimmepageError and is never charged. It carries code, message, retry, retryAfter, siteStatus, requestId and httpStatus. Branch on its subtypes:

TypeCodes
AuthErrorinvalid_key, account_suspended
OutOfCreditsErrorout_of_credits
RateLimitErrortoo_many_requests, site_busy
SiteErroreverything the site did: blocked, site_refused, site_rate_limited, site_error, site_unreachable, site_not_found, site_tls_error, too_many_redirects, too_large, timeout
UnavailableErrortemporarily_unavailable, and a failed connection to gimmepage

Every code is explained on the Errors page. A code your version does not know yet is a plain GimmepageError, so older versions keep working.

Retries

Off by default. With new Gimmepage({ retries: 3 }) a failed request is sent again, at most that many times, and only when its error says retry: after retryAfter seconds when the answer names a wait, otherwise after 1, 2, 4… seconds, at most 30. A request that returned a page is never sent again.

One caution. When the connection to gimmepage breaks before the answer arrives, the library cannot know whether the page was fetched. It treats that as worth retrying, so with retries on, such a request can be charged twice. Your usage list shows every request.

Source and changes: clients/js in the gimmepage repository, with its CHANGELOG.md.