On this page

Python SDK

Use the Python SDK to check drafts and read saved reports from your own code. You need Python 3.11 or newer and an authorized readlint.com account. The installation commands below use a macOS or Linux shell. On Windows, use the virtual environment's Python under .venv/Scripts/.

Install

python -m venv .venv
.venv/bin/python -m pip install readlint

Authenticate

Create an API key and supply READLINT_API_KEY through your environment or secret manager. The SDK accepts an explicit key before the environment variable. It does not read the CLI's saved login. Do not commit keys or print them.

For interactive device login, use the CLI, which saves its own credential. Scripts using the SDK should receive a separate API key from your secret manager. Both keys act for the same account. Listing reports does not require evaluation allowance.

First success

Choose the Python tab. The other tabs use the CLI, other SDK or curl setup.

List saved reports

npx readlint.com list --limit 25 --offset 0 --json

import json
from readlint import Readlint

with Readlint() as client:
    print(json.dumps(client.list_evaluations(limit=25, offset=0)))

import { Readlint } from "readlint.com";

const client = new Readlint();
console.log(JSON.stringify(await client.listEvaluations({ limit: 25, offset: 0 })));

curl --silent --show-error --fail-with-body \
  --header @readlint-auth.header \
  'https://readlint.com/v1/evaluations?limit=25&offset=0'

A valid key returns items and next_offset. An empty account returns {"items": [], "next_offset": null}. Follow evaluate an article for submission, reading and deletion examples in every client.

Responses and configuration

Save the Python example as list_reports.py and run .venv/bin/python list_reports.py.

The SDK returns typed JSON dictionaries: Evaluation, EvaluationSummary, EvaluationPage and EvaluationReport. Dates are RFC 3339 strings. py.typed is included. Use a context manager or call close() to release connections.

Readlint(api_key=...) overrides READLINT_API_KEY. base_url overrides READLINT_BASE_URL. timeout defaults to 120 seconds and max_retries to 2. transport accepts an httpx transport for controlled tests.

ReadlintError exposes code, message, status (None for transport errors) and evaluation_id when a stored evaluation failed. It omits credentials and raw server responses. Catch it, follow the recovery message and retain the original key for an uncertain submission.

Retry safely

evaluate requires an explicit submission key (idempotency_key in Python, idempotencyKey in TypeScript). Save it before sending. After a timeout, use the same key and identical article, title and description. A running evaluation has report: null; read its ID later. A stored failed evaluation raises evaluation_failed; reading its ID returns the saved failure.

Reads and keyed submissions retry network failures and HTTP 429, 502, 503 and 504 at most twice. They honor Retry-After; waits over 60 seconds stop the call. Deletes are sent once. Read the same ID after a lost delete response before trying again. The limits and recovery guide explains account errors, expiry and terminal failures.

Next: TypeScript SDK