API
An API (Application Programming Interface) is a set of defined rules that enables one software application to communicate with and use the functionality of another.
§ 1 Definition
An API is a contract between two pieces of software. It defines how they communicate: what requests are valid, what data to expect, and what errors look like. On the web, APIs typically use HTTP as the transport and JSON or XML as the data format. Web APIs come in many flavors: REST (resource-oriented, stateless), GraphQL (query-based, single endpoint), WebSocket (bidirectional, persistent), and RPC (action-oriented). Every time your browser gets weather data from a server, every time a mobile app loads your social feed, and every time a third-party service embeds a map on your site, an API is doing the work. APIs are the plumbing of modern software. They let teams build specialized services and connect them without needing to know each other's internal implementation.
§ 2 How web APIs work
A client sends an HTTP request to a defined endpoint URL. The request includes a method (GET to read, POST to create, PUT to update, DELETE to remove), headers (authentication tokens, content type), and optionally a body. The server processes the request and returns a response with a status code and data payload. Well-designed APIs follow consistent patterns: resource-oriented URLs, proper HTTP status codes, clear error messages, and versioning.
§ 3 REST vs. GraphQL vs. RPC
REST organizes APIs around resources (`/users/42`). Each resource has standard CRUD operations. GraphQL gives clients the power to request exactly the fields they need, reducing overfetching and underfetching. RPC (like gRPC) calls specific functions on the server. There is no universally best choice. REST is simpler and cacheable. GraphQL is more flexible for complex UIs. RPC is fastest for internal microservices.
§ 4 Common misconception
Calling something a REST API does not make it RESTful. True REST (as Roy Fielding defined it) requires HATEOAS (hypermedia as the engine of application state). Most "REST APIs" are really HTTP APIs that follow REST-like conventions. That is fine for practical purposes, but do not argue that your CRUD JSON endpoint is truly REST unless it returns hypermedia links.
§ 5 Note
§ 6 In code
```javascript
// Calling a REST API with fetch
const response = await fetch('https://api.example.com/users', {
headers: { 'Authorization': 'Bearer token123' }
});
const users = await response.json();
```§ 7 Common questions
- Q. What is the difference between an API and a library?
- A. A library is code you include. An API is an interface you call, often over a network.
- Q. Do all APIs use HTTP?
- A. No. APIs can use other protocols: gRPC uses HTTP/2, WebSocket is TCP-based, and native APIs may use local IPC.
- APIs define how software components communicate.
- Most web APIs use HTTP and JSON.
- Good API design prioritizes consistency, clear errors, and versioning.
Atomic Glue designs and builds APIs that are consistent, documented, and performant. From REST to GraphQL, we integrate your services. See our Website Development services.
Get in touchAn API (Application Programming Interface) is a set of defined rules that enables one software application to communicate with and use the functionality of another.
Category: Web Development (also: Analytics, Apis)
Author: Atomic Glue Team
## Definition
An API is a contract between two pieces of software. It defines how they communicate: what requests are valid, what data to expect, and what errors look like. On the web, APIs typically use [HTTP](/glossary/http) as the transport and [JSON](/glossary/json) or [XML](/glossary/xml) as the data format. Web APIs come in many flavors: REST (resource-oriented, stateless), GraphQL (query-based, single endpoint), WebSocket (bidirectional, persistent), and RPC (action-oriented). Every time your browser gets weather data from a server, every time a mobile app loads your social feed, and every time a third-party service embeds a map on your site, an API is doing the work. APIs are the plumbing of modern software. They let teams build specialized services and connect them without needing to know each other's internal implementation.
## How web APIs work
A client sends an HTTP request to a defined endpoint URL. The request includes a method (GET to read, POST to create, PUT to update, DELETE to remove), headers (authentication tokens, content type), and optionally a body. The server processes the request and returns a response with a status code and data payload. Well-designed APIs follow consistent patterns: resource-oriented URLs, proper HTTP status codes, clear error messages, and versioning.
## REST vs. GraphQL vs. RPC
REST organizes APIs around resources (`/users/42`). Each resource has standard CRUD operations. GraphQL gives clients the power to request exactly the fields they need, reducing overfetching and underfetching. RPC (like gRPC) calls specific functions on the server. There is no universally best choice. REST is simpler and cacheable. GraphQL is more flexible for complex UIs. RPC is fastest for internal microservices.
## Common misconception
Calling something a REST API does not make it RESTful. True REST (as Roy Fielding defined it) requires HATEOAS (hypermedia as the engine of application state). Most "REST APIs" are really HTTP APIs that follow REST-like conventions. That is fine for practical purposes, but do not argue that your CRUD JSON endpoint is truly REST unless it returns hypermedia links.
## Note
API versioning is critical. Breaking changes without versioning break your clients. Common strategies: URL versioning (`/v1/users`), header versioning (`Accept: application/vnd.api+json;version=1`), or query parameter versioning.
## In code
## Common questions Q: What is the difference between an API and a library? A: A library is code you include. An API is an interface you call, often over a network. Q: Do all APIs use HTTP? A: No. APIs can use other protocols: gRPC uses HTTP/2, WebSocket is TCP-based, and native APIs may use local IPC.
## Key takeaways
- APIs define how software components communicate.
- Most web APIs use HTTP and JSON.
- Good API design prioritizes consistency, clear errors, and versioning.
## Related entries
- [JSON](atomicglue.co/glossary/json)
- [XML](atomicglue.co/glossary/xml)
- [REST](atomicglue.co/glossary/rest)
- [HTTP](atomicglue.co/glossary/http)
- [WebSocket](atomicglue.co/glossary/websocket)
Last updated June 2026. Permalink: atomicglue.co/glossary/api