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 readsX-RateLimit-Resetinstead. - Automatic pagination. Eight collection endpoints are cursor-paginated with the cursor in a
Linkheader. 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
client = AsyncFlatClient(access_token="YOUR_TOKEN")
# every operation is awaitable\n```
## Supported versions
Python 3.11, 3.12 and 3.13. Versions past their upstream end of life are not supported; see
[MIGRATION.md](MIGRATION.md) if you are on an older runtime.
## Documentation
- [Quickstart](QUICKSTART.md), install to first call
- [Per-operation reference](docs/reference/), generated
- [API documentation](https://flat.io/developers/docs/api/)
- [Migrating from 1.1.x](MIGRATION.md)
## 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.
```sh
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.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file flat_api-2.0.0.tar.gz.
File metadata
- Download URL: flat_api-2.0.0.tar.gz
- Upload date:
- Size: 374.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8faa3bf2dcd3c9f0e55e271b7112cb9db28b0b35debe97c7daeb47982ca04ecc
|
|
| MD5 |
4fad0200d3c9af9cd1c0da7052eafbc9
|
|
| BLAKE2b-256 |
271a488f76a11d708cff56a4d9c452976e0fcf121ec73252b12a96098a294af5
|
Provenance
The following attestation bundles were made for flat_api-2.0.0.tar.gz:
Publisher:
release.yml on FlatIO/api-client-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
flat_api-2.0.0.tar.gz -
Subject digest:
8faa3bf2dcd3c9f0e55e271b7112cb9db28b0b35debe97c7daeb47982ca04ecc - Sigstore transparency entry: 2784647401
- Sigstore integration time:
-
Permalink:
FlatIO/api-client-python@024fc34b35177b7c50ece32e9c03d2221f843747 -
Branch / Tag:
refs/tags/2.0.0 - Owner: https://github.com/FlatIO
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@024fc34b35177b7c50ece32e9c03d2221f843747 -
Trigger Event:
push
-
Statement type:
File details
Details for the file flat_api-2.0.0-py3-none-any.whl.
File metadata
- Download URL: flat_api-2.0.0-py3-none-any.whl
- Upload date:
- Size: 1.2 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
46e6ad8a5d1740d49faf5914c9cc0de68fa51c1f346cc9b957eb585f53244026
|
|
| MD5 |
e0af982d7d1962fd4f0e4e020efa6f2d
|
|
| BLAKE2b-256 |
a6b30e95b6e5d5187b4814eb0d268d6870907c6971376db2d3fb4d0893bdd954
|
Provenance
The following attestation bundles were made for flat_api-2.0.0-py3-none-any.whl:
Publisher:
release.yml on FlatIO/api-client-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
flat_api-2.0.0-py3-none-any.whl -
Subject digest:
46e6ad8a5d1740d49faf5914c9cc0de68fa51c1f346cc9b957eb585f53244026 - Sigstore transparency entry: 2784647613
- Sigstore integration time:
-
Permalink:
FlatIO/api-client-python@024fc34b35177b7c50ece32e9c03d2221f843747 -
Branch / Tag:
refs/tags/2.0.0 - Owner: https://github.com/FlatIO
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@024fc34b35177b7c50ece32e9c03d2221f843747 -
Trigger Event:
push
-
Statement type: