Skip to content

Prerequisites and setup

To read the course and use the “Run” buttons you need nothing. To run the examples on your computer you need:

  1. Python 3.12 or later: python3 --version.
  2. A virtual environment with the libraries used in the course:
    Finestra del terminale
    python3 -m venv .venv && source .venv/bin/activate # Windows: .venv\Scripts\activate
    pip install httpx pydantic jsonschema ijson orjson
  3. Check:
    Finestra del terminale
    python3 -c "import httpx; print(httpx.get('https://corso-api-json.giuseppebosi.com/api/v1/health').json())"
    Expected: {'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:

terminal
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 a GET

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.

  • 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.