Skip to main content
rankraft-py on PyPI

Install

Requires Python 3.10+. One runtime dependency (httpx); pandas is optional. The package installs as rankraft-py and imports as rankraft.

Quick start

Every parameter is keyword-only, and names match the API reference (site_id, start_date, group_by). Dates can be strings ("2026-09-01") or datetime.date.

Methods

Pagination

Iterating a page stays on that page; the methods that fetch more pages say so in their name, so a notebook cell never makes surprise requests. The client re-sends your exact query with each cursor, so pages always line up.

to_pandas()

Returns a DataFrame with UTC datetimes, numeric metric columns and categorical dimensions — the types you would otherwise fix by hand after pd.DataFrame(page.data). Needs the pandas extra.

Filters

Pass a plain dict, or build one with &, | and ~:
Operators: is_, not_is, in_, not_in, contains, not_contains, all case-insensitive. Numbers and booleans are converted to strings for you (F("verified").is_(True)). Which fields each report accepts: Filtering.

Errors

Every error carries status, code, details and request_id — include the request id when you contact support. The classes match the JavaScript SDK: BadRequestError, InvalidCursorError, AuthenticationError, PlanRequiredError, PermissionDeniedError, NotFoundError, ConflictError, PayloadTooLargeError, ValidationError, PromptLimitError (err.remaining, err.limit), RateLimitError (err.retry_after_seconds) and InternalServerError. See Errors for every code.

Retries

On by default, with two retries after the first attempt. A 429 is retried after exactly the Retry-After time. Other errors are retried only for operations that are safe to repeat. max_retry_wait caps the total time one call may spend waiting.

Managing prompts

Needs a key with Read and manage prompts access. Prompts can be created, re-categorised and switched on or off, but never deleted, so their history is always kept.

Options

Use with RankRaft() as rr: (or call rr.close()) so connections are released. The client is synchronous; use it on a server or in a notebook, never in code a browser can read.

Package

rankraft-py on PyPI · MIT licence