⌘K

Data Formats

API

An API (Application Programming Interface) is a defined contract that lets one piece of software request data or actions from another without knowing how it works internally.

Updated 12 Aug 2026

A contract between programs

An API is the published surface of a system: the endpoints you may call, the inputs they accept and the outputs they promise. Everything behind that surface — the language, database and deployment — can change freely as long as the contract holds.

On the web, most APIs speak HTTP and exchange JSON. A client sends a method (GET, POST, PUT, DELETE), a path, headers and often a body; the server replies with a status code and a body. REST organises those calls around resources; GraphQL exposes a single endpoint and lets the client describe exactly which fields it wants.

Anatomy of a request

PartPurpose
MethodThe intent: read, create, replace or delete
PathWhich resource is being addressed
HeadersContent type, authentication token, caching hints
BodyThe payload, normally JSON
Status code200 success, 400 bad input, 401 unauthenticated, 500 server fault

Authentication in practice

Most APIs identify the caller with either an API key sent in a header or a bearer token such as a JWT. Tokens usually carry an expiry, so clients refresh them periodically. Never place credentials in a URL — they end up in logs, browser history and analytics.

JSON Formatter

Paste a raw response to format, fold and validate it instantly.

Try JSON Formatter

Characteristics

  • A published, versioned contract independent of implementation
  • Typically HTTP with JSON payloads on the web
  • Status codes communicate outcome separately from the body
  • Authentication via API keys or bearer tokens

Common uses

  • Connecting a front-end application to its back end
  • Integrating third-party services such as payments, email or maps
  • Machine-to-machine automation and webhooks
  • Exposing internal data to partner systems safely

Advantages

  • Decouples teams — clients and servers evolve independently
  • Reuses one back end across web, mobile and partner clients
  • Standard status codes and formats make tooling interchangeable
  • Enables automation without screen scraping

Limitations

  • Breaking changes need versioning and a migration path
  • Every network call adds latency and failure modes
  • Rate limits and quotas constrain heavy clients
  • Poorly documented contracts are as bad as none

Examples

A JSON API request and its response
POST /v1/users HTTP/1.1
Content-Type: application/json
Authorization: Bearer <token>

{ "name": "Ada Lovelace", "email": "ada@example.com" }

HTTP/1.1 201 Created
{ "id": 4821, "name": "Ada Lovelace" }

Frequently asked questions

What is an API in simple terms?

A defined way for one program to ask another for data or to perform an action, without knowing how it is implemented.

What is a REST API?

An HTTP API organised around resources, where the method expresses the intent and the path identifies the resource.

Why do APIs use JSON?

It is compact, human-readable and maps directly onto native data structures in every common language.

What does a 401 status mean?

The request was not authenticated — the token is missing, expired or invalid.

What is the difference between REST and GraphQL?

REST exposes many endpoints returning fixed shapes; GraphQL exposes one endpoint where the client specifies the fields it needs.

Related terms

All terms

Related tools

Related guides

All guides