← Glossary

What Is an API?

An API, or application programming interface, is a defined set of operations through which one piece of software uses another without knowing its internals. This article explains how requests and responses are exchanged, what endpoints are, the main families of APIs, how they differ from user interfaces and SDKs, and where their limits lie.

Updated:

An API (application programming interface) is a defined set of operations, data formats and rules through which one piece of software uses the capabilities of another. The program offering the API publishes what can be asked of it and in what form; the program calling it follows those rules and gets back a predictable result. MDN describes the arrangement as a contract between the application exposing the interface and whatever consumes it, in contrast to a user interface, which is built for a human.

The term is often assumed to mean a web service reached over HTTP. That is one common shape, but far from the only one. An operating system exposes APIs for opening files and drawing windows; a programming library exposes an API of functions and classes; a browser exposes APIs that scripts use to read the page or access a camera; a remote service exposes an API over the network. What unites them is the idea of a stable boundary: the implementation behind it can change as long as the interface keeps its promises.

How Applications Exchange Requests

A common API interaction has a caller and a provider. The caller issues a request naming an operation and supplying inputs; the provider processes it and returns a result or error. A local library may expose this as a function with arguments and a return value. Other APIs use callbacks, events or streams, so an immediate request-response exchange is a useful example rather than a universal rule.

Across a network the same pattern is carried by a protocol. HTTP, as specified in RFC 9110, is a stateless request-response protocol in which a client sends a message with a method and a target and the server replies with a status code and content. Other interfaces use gRPC, WebSocket messages or message queues, sometimes exchanging events rather than paired requests and responses. Network boundaries introduce latency and partial failures. Authentication and authorization matter too, although local APIs can also enforce permissions. These constraints explain rules about retries, timeouts and credentials.

The caller can usually use the documented contract without knowing the provider's internal implementation. A weather API returns a forecast; whether the provider computes it, buys it or caches it is invisible. The interface hides implementation details while exposing the information a caller needs: expected inputs, available operations, results and documented failure behavior.

Endpoints, Inputs and Responses

In an HTTP API, an API endpoint is an address through which a resource or operation is reached. Documentation commonly identifies an operation by its path and HTTP method. A request to such an endpoint carries several parts:

  • the method, such as GET to retrieve a representation or POST to submit data for processing, which signals intent;
  • the path and query parameters, which identify the resource and filter or page through results;
  • headers, which carry metadata such as content type, accepted formats and authentication tokens;
  • an optional body, typically JSON, holding the data to be created or changed.

The response mirrors it: a status code summarizing the outcome, headers describing the payload, and a body with the requested data or a structured error. In a browser, the Fetch API exposes exactly this model. A call to fetch() returns a promise that fulfills with a Response object. Code can inspect its status and headers, then read the body separately as JSON or text. One detail trips up newcomers: a 404 or 500 status is still a completed response, so the promise fulfils and the code must check the status itself; network errors, cancellation and certain request failures can reject it.

For a local API, a function signature serves as an entry point rather than a network address. Parameters, return types and documented exceptions describe how it can be used. Across different API families, identify the entry points, data contracts and error behavior without assuming that every interface is an HTTP endpoint.

Families of APIs

FamilyWhere the boundary sitsExample
System and OS APIsBetween a program and the operating systemFile, process and network calls
Library and framework APIsBetween a program and code it links or importsA JSON parser's functions
Browser (web platform) APIsBetween page scripts and browser or device capabilitiesDOM, Fetch, Geolocation, Web Audio
Remote web APIsBetween a client and a service over a networkPayment, mapping or storage services
Hardware and driver APIsBetween software and a deviceGPU graphics interfaces

Browser APIs deserve a note because they are what most web developers meet first. MDN groups them by shared principles: they are object-based, they have recognizable entry points such as the document object or an AudioContext, they often signal state changes through events, and sensitive ones add security gates such as HTTPS-only availability or runtime permission prompts. REST, GraphQL and similar styles describe conventions for remote web APIs specifically; they are design patterns within one family rather than definitions of the whole concept.

APIs vs User Interfaces and SDKs

A user interface presents capabilities to a person through screens, buttons and text. The person interprets labels and responds to feedback. An API presents the same or similar capabilities to a program, so it must be exact: field names, types, error codes and ordering all matter, and a small incompatible change can break callers that depend on the previous contract. Many products offer both, with the interface built on top of the same API that external developers use.

An SDK (software development kit) is a package of tools for working with an API from a particular language or platform: client libraries that wrap the raw calls, authentication helpers, sample code and documentation. The SDK is a convenience layer; the API is the contract underneath. A service can have one API and several SDKs, and a developer can often call a documented network API directly without its SDK. For other platforms, the SDK may be the supported way to access an interface.

Common Uses and Limitations

APIs are the standard way to automate work that would otherwise require clicking through an interface: pulling reports, syncing records between systems, posting content to several platforms, or driving a browser through an automation protocol. For data collection, an official API is usually preferable to scraping the HTML of a site, because the data arrives structured, the terms of access are explicit and the format is less likely to change without notice.

The limitations follow from the fact that someone else owns the contract. Most remote APIs require an API key or token and enforce rate limits, so volume is bounded by the provider's policy. Versions are deprecated and endpoints retired, forcing callers to update. An API exposes only what its owner chose to expose, which may be less than the user interface shows. Network latency, availability and usage charges can also influence the design of an integration. None of this makes APIs unreliable, but it does mean that building on an API is building on a relationship with its provider.

Frequently asked questions

Are all APIs web APIs?

No. Web APIs reached over HTTP are one family. Operating systems, programming libraries, browsers and hardware drivers all expose APIs that never touch a network. The common element is a documented interface between two pieces of software, not the transport used to reach it.

Is an API the same as an SDK?

No. An API defines the operations and rules that software exposes. An SDK packages development tools, libraries and examples for a platform or interface. Some documented APIs can be called directly without an SDK; others are normally accessed through the supported kit.

Does an API always require a key?

No. Many local library functions require no key, and some public web APIs accept anonymous requests. Many remote services do require an API key or token to identify the caller, apply rate limits and bill usage, so authentication is a policy decision by the provider.

What is an API endpoint?

For a network API, an endpoint is an address through which a service can be reached. HTTP API documentation commonly pairs a URL path with a method to describe a particular operation. Other API types use entry points such as functions or message handlers instead.

What is the difference between an API request and an API response?

In a request-response interface, the request expresses what the caller wants and supplies its inputs. The response reports an outcome, data or an error. Some APIs also use asynchronous events and streams, so not every interaction follows a single request followed by one final reply.