What Is an API? A Simple Guide for Beginners
APIs power almost every app you use. Learn what an API is, how a request and response work and how to call one yourself, in plain English.
- An API (Application Programming Interface) is a set of rules that lets one program talk to another.
- Most web APIs use HTTP requests and return JSON.
- Common methods are GET, POST, PUT, PATCH and DELETE; status codes tell you what happened.
- You can call a public API with a browser, curl, Postman or a few lines of code.
When you check the weather on your phone, pay with a card or log in with Google, apps are talking to each other behind the scenes. So, what is an API? It is the way they talk to each other.
If you are learning to code or test software, the question “what is an API?” comes up quickly. The jargon makes it sound harder than it is.
In this guide you will learn what an API is in plain English, how requests and responses work, the main API types, and how to make your first call.
What is an API?
An API, short for Application Programming Interface, is a contract that describes how one piece of software can ask another for data or actions. The provider decides what you can ask for and in what format; you do not need to know how it works inside. The AWS overview of APIs gives a good vendor-neutral summary.
The restaurant analogy
Think of a restaurant. You (the client) read the menu, tell the waiter (the API) what you want, and the waiter takes the order to the kitchen (the server). The kitchen prepares the food and the waiter brings it back. You never enter the kitchen, and the kitchen only accepts orders from the menu.
How an API works: request and response
- The client (your app) sends a request to a URL called an endpoint.
- The request includes a method, headers and sometimes a body with data.
- The server checks the request, runs the logic and talks to a database if needed.
- The server sends back a response with a status code and usually JSON data.
Here is a simple response from a “get user” endpoint:
{
"id": 1,
"name": "Asha Patel",
"email": "asha@example.com",
"active": true
}
Types of APIs
| Type | What it is | Typical use |
|---|---|---|
| REST | Resources at URLs, standard HTTP methods, usually JSON | Most public web APIs |
| GraphQL | One endpoint where the client chooses the fields | Apps needing flexible data shapes |
| SOAP | XML messages with strict contracts | Older enterprise and banking systems |
| gRPC | Fast binary calls between services | Microservices |
| Webhooks | The server calls you when an event happens | Payment or deploy notifications |
Beginners should start with REST. Read our REST API best practices guide when you are ready to design your own.
HTTP methods and status codes
| Method | Meaning | Example |
|---|---|---|
| GET | Read data | GET /users/1 |
| POST | Create something | POST /users |
| PUT | Replace something | PUT /users/1 |
| PATCH | Update part of something | PATCH /users/1 |
| DELETE | Remove something | DELETE /users/1 |
| Code | Meaning |
|---|---|
| 200 OK | Request succeeded |
| 201 Created | A new resource was created |
| 400 Bad Request | Your request was invalid |
| 401 / 403 | Not logged in / not allowed |
| 404 Not Found | The resource does not exist |
| 500 Server Error | Something broke on the server |
MDN lists every code in its HTTP status reference.
Try an API yourself
The free JSONPlaceholder service provides fake data for practice. Open this link in a browser to make a GET request: https://jsonplaceholder.typicode.com/users/1.
With curl
curl https://jsonplaceholder.typicode.com/users/1
With JavaScript
const res = await fetch('https://jsonplaceholder.typicode.com/users/1');
const user = await res.json();
console.log(res.status, user.name);
With Python
import requests
res = requests.get("https://jsonplaceholder.typicode.com/users/1")
print(res.status_code, res.json()["name"])
To create data, send a POST request with a JSON body:
curl -X POST https://jsonplaceholder.typicode.com/posts \
-H "Content-Type: application/json" \
-d '{"title":"Hello","body":"My first API call","userId":1}'
Quick tip: Prefer a visual tool? Our API testing with Postman guide shows how to send requests, add auth and write checks.
API keys and security basics
Many APIs require authentication so the provider knows who is calling. Common methods are API keys, bearer tokens and OAuth. Keep these simple rules in mind:
- Never put secret keys in front-end code or public repositories.
- Store keys in environment variables or a secrets manager.
- Always use HTTPS.
- Respect rate limits to avoid being blocked.
- Give each key only the permissions it needs.
Using Python? Our Python tutorial for beginners covers the basics you need for the example above.
Final thoughts
So, what is an API? It is a clear, agreed way for software to ask other software for something. Once you understand requests, responses, methods and status codes, most web APIs feel familiar. Make a GET request to the practice API today, then try a POST, and you will have the core skill that developers and testers use every day.
Frequently asked questions
What is an API in simple words?
An API is a set of rules that lets two programs communicate, like a waiter who carries your order to the kitchen and brings back your food.
What is the difference between an API and a REST API?
API is the general idea. A REST API is a specific style that uses URLs for resources and standard HTTP methods, usually returning JSON.
Do I need to code to use an API?
Not always. Tools such as a browser, curl or Postman let you send requests without writing a program.
What is an API endpoint?
An endpoint is the URL where an API receives requests, for example https://api.example.com/users.
Are APIs free?
Some are free, some have free tiers with limits, and others are paid. Always read the provider’s pricing and terms.
Keep learning
Need help with testing, WordPress or SEO?
We help teams ship better software and grow their sites. Tell us what you are working on and we will suggest a clear next step.