Skip to content
TeachTrails
DevelopmentBackend

What Is a Backend? APIs Explained for Beginners

What a backend and an API are, in plain English: requests, responses, JSON, HTTP methods and status codes, using one simple To-Do app as the example.

Sukanya Saha, Technology Consultant

8 min read

Beginner friendly

Our example for the whole course: a To-Do app

Everything in this course is built around one simple example: a To-Do list app. You sign up, log in, add tasks like “Buy milk”, tick them off, and delete them. By the last lesson you'll have written the complete backend for it, with a real database. Keep this app in your head; every new idea is a new piece of it.

The restaurant picture

Think of a restaurant:

  • You (the customer) = the app on a phone or browser. This is the frontend.
  • The menu = the API: the list of things you're allowed to order.
  • The waiter = the internet, carrying your order and bringing back the food.
  • The kitchen = the backend. It cooks, checks rules (“sorry, we're out of that”) and serves.
  • The store room = the database, where all the ingredients (data) are kept.

You never walk into the kitchen. You only order from the menu. That's exactly how apps talk to backends.

One request, start to finish

When you tap “Add task” in the To-Do app, this happens in less than a second:

  1. 1

    App sends a request

    POST /api/tasks with the data { "title": "Buy milk" }.

  2. 2

    It travels over the internet

    Using HTTP, the language of the web.

  3. 3

    Backend checks it

    Is the user logged in? Is the title empty? Rules first.

  4. 4

    Backend saves it

    The task goes into the database (PostgreSQL).

  5. 5

    Backend sends a response

    Status 201 and the new task as JSON.

  6. 6

    App shows it

    "Buy milk" appears in your list.

What a request is made of

Every request has up to four parts. Here they are for “add a task”:

PartWhat it isExample
MethodThe verb: what you want to doPOST
URL (path)The noun: which thing/api/tasks
HeadersExtra info, like who you areAuthorization: Bearer <token>
BodyThe data you send (for POST/PATCH){ "title": "Buy milk" }

The 5 methods you'll use every day

The method is the verb. With just these five you can build almost any API:

MethodMeansTo-Do example
GETRead (never changes anything)GET /api/tasks → list my tasks
POSTCreate something newPOST /api/tasks → add a task
PATCHChange part of somethingPATCH /api/tasks/5 → mark task 5 done
PUTReplace the whole thingPUT /api/tasks/5 → replace task 5 completely
DELETERemove itDELETE /api/tasks/5 → delete task 5

The response: a status code and JSON

The backend always answers with a status code (a 3-digit number saying how it went) and usually a JSON body:

201 CreatedResponse
{
  "id": 1,
  "title": "Buy milk",
  "done": false
}

JSON is just text that looks like a JavaScript object: keys in double quotes, values that are text, numbers, true/false, lists or other objects. Every programming language can read it.

Status codes you must know

The first digit tells you the story: 2 = success, 4 = you (the app) made a mistake, 5 = the server broke.

CodeNameWhen our To-Do API sends it
200OKHere are your tasks / here's the updated task
201CreatedYour new task (or account) was made
204No ContentTask deleted, nothing to send back
400Bad RequestThe title is empty or the JSON is broken
401UnauthorizedYou're not logged in (no token, or it expired)
403ForbiddenYou're logged in but not allowed to do this
404Not FoundThere's no task with that id (or it isn't yours)
409ConflictAn account with this email already exists
500Server ErrorA bug on our side. Never the user's fault

The full menu of our To-Do API

Here's every endpoint you'll build in this course. An endpoint is one method + one URL:

EndpointWhat it doesLogin needed?
POST /api/auth/registerCreate an accountNo
POST /api/auth/loginLog in, get a tokenNo
GET /api/tasksList my tasks (page by page)Yes
GET /api/tasks/:idGet one taskYes
POST /api/tasksAdd a taskYes
PATCH /api/tasks/:idChange a task (title or done)Yes
DELETE /api/tasks/:idDelete a taskYes

:id means “put a number here”, like /api/tasks/5. That's called a URL parameter. Extra options after a ?, like /api/tasks?page=2, are query parameters.

The tools we'll use (and why)

ToolIts jobWhy this one
Node.js (JavaScript)Runs JavaScript on a serverThe most used way to build web backends with JavaScript
TypeScriptJavaScript with typesCatches mistakes before you run the code (next lesson)
BunRuns our code and installs packagesOne fast tool, runs TypeScript directly, no setup
ExpressMakes writing APIs easyThe most popular, simplest Node.js web framework
PostgreSQLThe databaseFree, reliable, used by companies of every size
PrismaTalks to the database for usWrite data code in TypeScript, get tables made for you

Key takeaways

  • The frontend is what you see; the backend stores data and applies rules; the API connects them.
  • Every request has a method and a URL, and sometimes headers and a JSON body.
  • Use plural nouns for URLs and HTTP methods for actions (REST style).
  • Status codes tell the app what happened: 2xx good, 4xx client mistake, 5xx server bug.
  • We'll build one To-Do API through the whole course: auth plus five task endpoints.

Frequently asked questions

What is a backend in simple words?

The backend is the part of an app you don't see. It runs on a server, keeps the data (users, tasks, orders) in a database, checks who is allowed to do what, and sends answers back to the app on your phone or browser.

What is an API?

An API is the list of requests a backend understands, like a restaurant menu. Each item has an address (URL) and a method (GET, POST…). The app orders from the menu; the backend cooks and serves the answer as JSON.

What is the difference between frontend and backend?

The frontend is what users see and click (the screens). The backend is the server behind it that stores data and applies the rules. They talk to each other through the API.

What is REST?

REST is a popular, simple style for designing APIs: things are 'resources' with URLs (like /api/tasks), and HTTP methods say what to do with them (GET to read, POST to create, PATCH to change, DELETE to remove).

Do I need to know frontend before backend?

No. You only need basic programming (variables, functions, if/else, arrays, objects). This course starts from zero backend knowledge.

🧠 Quick check: backend basics

  1. 1. The app wants to show all your tasks. Which method does it use?

  2. 2. You created a new task successfully. Which status code is best?

  3. 3. You ask for /api/tasks/999 but there's no task 999. The server replies…

  4. 4. Which format do almost all modern APIs use to send data?

Node.js Backend with Express

Part 1 of 9: What Is a Backend