Skip to content

Flat REST API SDKs ​

We publish and maintain four clients for the Flat REST API. Each one is generated from our public OpenAPI specification and released automatically when that specification changes, so a client never drifts from the API it describes.

InstallLatestRequires
🐍 Pythonpip install flat-apiPython on its registryPython 3.11 – 3.13
💛 JavaScript & TypeScriptnpm install flat-apiJavaScript  TypeScript on its registryNode 22, 24
💎 Rubygem install flat_apiRuby on its registryRuby 3.3, 3.4
🐘 PHPcomposer require flat/apiPHP on its registryPHP 8.2 – 8.4

The version badges read from each registry, so they are current whatever this page says.

Only runtimes still supported upstream are tested. When a version reaches its end of life we drop it in the next major release of the client.

What the clients do for you ​

The Flat API has a few behaviours that are easy to get wrong by assuming convention. Each client handles them for you.

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

Your first call ​

Create a Personal Access Token to get started. It behaves like an OAuth access token scoped to your own account.

python
from flat_api import FlatClient
from flat_api.api.account_api import AccountApi

client = FlatClient(access_token="YOUR_TOKEN")
print(AccountApi(client.api_client).get_authenticated_user().username)
ts
import { FlatClient } from 'flat-api';

const client = new FlatClient({ accessToken: 'YOUR_TOKEN' });
console.log((await client.account.getAuthenticatedUser()).username);
ruby
require 'flat_api'

client = FlatApi::FlatClient.new(access_token: 'YOUR_TOKEN')
puts client.account.get_authenticated_user.username
php
use Flat\APIClient\FlatClient;

$client = new FlatClient(accessToken: 'YOUR_TOKEN');
echo $client->account()->getAuthenticatedUser()->getUsername(), PHP_EOL;

Each repository carries a QUICKSTART.md that goes from installation to a first call, and a per-operation reference generated from the specification.

Another language ​

The specification is public and standard, so you can generate a client for any language openapi-generator supports:

bash
openapi-generator generate \
  -i https://flat.io/developers/docs/openapi.yaml \
  -g <language> -o ./flat-client

The four clients above are generated the same way, with the ergonomic layer described earlier added on top.

Source ​

PythonFlatIO/api-client-pythonReleases
JavaScriptFlatIO/api-client-jsReleases
RubyFlatIO/api-client-rubyReleases
PHPFlatIO/api-client-phpReleases

Copyright © Tutteo Limited