What is an API?
Author: Domeny.ForSale editorial team Published
In brief: An API is a programming interface: a set of rules that allows one program to use another program’s data or functions. For example, it can retrieve a weather forecast for an application, pass an order to a warehouse management system, or request the creation of a shipping label. An API defines which operations are available, how to call them, and how to interpret the result.
How does an API work in practice?
API stands for Application Programming Interface. Here, an interface means a way for software components to communicate, rather than a screen with buttons. A user interacts with an application through a form or menu, while a program can use another system through its API.
You can compare an API to an order form: it specifies what can be ordered, which information must be supplied, and what confirmation to expect. You do not need to know how a warehouse is organised internally to place a valid order. Likewise, an application does not need to know how another system stores data or performs calculations.
In a typical web API, communication works as follows:
- The application sends a request, asking for data or for an operation to be performed.
- The receiving system checks whether the request is valid and, if required, checks the sender’s permissions.
- The system performs the operation and sends back a response containing the result or information about an error.
Not every API works over the internet. Operating systems and libraries—ready-made collections of functions used in programming—also provide programming interfaces. However, in discussions about connecting services, the term “API” most often refers to network communication.
Example: a store requests a parcel shipment
Imagine an online store connected to a courier company’s system. Once an order has been paid for, the store’s software sends the information needed to ship the parcel through the API, such as the recipient’s address, the selected service, and the parcel’s specifications. The courier system may return a tracking number and a label to print.
An employee then does not have to enter the same information again in the carrier’s dashboard. Later, the store can retrieve the shipment status and display it to the customer. The available actions and required data depend on the particular API.
However, a carrier making an API available does not mean that a store will automatically start using it. An integration is needed: a configured connection between the systems, using a ready-made plugin, an automation service, or a separate program. The API makes communication possible, while the integration carries out a specific business process.
What do endpoint, HTTP, and JSON mean?
Web API documentation often mentions an endpoint: a specific address where a particular function or resource is available. For example, the path /produkty/123 might point to data for the product with the identifier 123. This is an illustration—the actual addresses are defined by the service provider.
Many such interfaces use HTTP, the communication protocol also used by websites. A request contains a method specifying the type of action. The GET method is used to retrieve data, while POST is often used to send it, for example when creating an order.
The response may be written in JSON, a text-based data format that programs can read. A simple result might look like this: {"id":123,"name":"Mug","available":true}. The application reads the fields and uses them to display the product name and availability information.
An API also provides information about errors. In HTTP communication, the code 404 usually means that the specified resource was not found, while 429 means that the permitted request rate has been exceeded. A properly implemented integration must also handle missing responses, service unavailability, and invalid data, rather than assuming that every operation will succeed.
Do you need to code to use an API?
If a ready-made plugin supports the service you need, using an API may simply involve connecting accounts and configuring a few options. Automation tools also allow you to create simple workflows without writing code, such as passing enquiries from a form to a customer service system.
A developer is usually needed when no ready-made connection is available or the process requires custom logic. One example is synchronising stock levels from several sources, which requires resolving conflicting data and safely retrying failed operations.
Manual file exports and imports can sometimes be an alternative to an API. This may be sufficient for occasional exchanges of small amounts of data. An API makes more sense when exchanges are frequent or data should reach the other system without someone manually starting an export.
What should you check before connecting services?
API access is not necessarily public or free. It often requires an API key or token: credentials used to authorise access. Confidential keys should not be included in a website’s public code or sent to people who do not need them.
Before implementation, check the provider’s official documentation and terms for:
- Functionality: whether the API allows you to perform the required operations, rather than only read data.
- Costs and limits: whether access requires a particular plan and how many requests you can send.
- Permissions: whether access can be restricted to only the necessary data and actions.
- Maintenance: how the provider communicates changes and the retirement of older API versions.
Start by describing one task, such as “create a shipment once the order has been paid for”. Then check whether a ready-made integration exists and, if not, whether the APIs of both systems provide the functions needed to complete that task.
See also: What is 2FA?
