TR/EN
Blog

What Is an API? What It Does and How It Works

Published: · 9 min read

When you tap "Sign in with Google" in an app, check where your package is on an online store, or open a weather app, the same thing happens behind the scenes: one piece of software is talking to another through an API. So what is an API, how does it work and why does it matter so much? In this post we explain it so that even non-technical readers can follow, with examples and tables.

What Is an API?

API stands for Application Programming Interface. In short, it's a set of rules describing how two pieces of software talk to each other.

The most common analogy is a restaurant: you (the customer) don't walk into the kitchen and cook the food yourself. You tell the waiter what you want from the menu, the waiter passes the order to the kitchen and brings the food back to you. The waiter is the API. The menu is the API's documentation: it shows what you can ask for and how to ask for it. You don't need to know what's going on in the kitchen.

Everyday API Examples

  • Weather apps: They don't measure the weather themselves, they pull data from a weather service's API.
  • Online payments: The store sends your card details to a payment provider's API and gets back "approved" or "declined".
  • Maps: The "find our store" map on a website is shown through a map service's API.
  • "Sign in with Google / Apple": Authentication happens through that service's API.
  • Package tracking: The store asks the shipping company's API about your tracking number and shows you the latest status.

How Does an API Work?

Most modern APIs work over HTTP, the same protocol the web uses. The logic is simple:

  1. The client (an app, a website or another server) sends a request to a specific address.
  2. The server receives the request, checks permissions and does the work (reading from a database, creating a record, etc.).
  3. The server sends back a response; usually data in JSON format plus a status code describing the result.

The Parts of an API Request

PartWhat it's forExample
Endpoint (URL)The address the request goes tohttps://api.example.com/v1/orders/1042
HTTP methodSays what you want to doGET, POST, DELETE...
HeadersExtra info like authentication and data formatAuthorization: Bearer ...
BodyThe data being sent (usually JSON){"name": "Alice"}
Status codeTells you the result in the response200, 404, 500

HTTP Methods

MethodWhat it doesExample
GETReads dataFetching an order's details
POSTCreates a new recordPlacing a new order
PUTReplaces a record entirelyChanging the whole address
PATCHUpdates part of a recordChanging just the phone number
DELETEDeletes a recordCancelling an order

Common Status Codes

CodeMeaningWhen you see it
200 OKSuccessThe request was processed fine
201 CreatedCreatedA new record was created
400 Bad RequestBad requestMissing or badly formatted data
401 UnauthorizedNot authenticatedNo API key, or an invalid one
403 ForbiddenNot allowedYou're authenticated but not permitted to do this
404 Not FoundNot foundNo such record or address
429 Too Many RequestsToo many requestsUsage limit (rate limit) exceeded
500 Internal Server ErrorServer errorThe problem is on the server side

An Example Request and Response

Let's ask for an order's details from the command line with curl:

curl -H "Authorization: Bearer YOUR_API_KEY" \
     https://api.example.com/v1/orders/1042

The server's response would be JSON along these lines:

{
  "id": 1042,
  "status": "shipped",
  "total": 349.90,
  "currency": "USD",
  "items": [
    { "product": "Keyboard", "quantity": 1 }
  ]
}

The app takes this data and shows "Your order has shipped" on screen. That's all you see; the API handles everthing behind it.

Types of APIs

TypeData formatKey traitWhere it's used
RESTUsually JSONSimple, widespread, built on HTTP methodsMost web and mobile apps
GraphQLJSONThe client asks for exactly the fields it wantsComplex interfaces, mobile apps
SOAPXMLStrict rules, old but still commonBanking, enterprise and government systems
gRPCProtocol Buffers (binary)Very fast, small payloadsCommunication between microservices
WebSocketFree-formAlways-open, two-way connectionLive chat, instant notifications, market data

APIs by Who Can Use Them

TypeWho uses itExample
Public APIAnyone, usually with an API keyWeather, map services
Partner APIOnly contracted business partnersShipping or payment integrations
Internal (private) APIOnly the company's own systemsA mobile app talking to its own backend

API Security

APIs are doors to your data, so security really matters. The basics:

  • API keys: A secret key that identifies who's making the request. Don't hard-code it and push it to places like GitHub; use environment variables or a secrets manager.
  • OAuth 2.0 and tokens: The standard for granting limited, time-bound access on a user's behalf ("Sign in with Google" uses it).
  • HTTPS: All API traffic should be encrypted; sending keys over plain HTTP is like leaving the door open.
  • Rate limiting: Capping how many requests can be made in a given time to prevent abuse and overload.
  • Least privilege: Give each key only the permissions it needs; don't give delete rights to an integration that only reads.

APIs and AI

Today, the most common way to add AI to a product is also through an API. Large language model providers offer their models as APIs; you send text, the model sends back an answer. Even when you run an open-source model on your own server (e.g. with Ollama), you still use it through an API. We cover how to do that in our how AI runs on a virtual server post. For integrating AI into your existing systems, check out our AI service.

Where Should You Run Your Own API?

When you write an API for your own app, you need a server that keeps it up 24/7. Roughly, your options are:

  • A virtual server: Whatever language you used, Node.js, Python, PHP, Go..., you can run it directly. The most practical start for small to mid-size APIs. VECDC virtual servers come with NVMe storage, start at $6/month and are ready in about 5 minutes.
  • With Docker: Package your API as a container and run it the same way everywhere. Developer VDS, delivered with Docker installed, is ideal for this.
  • With Kubernetes: If you want a setup that scales automatically with traffic and updates without downtime, you can start with Kubernetes Server.

Frequently Asked Questions

What's the difference between an API and a web service?

A web service is a type of API that's accessed over a network (usually HTTP). So every web service is an API, but not every API is a web service; for example, the interfaces an operating system or software library provides are APIs too, but they don't run over a network.

What is a REST API?

REST is an API design approach that uses HTTP methods (GET, POST, PUT, DELETE) and accesses resources through URLs. Data is usually carried as JSON. It's the most common type of API in web and mobile apps today.

What is an API key?

An API key is a secret code that identifies the application sending requests to an API. The provider uses it to track who makes how many requests and to block unauthorized access. Keep it like a password and never hard-code it into code that ends up in public places.

Is using an API free?

It depends. Many APIs are free up to a certain usage limit and are billed by requests or usage beyond that. A company's own internal APIs only cost whatever the server they run on costs.

In Short

An API is an interface that lets pieces of software talk to each other. You send a request, the other side does the work and sends back a response; you don't need to know what happens in the kitchen. Almost every app we use today runs on dozens of APIs working together. If you'd like help shipping your own API or connecting your systems, drop us a message and lets take a look together.

Your Virtual Server, Ready in 5 Minutes

NVMe virtual servers with dedicated resources start at $6/month.

See Packages →