Skip to main content

Flat API client for Python

Official client for the Flat REST API, generated from Flat's public OpenAPI specification and kept current automatically.

pip install flat-api
from flat_api import FlatClient

client = FlatClient(access_token="YOUR_TOKEN")
me = client.api_client  # generated APIs hang off here

Get a token in seconds with a Personal Access Token; it works exactly like an OAuth access token for your own account.

What this client does for you

  • Typed errors. Branch on the error, not the status code. Flat returns HTTP 403 for both rate limiting and authorization failures, so status alone cannot tell them apart.
  • Automatic retries. Rate limits and server errors are retried with backoff. Flat sends no Retry-After, so the client reads X-RateLimit-Reset instead.
  • Automatic pagination. Eight collection endpoints are cursor-paginated with the cursor in a Link header. You get an iterator; you never touch a cursor.
  • OAuth2 built in. Authorization URLs, code exchange and transparent token refresh.
  • Full type information, so your editor and your coding assistant both know the API.

Pagination

from flat_api import paginate

for score in paginate(api.get_user_scores_with_http_info, user="me"):
    print(score.title)

Errors

from flat_api import FlatRateLimitError, FlatNotFoundError

try:
    ...
except FlatRateLimitError as exc:
    print("retry after", exc.reset)
except FlatNotFoundError:
    print("no such score")

Asynchronous use

from flat_api import AsyncFlatClient

client = AsyncFlatClient(access_token="YOUR_TOKEN")
# every operation is awaitable

Supported versions

Python 3.11, 3.12 and 3.13. Versions past their upstream end of life are not supported; see MIGRATION.md if you are on an older runtime.

Documentation

Verifying this package

Every release carries a signed provenance attestation linking the package back to the commit, the workflow run that built it, and the API specification version it was generated from.

pip download --no-deps flat-api
gh attestation verify flat_api-*.whl --repo FlatIO/api-client-python

Published through PyPI trusted publishing: no long-lived token exists that could publish under this name.

How this client is maintained

Generated from the public specification published at FlatIO/api-reference. A new specification release regenerates, validates and publishes this package automatically, so it never drifts from the API.

Files under docs/reference/ and the client sources are generated: edit the generator configuration in tools/, not the output.

License

Apache 2.0. See LICENSE.

Release files for flat-api 2.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for flat-api 2.0.2
File Size Uploaded
flat_api-2.0.2.tar.gz 373.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for flat-api 2.0.2
File Interpreter ABI Platform
flat_api-2.0.2-py3-none-any.whl Python 3 none any Details

Total release size: 1.5 MB

Release files / flat_api-2.0.2.tar.gz

Download URL flat_api-2.0.2.tar.gz
Size 373.2 kB
Tags Source
SHA-256 checksum
How to use checksums
f6e2ce4a3403db00b80440b43fa7c3b7194621367e91625a84dee9a197082495
BLAKE2b-256 checksum
How to use checksums
c4d3e62b01d8fc7ee89bb1c9c4234758f29f1ec89e415210d28771d709059a43
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 17, 2026.

Transparency log

Release files / flat_api-2.0.2-py3-none-any.whl

Download URL flat_api-2.0.2-py3-none-any.whl
Size 1.2 MB
Tags Python 3
SHA-256 checksum
How to use checksums
bd1469d8375dca9c3df7d1fd796c284396364e7e3794afba22f70f8ebb5bf1dc
BLAKE2b-256 checksum
How to use checksums
54108a613297afa6eb9af5dc8b335b7b23655f8bbc47bc469557f29883de1259
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 17, 2026.

Transparency log

Release history Release notifications | RSS feed

2.0.3

2 release files

This release

2.0.2 This release

2 release files

2.0.1

2 release files

2.0.0

2 release files

1.1.3

2 release files

1.1.0

2 release files

1.0.0

2 release files

0.8.1

2 release files

0.8.0

2 release files

0.7.0

1 release file

0.6.0

1 release file

0.5.0

1 release file

0.4.0

1 release file

0.3.0

1 release file

0.2.0

1 release file

0.1.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page