Skip to main content

API

Application Programming Interface

Updated 1 min read

Share this page

Send the link, quote the definition with a link back, or show it as a card on your own site.

https://softwaredictionary.org/terms/api

In short

An API is a set of rules that lets one piece of software request data or actions from another in a predictable, documented way.

What is an API?

An API is a contract: it describes which operations a piece of software offers to others and exactly how to call them. As long as the caller follows those rules, it can use the functionality without knowing anything about how it works inside.

A common analogy is a waiter in a restaurant. You don't walk into the kitchen; you give your order to the waiter, who brings back the result. On the web, the order is usually an HTTP request and the result is usually data in JSON format.

APIs are not limited to web services. The functions an operating system exposes for reading files, or the public methods of a library, are APIs too.

How it works

  1. Your code sends a request

    It calls an address the API documents and says what it wants.

    GET /v1/weather?city=Paris
  2. The API checks it

    It checks your key and that the request follows its rules.

    X-API-Key: 4f9a…
  3. The provider does the work

    Behind the API, the provider's own code and databases find the answer. You never see them.

  4. You get the answer

    It comes back in the agreed format, usually JSON, with a status code that says how it went.

    200 OK {"temp": 18}

Often misunderstood

You might think: An API is a website or a server.

In fact: An API is a contract: the requests a piece of software accepts and the answers it gives back. It is often a web service, but a library or an operating system offers an API to your code too.

At a glance

Your app sends the request GET /users/42 to an API, which lists the operations it offers; the service's code and database stay hidden behind it, and the API sends back the JSON response { "name": "Ada" }.Inside the serviceGET /users/42{ "name": "Ada" }Your appthe callerAPIdocumented operationsGET /users/:idPOST /ordersDELETE /orders/:idCodeDatabaseall the caller seeshidden from the caller
The caller only follows the documented operations; how the service does the work inside stays hidden and can change freely.

Key takeaways

  • An API defines how two pieces of software communicate.
  • Callers don't need to know the internal implementation.
  • Web APIs usually work over HTTP and return JSON.
  • Libraries and operating systems expose APIs too, not just web services.

Example

Fetching data from a web APIjavascript
// Ask the API for a user's details
const response = await fetch("https://api.example.com/users/42");
const user = await response.json();

console.log(user.name);

Readers ask

Is an API the same as a REST API?

No. API is the general concept; a REST API is one style of API built on HTTP that follows REST principles.

What is an API key?

An API key is a secret value sent with requests so the API can identify the caller and control or limit access.

See also

Free · once a week

Software and AI, explained once a week

The week's software and AI news with every term explained, plus a term to learn and a quick quiz. A two-minute read.

You confirm by email first, and one click unsubscribes. Privacy

See this week's issue

About this page

Page history

  1. Added "How it works": an API call from request to answer, and what an API really is.

Changes that altered what this page says. Typo fixes are not listed.

Spotted a mistake or something missing on this page?Suggest an edit

How pages are made

More

Settings