• ↑↓ pour naviguer
  • pour ouvrir
  • pour sélectionner
  • ⌘ ⌥ ↵ pour ouvrir dans un panneau
  • ←→ pour naviguer
  • esc pour rejeter
⌘ '
raccourcis clavier

The Problem

Front end and back end need a contract to talk — what format do requests and responses follow when a browser calls a server?

Formal Definition

Per Wikipedia: “An HTTP API is an interface that exposes application functionality over HTTP using verbs, paths, headers and status codes.”

Explanation

Think of an API as a menu in a restaurant. The front end orders by calling a URL, the back end cooks and returns JSON. HTTP just defines how the waiter carries the order.

How It Works

  1. Client forms HTTP request with method and URL
  2. Server routes request to handler
  3. Handler runs business logic and queries data
  4. Server formats JSON response with status code
  5. Client parses response and updates UI

Visual Explanation

http_api A Client Request B Server Handler A->B step 1 C JSON Response B->C step 2

Semantic Network

semantic_http_api THIS HTTP API REL1 Related THIS--REL1 related REL2 Prereq THIS--REL2 builds from

Key Properties

  • Stateless — each request carries its own auth and context
  • Uses standard verbs GET POST PUT DELETE
  • Versioned via URL or header
  • Errors signaled via status codes

Real-World Example

# Minimal HTTP API call
import requests
resp = requests.get('https://api.example.com/users/1')
print(resp.status_code, resp.json())

Connections

  • Built from: Client-Server Model — API is the contract inside that model
  • Built from: API — specialization of generic API for HTTP
  • Related: Server — server implements the API
  • Contrasts with: Front End — front end consumes the API

Edge Cases & Gotchas

  • Forgetting pagination on list endpoints paginates in client not server
  • Mixing HTTP verbs — GET should not change state