Mack's LoL Scout
Explain

HTTP + JSON in 12 minutes

Your program asks a server for data. The server answers with a status code and a body (often JSON). When it breaks, you don’t guess—you print the receipts.

TL;DR

  • Print the URL + status code every time.
  • If status != 200: print a tiny slice of the body.
  • JSON = dicts + lists. Print keys/lengths instead of guessing.

Status codes you’ll actually see

  • 200: success
  • 404: wrong URL, wrong region, wrong ID
  • 429: rate limit (slow down, cache, retry later)
  • 401: missing/invalid auth
  • 403: auth present but expired/not allowed

JSON → Python types

JSON objects become dict. JSON arrays become list. “Nested data” is just “dicts inside dicts inside lists”.

Tiny mental model

# JSON: {"items": [{"id": 1}, {"id": 2}]}
data = response.json()
print(type(data))           # dict
print(type(data['items']))  # list
print(data['items'][0]['id'])

Print debugging: the minimum receipt

When a request fails, print just enough to be dangerous (to the bug).

Receipt template

print('URL:', url)
print('PARAMS:', params)
print('STATUS:', r.status_code)
if r.status_code != 200:
  print('BODY:', r.text[:200])