In partnership with

Imagine you run a cafe website.

cafe website

You want to show the best-selling coffee of the day.

cafe website

The data changes every day based on the sales.

You need to grab that data from the database.

But you can't pull the data directly.

Why?

Because it’s insecure.

So, we need a middleman called an API.

How API works

You send a request to the API.

send an API request

The API scans the request to ensure it’s safe

scan the request

Then it talks to the database

get data from database

and brings you the data you want.

return response data

But how should the request and response look?

We need some kind of guidelines.

That guideline is called Rest API.

Rest (Representational State Transfer) API

The guidelines include

  • Client-server decoupling

  • Statelessness

  • Cacheability

  • Layered system architecture

Sounds complicated?

Don't worry, we are not going through that.

In practice, it looks something like this.

First, you send a request.

It falls into one of these four categories.

CRUD

Which action should you use to get the best-selling coffee?

READ.

Each action maps to an HTTP method.

HTTP methods

We are going to send a GET request.

But where should we send it?

The server, right?

Get request

But a server has many types of data, like the best-selling dish, the menu, and other stuff.

How does it organize them?

By using URIs (endpoints).

API Endpoints

They look like this.

api endpoints

Each of them returns different data.

You send your GET request to the right endpoint.

GET https://server.com/best-coffees

The server queries the database and returns the data, which is usually in JSON.

json data

You get what you want.

But wait.

One last thing.

HTTP Status Code

The request isn't always successful.

So, the server needs to tell the client if the request worked or not.

It does that by using a status code.

http status code

200-level status code means success.

400 means you messed up.

And 500 means the server messed up.

Fee from Anime Coders

Earn a master's in AI for under $2,500

AI skills aren’t optional anymore—they’re a requirement for staying competitive. Now you can earn a Master of Science in Artificial Intelligence, delivered by the Udacity Institute of AI and Technology and awarded by Woolf, an accredited higher education institution.

During Black Friday, you can lock in the savings to earn this fully accredited master’s degree for less than $2,500. Build deep expertise in modern AI, machine learning, generative models, and production deployment—on your own schedule, with real projects that prove your skills.

This offer won’t last, and it’s the most affordable way to get graduate-level training that actually moves your career forward.

How did you like today's email?

Login or Subscribe to participate

Keep Reading