Explainer
How APIs work: requests, responses, JSON, REST and OAuth
An API (application programming interface) is a set of features and rules that lets one piece of software interact with another, a kind of contract between them.[1] Web APIs reached over HTTP work by request and response: a client sends a request with a method such as GET or POST, and the server replies with a status code and can return data in formats such as JSON.[2][3][4] The REST style asks that every request carry everything needed to understand it, and OAuth 2.0 access tokens let apps reach a user's data without that user's password.[5][6]
What an API is
An API is a set of features and rules inside a program that lets other software interact with it, as opposed to a user interface built for people.[1] MDN describes it as a contract between the application offering it and other software or hardware.[1] In web development, an API is usually a set of methods, properties, events and URLs that developers use to work with the browser, the device or third-party websites and services.[7] For example, the browser’s Geolocation API can read location data from a device’s GPS, which an app can then combine with a maps API.[8]
Requests and responses over HTTP
Web APIs that work over the network exchange HTTP messages; HTTP is a stateless request/response protocol.[2] A client sends a request message with a method and a target, and the server answers with one or more response messages, each carrying a status code.[2]
The method says what the client wants to do. GET asks for something, POST sends data for the server to process, and DELETE asks the server to remove something.[3] The reply starts with a three-digit status code: codes in the 200s mean success, the 400s mean a problem with the request, and the 500s mean the server failed.[9]
RFC 9110 calls the method the primary source of request semantics: GET requests transfer of a current selected representation of the target resource, POST asks the resource to process the enclosed representation according to its own semantics, and DELETE asks the origin server to remove the association between the resource and its current functionality.[3] Status codes run from 100 to 599 and their first digit defines the class: 2xx successful, 4xx client error (bad syntax or a request that cannot be fulfilled) and 5xx server error.[9]
Data formats: JSON
One format for the data inside requests and responses is JSON, a lightweight, text-based, language-independent format derived from JavaScript.[4] It has four primitive types (strings, numbers, booleans and null) and two structured types (objects and arrays).[4] For where such data is often stored, see how databases work.
The REST style
Representational State Transfer (REST) was defined in Roy Fielding’s dissertation as an architectural style for distributed hypermedia systems, in which the key abstraction is a resource, meaning any information that can be named.[10] Under REST, each request from client to server must carry all the information needed to understand it, without relying on context stored on the server.[5] Its interface is defined by four constraints: identification of resources, manipulation of resources through representations, self-descriptive messages and hypermedia as the engine of application state.[5]
Access without passwords: OAuth
When an API acts on a user’s data, OAuth 2.0 lets a third-party application get limited access to an HTTP service using an access token, a string with a specific scope and lifetime, instead of the user’s credentials.[6] The specification’s own example is a user letting a printing service reach photos stored at a photo-sharing service without giving the printing service her username and password.[11] For how connections are protected in transit, see how encryption works.
Read next
How web browsers work: from URL to pixels on screen
What happens when you open a web page: DNS, connections, parsing HTML into the DOM, layout and paint, JavaScript, and the browser's security model.
Questions readers ask
What is an API in simple terms?
A set of features and rules inside a program that lets other software interact with it, as opposed to a screen built for people. MDN likens it to a contract between the application and the software that uses it.[1]
What do GET, POST and DELETE mean?
They are HTTP methods that tell the server what the client wants. GET requests a current representation of a resource, POST asks the resource to process enclosed data, and DELETE asks the server to remove the resource's association with its functionality.[3]
What does a 404 or 500 error mean?
HTTP status codes are three-digit numbers whose first digit gives the class. Codes in the 400s are client errors, where the request has bad syntax or cannot be fulfilled, and codes in the 500s mean the server failed to fulfill an apparently valid request.[9]
What is JSON?
A lightweight, text-based, language-independent data format derived from JavaScript. It represents strings, numbers, booleans and null, plus objects and arrays.[4]
What is a REST API?
An API that follows the REST architectural style defined in Roy Fielding's dissertation, in which the key abstraction is a resource and each request must carry all the information needed to understand it.[10][5]
How can an app access my account without my password?
Through OAuth 2.0, which gives the app an access token with a specific scope and lifetime instead of your credentials. The specification's example is a printing service reaching photos stored elsewhere without the user sharing her password.[6][11]
Sources
· 11 claims from 3 publishers
Each numbered claim is a statement we checked against the sources listed with it. Tap a number in the text to see its sources in place.
- [1]
An API (application programming interface) is a set of features and rules inside a program that lets other software interact with it, as opposed to a human user interface; MDN likens it to a contract between the application and other software or hardware. reportedas of 2026-11-14
- [2]
HTTP is a stateless request/response protocol; a client sends a request message with a method and a target, and the server replies with response messages that each include a status code. confirmedas of 2026-11-14
- RFC 9110: HTTP Semantics · IETF (RFC Editor) · Primary source · 2022-06-01 · Section 3.4 (retrieved 2026-11-14)
- RFC 9110: HTTP Semantics · IETF (RFC Editor) · Primary source · 2022-06-01 · Section 3.4 (retrieved 2026-11-14)
- RFC 9110: HTTP Semantics · IETF (RFC Editor) · Primary source · 2022-06-01 · Section 3.4 (retrieved 2026-11-14)
- [3]
HTTP methods tell the server what the client wants - GET requests a current representation of a resource, POST asks the resource to process enclosed data according to its own rules, and DELETE asks the server to remove the resource's association with its functionality. confirmedas of 2026-11-14
- RFC 9110: HTTP Semantics · IETF (RFC Editor) · Primary source · 2022-06-01 · Section 9.1 (retrieved 2026-11-14)
- RFC 9110: HTTP Semantics · IETF (RFC Editor) · Primary source · 2022-06-01 · Section 9.3.1 (retrieved 2026-11-14)
- RFC 9110: HTTP Semantics · IETF (RFC Editor) · Primary source · 2022-06-01 · Section 9.3.3 (retrieved 2026-11-14)
- RFC 9110: HTTP Semantics · IETF (RFC Editor) · Primary source · 2022-06-01 · Section 9.3.5 (retrieved 2026-11-14)
- [4]
JSON is a lightweight, text-based, language-independent data interchange format derived from JavaScript (ECMAScript); it represents strings, numbers, booleans and null, plus objects and arrays. confirmedas of 2026-11-14
- RFC 8259: The JavaScript Object Notation (JSON) Data Interchange Format · IETF (RFC Editor) · Primary source · 2017-12-01 · Abstract (retrieved 2026-11-14)
- RFC 8259: The JavaScript Object Notation (JSON) Data Interchange Format · IETF (RFC Editor) · Primary source · 2017-12-01 · Section 1 (retrieved 2026-11-14)
- [5]
Under REST, each request from client to server must carry all the information needed to understand it, without relying on context stored on the server, and the interface is defined by four constraints including identification of resources and self-descriptive messages. confirmedas of 2026-11-14
- Architectural Styles and the Design of Network-based Software Architectures, Chapter 5: Representational State Transfer (REST) · Roy Thomas Fielding, University of California, Irvine · Primary source · 2000-01-01 · Section 5.1.3 Stateless (retrieved 2026-11-14)
- Architectural Styles and the Design of Network-based Software Architectures, Chapter 5: Representational State Transfer (REST) · Roy Thomas Fielding, University of California, Irvine · Primary source · 2000-01-01 · Section 5.1.5 Uniform Interface (retrieved 2026-11-14)
- [6]
OAuth 2.0 lets a third-party application obtain limited access to an HTTP service using an access token - a string with a specific scope and lifetime - instead of the user's own credentials. confirmedas of 2026-11-14
- RFC 6749: The OAuth 2.0 Authorization Framework · IETF (RFC Editor) · Primary source · 2012-10-01 · Abstract (retrieved 2026-11-14)
- RFC 6749: The OAuth 2.0 Authorization Framework · IETF (RFC Editor) · Primary source · 2012-10-01 · Section 1 (retrieved 2026-11-14)
- [7]
In web development, an API is usually a set of methods, properties, events and URLs that developers use to work with the browser, other software or hardware on a device, or third-party websites and services. reportedas of 2026-11-14
- API · MDN Web Docs (Mozilla) · Secondary source · Glossary: API, second paragraph (retrieved 2026-11-14)
- [8]
For example, the browser's Geolocation API can retrieve location information from services on a device such as GPS, which can then be combined with other services such as a maps API. reportedas of 2026-11-14
- API · MDN Web Docs (Mozilla) · Secondary source · Glossary: API, examples (retrieved 2026-11-14)
- [9]
An HTTP status code is a three-digit number from 100 to 599 describing the result of a request; its first digit gives the class, with 2xx meaning success, 4xx a client error such as bad syntax, and 5xx a server failure. confirmedas of 2026-11-14
- RFC 9110: HTTP Semantics · IETF (RFC Editor) · Primary source · 2022-06-01 · Section 15 (retrieved 2026-11-14)
- RFC 9110: HTTP Semantics · IETF (RFC Editor) · Primary source · 2022-06-01 · Section 15 (retrieved 2026-11-14)
- RFC 9110: HTTP Semantics · IETF (RFC Editor) · Primary source · 2022-06-01 · Section 15 (retrieved 2026-11-14)
- RFC 9110: HTTP Semantics · IETF (RFC Editor) · Primary source · 2022-06-01 · Section 15 (retrieved 2026-11-14)
- [10]
Roy Fielding's dissertation defined Representational State Transfer (REST), an architectural style for distributed hypermedia systems in which the key abstraction is a resource - any information that can be named. confirmedas of 2026-11-14
- Architectural Styles and the Design of Network-based Software Architectures, Chapter 5: Representational State Transfer (REST) · Roy Thomas Fielding, University of California, Irvine · Primary source · 2000-01-01 · Chapter 5, introduction (retrieved 2026-11-14)
- Architectural Styles and the Design of Network-based Software Architectures, Chapter 5: Representational State Transfer (REST) · Roy Thomas Fielding, University of California, Irvine · Primary source · 2000-01-01 · Section 5.2.1.1 Resources and Resource Identifiers (retrieved 2026-11-14)
- Architectural Styles and the Design of Network-based Software Architectures, Chapter 5: Representational State Transfer (REST) · Roy Thomas Fielding, University of California, Irvine · Primary source · 2000-01-01 · Section 5.2.1.1 Resources and Resource Identifiers (retrieved 2026-11-14)
- [11]
The OAuth 2.0 specification's example is a user letting a printing service access photos stored at a photo-sharing service without giving the printing service her username and password. confirmedas of 2026-11-14
- RFC 6749: The OAuth 2.0 Authorization Framework · IETF (RFC Editor) · Primary source · 2012-10-01 · Section 1 (retrieved 2026-11-14)
Revision history (1)
- Page created.
Created Nov 14, 2026. Last reviewed by an editor on Nov 14, 2026. Next scheduled review: Aug 14, 2027.
Cite this page
"How APIs work: requests, responses, JSON, REST and OAuth." ContentLora, updated Nov 14, 2026. https://contentlora.com/explain/how-apis-work
Spotted an error? Suggest a correction or emailcorrections@contentlora.com.