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.

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.

Often compared

See also

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

Read a random page
Open today's review
Switch to the dark theme
Read this page in Türkçe

More

Settings