# HTTP

> The request-and-response language browsers and websites speak.

- Level: Basic
- Topics: Networks
- URL: https://tidbit.legios.com.ar/http/
- In Spanish: [HTTP](https://tidbit.legios.com.ar/es/http/)

**HTTP** (HyperText Transfer Protocol) is the set of rules a browser and a web server use to talk. The browser sends a **request** (give me this page) and the server sends back a **response** (the page, or an error). Every web page, image and API call you use runs on this simple back-and-forth.

A request has a method and a path. `GET /menu` means fetch the menu; `POST /order` means here is some data, create an order. The response starts with a status code: `200` is OK, `404` is not found, `500` is the server broke. Both carry **headers**, small notes such as the type of content, the language, or a cookie that identifies you.

HTTP is stateless: each request stands alone, and the server does not remember the previous one, which is why cookies and sessions exist. Plain HTTP is readable by anyone in between, so today almost everything uses HTTPS, which is the same conversation inside an encrypted tunnel. Newer versions (HTTP/2 and HTTP/3) make the exchange faster without changing what you ask for.

## An analogy

Ordering at a counter with a numbered ticket. You say what you want in a fixed form, you get a plate or a we are out of that, and the counter does not remember you between orders.

## Keep in mind

- A request has a method (`GET`, `POST`...) and a path; a response has a status code (`200`, `404`, `500`).
- HTTP is stateless: cookies are how a site remembers who you are between requests.
- HTTPS is HTTP with encryption; the conversation is the same, only protected.
- Most APIs on the web are just HTTP requests that return JSON instead of pages.

## Go deeper

- [An overview of HTTP (MDN)](https://developer.mozilla.org/en-US/docs/Web/HTTP/Guides/Overview)
- [What is HTTP? (Cloudflare)](https://www.cloudflare.com/learning/ddos/glossary/hypertext-transfer-protocol-http/)
- [HTTP (Wikipedia)](https://en.wikipedia.org/wiki/HTTP)

## Related terms

- [Web browser](https://tidbit.legios.com.ar/web-browser/): The app that fetches web pages from the internet and draws them on your screen.
- [Server](https://tidbit.legios.com.ar/server/): A computer whose job is to answer requests from other computers, all day, every day.
- [API](https://tidbit.legios.com.ar/api/): The menu of things one program lets another program ask for.
- [Cookies](https://tidbit.legios.com.ar/cookies/): Small notes a website asks your browser to keep, so it can recognize you later.
- [HTTPS](https://tidbit.legios.com.ar/https/): The padlock in your browser: web traffic nobody in between can read.
- [Encryption](https://tidbit.legios.com.ar/encryption/): Scrambling data so that only someone with the key can read it.
- [JSON](https://tidbit.legios.com.ar/json/): The plain-text format programs use to hand each other structured data.
