Asosiy/Lug'at/REST API (Representational State Transfer)
networking

REST API (Representational State Transfer)

An architectural style for client-server communication using standard HTTP methods (GET, POST, PUT, DELETE).

Sodda Hayotiy O'xshatish

"REST is like a restaurant waiter: you order food from a menu (request), the waiter relays it to the kitchen (server), and brings back the dish (response)."

Qanday ishlaydi va Nega kerak?

Formulated by Roy Fielding in 2000, REST relies on a stateless, client-server, cacheable communications protocol. In almost all modern instances, it utilizes JSON over HTTP.

Amaliy Kod Ko'rinishi

typescript
// REST API Endpoint namunasi
// GET /api/v1/posts/42 -> Bitta postni olish
// POST /api/v1/posts   -> Yangi post yaratish
// DELETE /api/v1/posts/42 -> Postni o'chirish

fetch('https://thegogetters.uz/api/topics')
  .then(res => res.json())
  .then(data => console.log(data));

Asosiy Xulosalar

Stateless: each request contains all context needed for completion
HTTP status codes (200, 201, 400, 401, 404, 500) provide semantic results
Standard JSON payload convention

Bog'liq Atamalar