Official client for the Flat REST API, generated from Flat's public OpenAPI specification and kept current automatically.
gem install flat_apirequire 'flat_api'
client = FlatApi::FlatClient.new(access_token: 'YOUR_TOKEN')
puts client.account.get_authenticated_user.usernameGet a token in seconds with a Personal Access Token; it works exactly like an OAuth access token for your own account.
- 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.
client.paginate(:list_collections, parent: 'user') do |collection|
puts collection.title
endpaginate takes any operation: positional arguments are its path parameters, keywords its query
parameters. It follows the cursor for you and stops at the last page.
begin
# ...
rescue FlatApi::FlatRateLimitError => e
puts "retry after #{e.reset}"
rescue FlatApi::FlatNotFoundError
puts 'no such score'
endSynchronous only: async is not idiomatic in Ruby for this shape of client.
Ruby 3.3 and 3.4. Versions past their upstream end of life are not supported; see MIGRATION.md if you are on an older runtime.
- Quickstart, install to first call
- Per-operation reference, generated
- API documentation
- Migrating from 0.3.x
Published through RubyGems trusted publishing, so no long-lived API key exists that could publish under this name. The release workflow is the only publisher, and each release is tied to the commit and the API specification version it was generated from.
gem fetch flat_api
gem spec flat_api-*.gemGenerated 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.
Apache 2.0. See LICENSE.