What Is a RESTful API? A Simple Guide With Examples
You have seen the term “REST API” in a job post, a tutorial, or a product page. It sounds technical, like something only developers need. But you use REST APIs every day, even if you never see them: when your weather app shows the forecast, a REST API fetched that data, and when you book a flight online, a REST API checked the seats.
In this guide, I will explain what a restful api is in plain words: the six rules behind it, the verbs it uses, and how to read its answers.
A RESTful API is a set of rules that lets one program ask another program for data over the web, using standard web requests. It uses verbs like GET and POST, returns data in a clear format, and follows six rules that keep it simple, fast, and easy to scale.
What an API Is in Plain Words
An API is a waiter in a restaurant: the kitchen is the program that holds the data, and you never walk in. You tell the waiter what you want, and the waiter brings back your food. You never see how the kitchen works.
That is what an API does. API stands for Application Programming Interface: rules that let one program talk to another. Your app is the customer, the other program is the kitchen, and the API is the waiter in the middle.
You do not need to know how the kitchen cooks — only how to place an order. That is the point of an API: it hides the hard work and gives you a simple way to ask for what you need.
The Main API Types
Not all APIs work the same way. Here are the main types of api you will hear about:
- REST: The most common type, using standard web requests.
- SOAP: An older, stricter type with a fixed format and many rules. It is common in banks and large firms.
- GraphQL: A newer type: ask for exactly the fields you want, no more and no less.
- RPC: A simple type: you call a function on the other program, like asking a friend to do one job.
An API is not the page you see — the page is built with HTML and CSS. If you have ever wondered what is cascading style sheet, here is the plain-words answer: CSS is the style layer that makes a page look good. The API fetches the data behind the page, and the page shows it.
What Makes an API RESTful

REST stands for Representational State Transfer. It is a style, not a strict law: an API is RESTful when it follows the rules Roy Fielding described in his dissertation (2000).
Think back to the restaurant: a RESTful API is a restaurant with a clear menu, where every dish has a name and every order uses the same words.
The word “resource” is key here: a resource is a thing the API can give you, like a user, a weather forecast, or a blog post. Each resource has its own address, called an endpoint. For example, /users/123 is the endpoint for user 123.
To learn more, read Amazon’s RESTful API explainer.
The Richardson Maturity Model in Plain Words
The Richardson Maturity Model is a scale with four levels, from 0 to 3, showing how RESTful an API really is.
- Level 0: One endpoint for everything.
- Level 1: A different endpoint for each resource, but no clear order words.
- Level 2: The right verbs (GET, POST, DELETE) and the right status codes — where most good APIs live.
- Level 3: Links to related actions too.
The Six Rules That Define REST
REST has six rules, called constraints:
1. Client-Server
The client (your app) and the server (the program that holds the data) are separate and only talk through the API, so either side can change safely.
2. Stateless
Stateless means the server does not remember you: each request is a fresh start and must carry all the facts the server needs.
3. Cacheable
Cacheable means the answer can be saved and reused: ask for the same forecast twice, and the second answer can come from the saved copy. That is faster.
4. Uniform Interface
Uniform interface means every request follows the same pattern — the same verbs, URL style, and answer format. That makes the API easy to learn.
5. Layered System
Layered system means the API can sit behind other layers, like a security check or a load balancer, and you never need to know how many there are.
6. Code-on-Demand (Optional)
Code-on-demand is the only optional rule: the server can send you a small piece of code to run. Most APIs skip it, and that is fine.
HTTP Methods: The Verbs of a REST API
Every REST API call uses a verb that tells the server what to do. There are five main verbs.
| Method | What it does | Example |
|---|---|---|
| GET | Read data | GET /users/123 — get user 123 |
| POST | Create data | POST /users — create a new user |
| PUT | Replace data | PUT /users/123 — replace user 123 |
| PATCH | Update part of data | PATCH /users/123 — change the email only |
| DELETE | Remove data | DELETE /users/123 — delete user 123 |
The URL is a noun and the verb is the action — that is the REST pattern. You never put the verb in the URL; you use the HTTP method instead: GET /users/123, not /getUser/123.
How a REST API Call Works, Step by Step

Here is a full example: you open a weather app and want the forecast for your city.
Step 1: You Make a Request
Your app sends a request to the API with three parts — the verb, the endpoint, and any extra facts. For the weather, it might look like this:
GET https://api.weather.example/forecast?city=London
The verb is GET, the endpoint is the forecast, and the city is the extra fact.
Step 2: The Server Checks the Request
The server reads the request and checks your API key, the endpoint, and the facts. If anything is wrong, it sends back an error.
Step 3: The Server Fetches the Data
The server looks up the forecast and builds the answer in JSON, a plain text format that uses keys and values, like this:
{ "city": "London", "temperature": 18, "condition": "Cloudy" }
That is the whole answer.
Step 4: You Get a Response
The server sends back the answer, plus a status code that tells you if the call worked.
Your app reads the JSON and shows “18°C, Cloudy” on the screen. You never see the API call, but it happened.
Try It Yourself
You can test a GET request from a plain HTML file. First, learn how to create an html file: open a text editor, type a simple page with a fetch call, save it as test.html, then open it in your browser. The page will call the API and show the answer.
Status Codes: Reading the Answer
Every API answer comes with a status code — a number that tells you what happened. Here are the ones you will see most often.
| Code | Meaning | What it means for you |
|---|---|---|
| 200 OK | It worked | Your request worked. Here is the data. |
| 201 Created | It was made | Your new item was created. |
| 400 Bad Request | Your request was wrong | Check your facts and try again. |
| 401 Unauthorized | You are not logged in | Check your API key or login. |
| 404 Not Found | It does not exist | The resource is not there. Check the URL. |
| 500 Internal Server Error | The server broke | It is not your fault. Try again later. |
Codes that start with 2 mean success, 4 means your mistake, and 5 means the server’s mistake. That is the simple rule.
REST vs SOAP vs GraphQL
REST is not the only choice. Here is how it compares.
| REST | SOAP | GraphQL | |
|---|---|---|---|
| Format | JSON, simple | XML, strict | JSON, exact fields |
| Rules | Flexible style | Strict protocol | Flexible query |
| Best for | Most web apps | Banks, large firms | Apps that need exact data |
| Learning curve | Easy | Hard | Medium |
SOAP is a strict XML protocol: many rules, harder to learn, but very safe, which is why banks use it. GraphQL lets the client ask for exactly the fields it wants — a name and an email, say, and nothing else. REST gives you the whole resource.
For most new projects, I recommend REST — simple, well known, and working with the tools you already have.
Where REST APIs Show Up Every Day
REST APIs are everywhere — you use them all day without noticing.
- Weather apps: Your app asks a weather API for the forecast.
- Maps: Your map app asks an API for directions.
- Social media: Your feed is data from an API, and your post goes out through one.
- Online shops: When you search for a product, an API fetches the list, and when you pay, an API talks to the payment service.
- Travel: When you book a flight, an API checks the seats.
Behind each of these, the API talks to a database, where the data lives. Here is the short version: sql vs mysql — SQL is the language you use to ask a database for data, and MySQL is one database that speaks SQL.
There are many types of databases. The two main kinds are relational and document: a relational database stores data in tables with rows and columns, while a document database stores data in flexible documents, like JSON. The API just asks, and the database answers.
Common REST API Mistakes to Avoid
Here are the mistakes I see most often.
Using Verbs in URLs
Do not put the action in the URL — use the HTTP method instead: GET /users/123, not /getUser/123.
Ignoring Status Codes
Do not ignore the status code: 200 means it worked, 404 means it is not there, and 500 means the server broke.
Forgetting Authentication
Most APIs need a key, a secret code that proves who you are. Keep it secret — if it leaks, anyone can use your account.
Returning Too Much Data
Send only what was asked for, not the whole database.
No Versioning
When you change an API, keep the old version working with a version in the URL, like /v1/users, so old apps do not break.
Good api governance is the habit of keeping an API healthy: clear keys, versioning, rate limits, and good docs. It is not glamorous, but it is what keeps an API working for years.
FAQs
What does REST stand for?
REST stands for Representational State Transfer, a style for building APIs that Roy Fielding described in his dissertation (2000).
The “state transfer” part means the server sends you a resource’s state as data, usually in JSON.
Is a REST API the same as an API?
No. An API is any way one program talks to another, and a REST API is one type that follows the REST rules.
Think of it like this: “API” covers all restaurants, while “REST API” is one type with a clear menu. All REST APIs are APIs, but not all APIs are RESTful.
Do I need to know Java or JavaScript to use a REST API?
No. You do not need Java or JavaScript to use a REST API — only to know how to send a request and read the answer. Tools like Postman let you do that with clicks.
The question usually comes down to java vs javascript: two different languages, and either one can call an API. Pick the one you already know.
What is the difference between REST and SOAP?
REST is a flexible style using standard web requests and JSON, while SOAP is a strict protocol using XML and many rules. REST is simpler and easier to learn.
SOAP is common in banks and large firms because it is very safe and strict.
What is JSON and why do REST APIs use it?
JSON is a plain text format for data that uses keys and values, like { "city": "London", "temperature": 18 }. It is easy to read and easy for programs to parse.
REST APIs use JSON because it is light, simple, and works in every language.
How do REST APIs keep data safe?
REST APIs keep data safe with API keys, tokens, and HTTPS: a key proves who you are, a token proves you are logged in, and HTTPS encrypts the data.
Never share your key, use HTTPS for every call, and only ask for the data you need.
What is an API key?
An API key is a secret code that proves who you are, sent with each request. The server checks it and decides if you can use the API.
Think of it as a password for your app.
When should I not use REST?
Do not use REST for real-time data, like a live chat or a stock ticker. REST is request and answer, not a constant stream of updates.
Also, do not use REST if you need exact fields every time — GraphQL is better — or a strict contract, where SOAP may fit better.
How do I test a REST API without writing code?
Use Postman, a free tool for sending requests with clicks: type the URL, pick the verb, and click Send. Postman shows you the answer.
You can also test in your browser: paste a GET URL into the address bar to see the JSON answer.
What to Try Next
You now know what a REST API is, how it works, and how to read its answers.
First, open Postman and send a GET request to a free public API. Look at the JSON answer and find the status code — that one test will make the whole idea click.
Next, try the HTML file test from section 5: build a small page, call the API with fetch, and show the answer on the page.
Finally, read Kong’s guide to RESTful APIs for a deeper look at the same ideas.
REST sounds technical, but it is just a waiter with a clear menu: you ask, and the server answers.