Technology explained
What Is an API? A Plain-English Explanation With Examples
An API is an agreed way for one piece of software to ask another for data or an action, and to get a structured answer back. Apps use APIs to show weather, maps and payments without building those systems themselves.
By CodingMarble · Published · 5 min read

The restaurant analogy
API stands for application programming interface. The words are unhelpful, so use a restaurant instead. You sit at a table, which is your app. The kitchen is a service that can prepare things you cannot make yourself. You do not walk into the kitchen and cook. You read a menu, tell a waiter what you want, and the waiter returns with a plate. The menu lists what you may order, the waiter carries requests and results, and the kitchen stays hidden.
An API is the menu and the waiter together. It defines which requests are allowed, what information each one needs, and what shape the answer will take. The company behind the service can rebuild its kitchen completely, and as long as the menu stays the same, your app keeps working. That separation is the whole point: one side does not need to know how the other is built.
Real examples you already use
A weather widget on a news site rarely has its own weather stations. It sends the name of a city to a weather service's API and receives temperature and conditions to display. A restaurant website that shows a map is not drawing roads itself. It asks a mapping service to draw a map around a location and to calculate routes. A shop that takes card payments does not store card details on its own server. It passes the order total to a payment provider's API, which handles the sensitive part and reports back whether the payment succeeded.
The same idea works inside a single company too. A mobile app and a website often talk to the same backend through an internal API, so both show the same orders and profile. The difference is only who is allowed to call it. If you are curious how designers choose between styles of API, the comparison of REST and GraphQL covers that decision.
Request, response and JSON
Most web APIs work over HTTP, the same protocol browsers use. The app sends a request containing an address (a URL), a method such as GET to read data or POST to create it, and sometimes extra details. The service sends a response with a status code and a body. For APIs, that body is usually JSON, a plain-text format for structured data that humans can read and programs can parse easily.
{
"city": "Pune",
"temperature_c": 29,
"condition": "Partly cloudy",
"updated_at": "2026-11-27T09:30:00Z"
}JSON is built from named fields and values, in curly braces for an object and square brackets for a list. Because both sides agree on this shape, the app can pick out temperature_c and display it without guessing. Every real API publishes documentation that lists the available endpoints, the information each needs, the fields it returns and the errors it may give.
API keys and why they are secret
Many services need to know who is calling. They issue an API key, a long random string that you send with each request, often in a header. The key identifies your account, so the provider can apply the right permissions, count usage and block abuse. If someone else gets your key, they can make requests as you. Depending on the service, that can mean running up usage on your account, reading private data or changing things.
So keys are treated like passwords. They should live in server-side configuration, never be typed into a public repository, and never be placed in code that runs in a visitor's browser, where anyone can open developer tools and read them. If a key leaks, the usual response is to revoke it in the provider's dashboard and create a new one. Some keys are deliberately designed for browser use and are restricted by website address or by action, so read what the provider says about each kind.
Practical tip: keep keys in environment variables, add the file that holds them to your ignore list before the first commit, and give each key the narrowest permissions the provider offers. Check the provider's documentation for how to rotate a key without downtime.
REST in one paragraph
REST is a popular style for designing web APIs rather than a product or a standard you install. In a REST API, each kind of thing, such as an order or a user, has its own address, and the HTTP method says what to do with it: GET reads, POST creates, PUT or PATCH changes, and DELETE removes. Each request carries everything the server needs, so the server does not have to remember earlier calls, and responses use ordinary status codes such as 200 for success and 404 for not found. Designers follow these conventions loosely, so always rely on the specific API's documentation. Our guide on API design principles goes deeper.
A tiny fetch example
Here is how a script asks an API for data. The address and field names are placeholders, so substitute the ones from a service's documentation. The function checks that the response was successful before reading it, because a failed call still returns something and your code should not treat it as good data.
async function showWeather(city) {
const url = "https://api.example.com/weather?city=" + encodeURIComponent(city);
try {
const response = await fetch(url);
if (!response.ok) {
throw new Error("Service replied with status " + response.status);
}
const data = await response.json();
console.log(data.city + ": " + data.temperature_c + " C, " + data.condition);
} catch (error) {
console.log("Could not load weather right now.", error.message);
}
}
showWeather("Pune");Notice that the code is written to cope with failure. That matters because real APIs are separate systems that you do not control.
When an API is down, and how apps combine APIs
An API can fail for many reasons: the provider has an outage, your key has expired, you sent too many requests too quickly, or the network dropped. A well-built app plans for this. It shows a clear message instead of a blank screen, retries after a pause for temporary errors, keeps the last good data where that is safe, and does not let one broken feature take down the whole page. Providers often publish a status page, which is the first place to check when something suddenly stops working.
Most modern products are combinations. A delivery app may use one API for maps, another for payments, another for sending text messages, and its own backend to tie them together. Each connection is a dependency, so it is sensible to ask what happens if any one of them disappears, how much each costs under real usage, and whether you could swap it for another provider without rewriting everything.
Keep reading
- Web developmentREST vs GraphQL: How to Choose an API StyleREST exposes many URLs that each return a fixed resource, while GraphQL exposes one endpoint where the client describes the exact shape of data it wants. For a small team with a handful of clients, REST is usually the simpler default; GraphQL pays off when many different screens or apps need different slices of the same data.
- Programming fundamentalsREST API Design Principles: Practical Rules With ExamplesA well-designed REST API models your data as nouns, uses HTTP methods and status codes the way clients expect, and behaves consistently for errors, pagination and versioning. The goal is that a developer who has never met your team can guess how the next endpoint works.
- Error fixesFix CORS Error: No Access-Control-Allow-Origin HeaderThe browser blocked a cross-origin request because the server's response did not include permission for your page's origin, in the form of an Access-Control-Allow-Origin header. The fix always lives on the server (or in a proxy you control), not in the front-end fetch call.
- Technology explainedHow the Internet Works, Explained Simply Step by StepWhen you type a web address, your device asks the Domain Name System for the server's numeric address, sends a request across many connected networks in small packets, and the server replies with files that your browser assembles into a page. Delays can come from any step, and the Network tab in your browser's developer tools lets you see each one.
Need this built properly for your business?
CodingMarble is a remote studio in India that builds websites, apps and games on fixed packages with the scope written down before payment. Try the free tools we run, or start a project when you are ready.