npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

flat-api

v1.0.1

Published

The official JavaScript and TypeScript client for the Flat API

Readme

Flat API client for Typescript

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

npm install flat-api
import { FlatClient } from 'flat-api';

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

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

for await (const collection of client.paginate('listCollections', { parent: 'user' })) {
  console.log(collection.title);
}

paginate takes the operation by name, because the generated methods are instance methods and an unbound reference would lose this. It follows the cursor for you and stops at the last page.

Errors

import { FlatRateLimitError, FlatNotFoundError } from 'flat-api';

try { /* ... */ }
catch (e) {
  if (e instanceof FlatRateLimitError) console.log('retry after', e.reset);
}

Asynchronous use

Every operation returns a promise; there is one surface.

Supported versions

Node 22 and 24, and modern browsers. 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.

npm audit signatures
npm view flat-api dist.attestations

Published through npm 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.