An API (application programming interface) is a set of rules that lets one piece of software ask another for data or to do something. When your online store takes a card payment, shows a Google Map or checks a courier's delivery status, it is using an API. Most web APIs work by sending a request to a URL and getting data back, usually in JSON format.
APIs are the reason modern software can be built quickly. Instead of building a payment system, a mapping service and an SMS network yourself, your website plugs into companies that already provide them.
The waiter analogy
In a restaurant you do not walk into the kitchen. You tell the waiter what you want, the waiter passes it to the kitchen and brings back your food. An API is the waiter. Your website (the customer) makes a request in an agreed format, the other system (the kitchen) does the work, and the API returns the result. You never need to know how the kitchen is organised.
APIs you already use every day
| When you… | An API is… |
|---|---|
| Pay by card on an online store | Sending the payment to a gateway and getting approval back |
| See a map on a contact page | Loading the map and your location from a mapping service |
| Log in with Google | Confirming your identity with Google without sharing your password |
| Get an SMS order confirmation | Asking an SMS provider to send the message |
| See live stock on a website | Fetching quantities from the shop's POS or ERP |
| Chat with an AI assistant on a site | Sending your question to an AI model and returning the answer |
How a web API request works
Most web APIs follow the REST style and use the same HTTP requests your browser uses. A request has four parts:
- The endpoint: a URL, such as
/api/products/42. - The method: what you want to do.
GETreads data,POSTcreates something,PUTorPATCHupdates it,DELETEremoves it. - Authentication: an API key or token proving who is asking.
- The data: for example the details of a new order.
The API replies with a status code (200 means OK, 404 means not found, 401 means not authorised) and the data, usually as JSON, a simple text format that both people and machines can read.
APIs vs webhooks
With an API, your system asks: "has this payment gone through?" With a webhook, the other system tells you the moment it happens: "payment succeeded for order 1042". Webhooks avoid checking over and over, so integrations that need to react quickly, such as payments and stock updates, often use both. We use this pattern when connecting online stores to POS and ERP systems.
Why APIs matter to your business
- Less manual work: orders, stock, invoices and customer details move between systems automatically.
- Faster builds: proven services for payments, maps, email and SMS are plugged in instead of built from scratch.
- Room to grow: a website with an API can later feed a mobile app, a partner's system or an AI assistant.
Questions to ask before relying on an API
- Is it documented and stable, or does it change often?
- What does it cost, and what are the usage limits?
- What happens to your website if the API goes down? Good integrations fail gracefully and retry.
- Where is your data stored, and who can access it?
Keeping APIs secure
- Keep API keys secret: in server settings, never in public JavaScript or shared documents.
- Give each key only the permissions it needs.
- Always use HTTPS.
- Rotate keys when staff or agencies change.
For how the pieces of a web system fit together, read frontend vs backend development explained.
Frequently asked questions
What does API stand for?
API stands for application programming interface. It is a defined set of rules that lets one piece of software request data or actions from another, without needing to know how the other system works inside.
What is a REST API?
A REST API is the most common style of web API. It uses standard web requests (such as GET to read data and POST to create it) sent to specific URLs, and usually returns data in JSON format.
What is the difference between an API and a webhook?
With an API, your system asks another system for information when it needs it. With a webhook, the other system automatically notifies yours when something happens, such as a payment succeeding. Many integrations use both.
Are APIs secure?
They can be. A well-built API requires authentication such as an API key or token, uses HTTPS, limits what each key can do and limits how many requests can be made. API keys should never be shared publicly or placed in frontend code.
Do APIs cost money?
Some are free, many are free up to a usage limit, and others charge per request or per month. Maps, SMS, AI and some data services commonly charge based on usage.
Sources and further reading
- Introduction to web APIs (MDN Web Docs)
- HTTP request methods (MDN Web Docs)
- About webhooks (GitHub Docs)
Need a website built properly?
Engage Lanka designs and builds fast, SEO-ready websites in Kandy for businesses in Sri Lanka and abroad, from LKR 55,000 for a 5-page site to custom booking and multilingual sites from LKR 250,000. You own the domain, hosting and code.