Prerequisites and setup
To read the course and use the “Run” buttons you need nothing. To run the examples on your computer you need:
- Python 3.12 or later:
python3 --version. - A virtual environment with the libraries used in the course:
Finestra del terminale python3 -m venv .venv && source .venv/bin/activate # Windows: .venv\Scripts\activatepip install httpx pydantic jsonschema ijson orjson - Check:
Expected:
Finestra del terminale python3 -c "import httpx; print(httpx.get('https://corso-api-json.giuseppebosi.com/api/v1/health').json())"{'status': 'ok', 'public_dataset': True}.
- Node.js 22 or later:
node --version. Node 22 runs.tsfiles directly (node --experimental-strip-types file.ts; from Node 23 the flag is no longer needed) and hasfetchbuilt in. - A working folder with the libraries used in the course:
Finestra del terminale mkdir corso-json && cd corso-json && npm init -ynpm install zod ajvnpm install -D typescript @types/node - Check (save as
check.ts):const r = await fetch("https://corso-api-json.giuseppebosi.com/api/v1/health");console.log(await r.json());Expected:Finestra del terminale node --experimental-strip-types check.ts{ status: 'ok', public_dataset: true }.
curl comes preinstalled on macOS, Linux and Windows 10/11 (curl --version). It is the tool we will use in every chapter to look at the “bare” request:
curl -s https://corso-api-json.giuseppebosi.com/api/v1/health- curl
- the program: it makes an HTTP request and prints the response
- -s
- silent: no progress bar, only the response body
- https://…/health
- the URL: scheme
https, host, path/api/v1/health. With no other options curl makes aGET
Expected: {"status":"ok","public_dataset":true}.
To filter and pretty-print JSON on the command line we will also use jq (optional: where it is missing, python3 -m json.tool formats without filtering). Install it with brew install jq (macOS), sudo apt install jq (Linux), winget install jqlang.jq (Windows). Check with jq --version.
Chapter 2 of Section 2 is entirely about curl.
If something goes wrong
Section titled “If something goes wrong”fetch is not defined→ Node older than 18: upgrade.- SSL/certificate error → wrong computer clock or a corporate proxy.
429 Too Many Requests→ you went over the per-minute limit: wait a few seconds.