Newton Institute of Technology Logo
Newton Institute of Technology Building Your Dream Career

What Is an API in Web Development? Frontend & Backend

Web Development Guide Basics

What Is an API?
How Frontend and Backend Communicate

Frontend · API · Backend

Follow one web request from the screen to the server and back, then inspect the same request yourself in the browser.

The communication route

Request goes in. Response comes back.

FocusWeb APIs

FlowRequest → response

Core toolsHTTP · JSON · Fetch

Updated31 October 2026

Quick answer

What is an API in web development?

API stands for Application Programming Interface. It is a defined interface that lets software request data or functionality from other software. In a web application, an API often lets the frontend ask the backend for data or an action. The backend validates the request, performs the required work and sends a response back. APIs are broader than web APIs, so this guide focuses specifically on the web-development use case. [1]

  • Frontend sends
  • API defines
  • Backend processes
  • Database stores
  • Response returns
FrontendUser interface
APICommunication interface
BackendLogic and rules
DatabasePersistent data
RequestWhat client asks
ResponseWhat server returns

How an API works: follow one student-results request

The easiest way to understand a web API is to stop thinking about the term for a moment and follow one feature from the screen to the server and back.

1. User action

A student who is already signed in presses View My Results. The frontend detects the click and knows that it needs examination data.

2. Request

The frontend sends a request such as GET /api/me/results. The method says what kind of operation is intended; the target identifies what is being requested.

3. Server work

The backend checks the request, identifies the signed-in user, verifies permission, applies business rules and retrieves the permitted records.

4. Response

The server returns a status, headers and—when appropriate—data. The frontend reads the response and turns it into a results table the student can understand.

The complete chain

  1. The student clicks the button: the browser detects the action.
  2. The frontend prepares a request: for example GET /api/me/results.
  3. The request reaches the server: HTTP carries the request to the target service.
  4. The backend validates it: the server checks the request structure and required information.
  5. Authentication is considered: the system determines who is making the request.
  6. Authorisation is checked: the system decides what that user is allowed to access.
  7. Application rules run: for example, whether results have been released.
  8. Data is retrieved: the backend may query a database or another service.
  9. The server returns a response: HTTP status, headers and possibly a response body come back.
  10. The frontend updates the screen: raw data becomes a useful interface.

The mental model to keep

User → Frontend → Request → API/Backend → Database or service → Response → Frontend. HTTP is built around client requests and server responses; the request method communicates the client’s intent and the response status communicates the result. [2]

What is actually inside an API request?

“Send a request” sounds abstract until you can read one. A simplified request might look like this:

HTTP request
GET /api/me/results?term=2 HTTP/1.1 Accept: application/json Authorization: Bearer <token>

Method

GET expresses the request’s intended operation. HTTP defines standard method semantics. [2]

Target / endpoint

/api/me/results?term=2 identifies where the request is directed and includes a query string.

Headers

Headers carry request metadata, such as accepted response formats or credentials used by the application’s authentication design.

Body

Some requests also carry content—for example JSON submitted to register a user or create an order.

Endpoint, path value and query parameter

Consider GET /api/students/104/results?term=2.

  • /api/students/104/results is the request path.
  • 104 can be used by an API design as a path value identifying a particular student.
  • ?term=2 is a query string. Query parameters are often used for filtering, searching, sorting or modifying a request.

Browser APIs such as URLSearchParams provide a standard way to work with URL query strings. [12]

What is inside a response?

A simplified successful response might contain 200 OK, a Content-Type: application/json header and a JSON body such as {"student":"Amina","mathematics":78}. JSON is a lightweight, text-based, language-independent data-interchange format. [3]

HTTP methods and status codes beginners should know

Do not memorise a huge protocol reference at the start. Learn the methods and response codes you will meet repeatedly, then deepen your knowledge as your applications become more complex.

Five HTTP methods you will meet often

GET

Beginner meaning: Retrieve a resource.

Example: Read examination results.

Important nuance: HTTP defines GET as a safe retrieval method, so it should not be used to request state-changing behaviour. [2]

POST

Beginner meaning: Submit content for processing.

Example: Submit a registration.

Important nuance: POST is often used to create resources, but its standard meaning is broader than simply “create”.

PUT

Beginner meaning: Create or replace target state.

Example: Replace stored profile details.

Important nuance: PUT uses replacement semantics for the target resource.

PATCH

Beginner meaning: Apply a partial modification.

Example: Change only a phone number.

Important nuance: PATCH is defined separately from the core RFC 9110 method set.

DELETE

Beginner meaning: Request removal.

Example: Delete an allowed record.

Important nuance: The server still has to authenticate, authorise and validate the action.

HTTP method semantics are defined by standards rather than by framework conventions alone. [2]

Status codes you will meet repeatedly

200 OK

Meaning: The request succeeded.

Check next: Read and use the returned content.

201 Created

Meaning: A new resource was created.

Check next: Review the returned representation or location information.

400 Bad Request

Meaning: The request has a client-side problem.

Check next: Inspect input, syntax and required fields.

401 Unauthorized

Meaning: Valid authentication credentials are missing.

Check next: Inspect login state, token/session and authentication flow.

403 Forbidden

Meaning: The server refuses the action.

Check next: Inspect the user’s role and permission.

404 Not Found

Meaning: The target resource was not found.

Check next: Inspect the route, identifier and whether the resource exists.

405 Method Not Allowed

Meaning: That method is not allowed for the target.

Check next: Confirm whether the endpoint expects GET, POST, PATCH or another method.

429 Too Many Requests

Meaning: Requests are arriving too frequently.

Check next: Respect the API’s rate limits and retry guidance.

500 Internal Server Error

Meaning: The server encountered an unexpected failure.

Check next: Inspect server-side logs and processing if you control the backend.

503 Service Unavailable

Meaning: The service is temporarily unable to handle the request.

Check next: Check availability and retry policy rather than assuming user input is wrong.

RFC 9110 defines HTTP response status classes and codes, including the distinction between authentication-related 401 responses and access-refusal 403 responses. [2]

Four practical examples of APIs in real applications

The definition becomes easier when you can recognise the same request-response pattern in different systems.

Student results portal

A student clicks View Results. The frontend requests the signed-in student’s records; the backend checks identity and permission, obtains the records and returns them.

Internal web API

Online shop order

The frontend submits product and quantity information. The backend validates the request, checks stock and pricing, applies rules, creates the order and sends the outcome back.

Business workflow

Application login

The browser submits credentials to a login endpoint. The backend verifies the account and returns success or failure. The visible form is only one part of authentication.

Authentication flow

M-PESA integration

A Kenyan application’s backend can communicate with Safaricom’s Daraja platform to integrate M-PESA payment functionality into web or mobile applications. [9]

External API

Internal API vs external API

An internal API can connect components controlled by the same organisation. An external API lets your application communicate with another organisation’s service. In both cases, software interacts through a defined interface.

API vs backend vs database—and where REST fits

Frontend

Presents information, collects user interaction and decides when it needs to request or submit data.

API

Defines how another software component can request permitted data or functionality.

Backend

Runs server-side logic, validation, permissions, integrations, background work and database operations.

Database

Stores and retrieves persistent information such as users, results, products, payments or orders.

Three misconceptions to remove early

API ≠ database. A database stores data. API ≠ backend. The API can be one interface to a larger backend. API ≠ REST. REST is one architectural style used for networked systems.

What is REST?

REST stands for Representational State Transfer. Roy Fielding introduced REST as an architectural style defined by constraints for distributed hypermedia systems, not merely as “an API that uses GET and POST”. [6]

Many APIs described as RESTful organise their interface around resources and use HTTP methods to interact with those resources. For example, GET /api/students/104 can retrieve one student while PATCH /api/students/104 can request a partial change.

Also remember: REST does not mean JSON. JSON is a data format; REST is an architectural style.

How frontend JavaScript calls an API

Seeing a real call makes the architecture less abstract. Modern browsers provide the Fetch API for making network requests.

load-results.js
async function loadResults() { try { const response = await fetch("/api/results"); if (!response.ok) throw new Error(response.status); const data = await response.json(); console.log(data); } catch (error) { console.error("Could not load results", error); } }

fetch()

Starts a network request to the supplied resource.

await

Lets the async function wait for the promise to settle before using the result.

response.ok

Provides a convenient check for HTTP success status in the 200–299 range.

response.json()

Reads the response body and parses it as JSON.

A beginner trap worth remembering

fetch() does not automatically reject its promise just because the server returned an HTTP error such as 404 or 500. Your code should inspect the response status or response.ok. [4]

See an API request yourself with Browser DevTools

This is the practical exercise that turns an API from an idea into something you can observe. Use a site or application you are authorised to inspect.

  1. Open Chrome DevTools: use the browser menu or the platform keyboard shortcut.
  2. Open the Network panel: network requests are recorded while DevTools is open.
  3. Reload the page: watch the request list populate.
  4. Perform an action: open a dashboard, search or use a non-sensitive feature in your own practice application.
  5. Filter for Fetch/XHR where useful: many API calls from frontend JavaScript appear there.
  6. Select one request: inspect its URL, method, status and initiator.
  7. Inspect Headers: see request and response metadata.
  8. Inspect Payload: see submitted data where the request carries it.
  9. Inspect Response: see what the server returned.
  10. Inspect Timing: see how long different parts of the request took.

Chrome’s official documentation describes the Network panel as a tool for recording and inspecting network activity, including request headers, responses and timing. [8]

A simple API debugging sequence

1. Was a request sent?

If nothing appears in Network, investigate the frontend event or code path first.

2. Was the target correct?

Check the URL and HTTP method before assuming the server or database is broken.

3. What came back?

Use the status code, response body and headers as evidence instead of guessing.

4. What failed behind it?

If you control the backend, continue into server logs, application logic, database queries and external-service calls.

CORS, authentication, authorisation and API secrets

Security terms often arrive all at once when a beginner starts connecting a frontend to a backend. Keep each concept separate.

What is CORS?

If frontend JavaScript at one origin requests an API at another origin, browser same-origin rules can apply. CORS—Cross-Origin Resource Sharing—is an HTTP-header-based mechanism through which a server indicates which other origins a browser may allow to access its resources. [5]

CORS is enforced by browsers

A CORS error does not automatically mean the API server is offline. A browser may be refusing scripted cross-origin access because the response lacks the required CORS permission. Server-to-server calls are not subject to browser CORS enforcement in the same way. Do not “fix” CORS by blindly allowing every origin; permit only what the application requires. [5]

Authentication vs authorisation

Authentication

Who are you? The system establishes the identity associated with the request.

Authorisation

What may you do? The system checks whether that identity is allowed to perform this action on this resource.

HTTPS

Protect the connection. HTTPS helps protect data in transit, but it does not replace application permission checks.

API credentials

Protect secrets deliberately. A private key, consumer secret or server-side credential should not be shipped inside public browser code.

OWASP’s REST security guidance recommends HTTPS for secure REST services, access-control checks at protected endpoints, restricting allowed methods and careful API-key handling. [7]

Knowing a record ID is not permission

If someone requests /api/students/104/results, the backend must not return the record merely because Student 104 exists. It must verify that the requester is authorised to receive it.

What good frontend code does when an API is slow or fails

Network operations are not guaranteed to succeed immediately. A request can fail because connectivity is lost, the server is unavailable, the request is invalid, authentication expired, permission is missing or another dependency failed.

Loading

Tell the user that work is happening. Avoid leaving the interface looking frozen.

Success

Show the returned information or confirm that the requested operation completed.

Error

Give a useful message and preserve enough evidence for the developer to trace the failure.

Retry

Where appropriate, let the user retry without accidentally duplicating state-changing operations.

How to read API documentation without getting lost

  1. Start with one task: for example “retrieve one student’s details”.
  2. Find the base address and endpoint: where should the request go?
  3. Check the method: GET, POST, PATCH, DELETE or something else?
  4. Check authentication: session, token, key or another credential?
  5. Check path and query parameters: which IDs or filters are required?
  6. Check headers and request body: what must the client send?
  7. Read the successful response example: what structure should come back?
  8. Read the error responses: what do common failure codes mean for this API?
  9. Check limits and rules: rate limits, allowed methods and provider-specific requirements.

Beginner practice: design a small API on paper

You do not need to build a huge application to practise API thinking. Imagine a small school system with students, courses, enrolments and results.

RequestWhat it should meanQuestion you must answer
GET /api/studentsRetrieve the student collectionWho is allowed to list students?
GET /api/students/104Retrieve Student 104What happens if the record does not exist?
POST /api/studentsSubmit data for a new studentWhich fields are required and validated?
PATCH /api/students/104Change part of Student 104Which roles may edit this record?
GET /api/students/104/resultsRetrieve this student’s resultsHow will the server prevent another student from reading them?

On a phone, swipe the table sideways to view every column.

The exercise is not about memorising URLs

For each operation, decide who may call it, what must be sent, what can come back, what should happen when something is wrong and which evidence would help you debug it. That is the beginning of application architecture.

A short learning order

Learn HTML and CSS first, then JavaScript fundamentals, JSON and asynchronous JavaScript. Use fetch(), understand HTTP requests and responses, then build your own backend endpoints, connect a database and add authentication, authorisation and testing. For the broader journey, see NIT’s Web Developer Roadmap.

Where APIs fit in full-stack development

A full-stack developer needs to understand how the layers connect. A student-registration feature can move through an interface, API route, validation, business logic, database write, response and final screen update.

NIT’s current Full-Stack Software Development programme connects frontend work with server-side development, databases, APIs, authentication, testing and deployment. The current programme has 8 months of institutional training, followed by a compulsory industrial attachment of at least 3 months, with current published tuition of KSh 90,000. No previous programming experience is required. [10]

NIT’s institutional website also documents student capstone work involving a React frontend, Node.js/Express backend API, database integration and API integration—practical examples of the same frontend-to-backend concepts described in this guide. [11]

Want the career-path comparison rather than the communication mechanism?

API FAQs for beginners

What does API stand for?

API stands for Application Programming Interface.

What is an API in simple terms?

An API is a defined interface that lets one piece of software request data or functionality from another.

What is an API in web development?

In web development, an API commonly gives a frontend, backend or external service a structured way to exchange data or request actions over a network.

Is an API a programming language?

No. An API is an interface. APIs can be created and used from many programming languages.

Is an API the same as a backend?

No. An API can be part of a backend, while the backend may also contain business logic, background jobs, database access, file processing and other services.

Is an API a database?

No. A database stores data. An API defines how software may request data or actions.

Does every website need an API?

No. Static sites may not need one, and traditional server-rendered applications can work without a separate JSON API for the browser. APIs become especially useful when different clients or software systems need structured communication.

Does every API use HTTP or JSON?

No. This guide focuses on web APIs, where HTTP and JSON are common. The broader API concept is not restricted to HTTP, and JSON is not the only possible data format.

Is every web API REST?

No. REST is one architectural style. Other approaches exist.

Can HTML send data without JavaScript?

Yes. An HTML form can submit data directly to a server. JavaScript is especially useful when an application needs programmatic network requests and partial interface updates.

Can a backend call another API?

Yes. The API client does not have to be a browser. One backend can call payment, mapping, messaging, weather or other internal and external services.

Can I see API requests in my browser?

Yes. Chrome DevTools includes a Network panel that records requests and lets you inspect properties such as status, headers, response content and timing. [8]

Learn the complete workflow

Register for Full-Stack Software Development at NIT

Learn how to build the interface, create the backend, design and use APIs, connect databases, control access, test complete workflows and deploy working applications.

Institutional training8 months

Industrial attachmentAt least 3 months

Current published tuitionKSh 90,000

References and further reading

Information checked: 31 October 2026.

Editorial responsibility: Newton Institute of Technology Editorial Team.