all work

Atlas API

(Public API Platform)

A public GraphQL and REST platform with keys, docs and limits developers actually enjoy.

  • 2B requests / month
  • 42ms p99 latency
  • 600+ developers

2024 · Node.js · GraphQL · PostgreSQL · Kubernetes

atlasapi.app

Problem

(what hurt)

Partners scraped HTML to get their own data, which broke on every redesign. Internal endpoints were undocumented and unauthenticated.

Project goal: Partners were scraping the dashboard because there was no API. The goal was a public GraphQL and REST platform with keys, docs and fair limits.

Architecture

(how it fits together)

A GraphQL gateway sits in front of existing services with per-request DataLoaders. REST endpoints are generated from the same schema. Keys, quotas and usage metering run at the edge before requests reach the cluster.

Tech decisions: A GraphQL gateway with DataLoader batching to kill N+1 queries, cursor pagination, token-bucket rate limiting at the edge, and generated TypeScript SDKs. Runs on Kubernetes.

  • Node.js
  • GraphQL
  • PostgreSQL
  • Kubernetes
(architecture)SDKsGraphQLPostgresCache
graphql/resolvers/project.ts
export const Project = {
  // batched: one query per request, not one per row
  owner: (project, _args, { loaders }) =>
    loaders.user.load(project.ownerId),

  deployments: async (project, { first = 20, after }, { db }) => {
    const rows = await db.deployment.findMany({
      where: { projectId: project.id },
      take: first + 1,
      cursor: after ? { id: decode(after) } : undefined,
    });
    return toConnection(rows, first);
  },
};

Features

(what it does)

  • One schema, two APIs

    GraphQL and REST are generated from one source, so docs and SDKs never drift from reality.

  • Fair rate limits

    Token buckets per key, with clear headers that tell developers exactly when to retry.

  • Docs you can run

    Every example in the docs is executable against a sandbox key.

(in use)
ship it ✓
atlasapi.app/settings

Challenges

(what was hard)

  1. 01N+1 queries

    Nested queries fanned out into thousands of reads. Batching brought p99 down to 42ms.

  2. 02Breaking changes

    Schema checks in CI block any change that would break a query seen in the last 30 days.

Results

  • 2B requests / month
  • 42ms p99 latency
  • 600+ developers

Atlas serves 2 billion requests a month to 600+ developers, and scraping traffic dropped to zero.

design & code by Shreya Pathak