SQL & APIs · APIs
HTTP APIs & JSON
How apps talk: requests, status codes, JSON bodies, and calling an API from Python.
Step 1 of 4 · Overview15 min read ·
Client
your script
Request
GET /trades?date=…
Server
API
Response
200 + JSON body
| Status | Meaning |
|---|---|
| 200 | OK |
| 201 | Created |
| 400 | Bad request (your input) |
| 401/403 | Not authenticated / not allowed |
| 404 | Not found |
| 429 | Rate limited: slow down |
| 500 | Server error |
import requests
r = requests.get("https://api.example.com/trades", params={"date": "2026-10-14"}, timeout=10)
r.raise_for_status() # error on 4xx/5xx
trades = r.json()Key idea
Always set a timeout and handle 429 with backoff. An LLM API is just another HTTP API.Next: Practice