Documentation

Python library

The official library: one call per page, typed results, the errors as exceptions. Python 3.10 or newer.

pip install gimmepage

Quick start

from gimmepage import Gimmepage

client = Gimmepage()  # reads GIMMEPAGE_API_KEY; or Gimmepage(api_key="YOUR_API_KEY")
page = client.fetch("https://example.com/")
print(page.site_status, page.final_url, page.cost, page.balance)
print(page.text)

Your key is on your account page. Keep it out of source code: the environment variable is the easy way. One client is safe to share between threads; reuse it.

Options

page = 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
    max_chars=20_000,     # cut the Markdown
    timeout=30,           # seconds, 2 to 60
)

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

The result

A Page has content (bytes), text (decoded with the page's charset; raises for content that is not text), site_status, final_url, content_type, output, proxy, country, cost, balance, request_id, cached_age, truncated and full_length. A site's own "not found" page is a page with site_status == 404, and it is charged.

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

Async

import asyncio
from gimmepage import AsyncGimmepage

async def main(urls):
    async with AsyncGimmepage() as client:
        return await asyncio.gather(*(client.fetch(u) for u in urls))

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 raises a GimmepageError and is never charged. It carries code, message, retry, retry_after, site_status, request_id and http_status. 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 Gimmepage(retries=3) a failed request is sent again, at most that many times, and only when its error says retry: after retry_after 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/python in the gimmepage repository, with its CHANGELOG.md.