← The Forge
Fundamentals Lab · Python 2

Python API Calls

Same curl calls from the last lab, same real APIs — but now built and parsed in Python. One continuous python3 session: everything you create stays around for later exercises, exactly like a real REPL.
Quick Refresher

Same REPL, real network calls.

  • Same >>> / ... prompts as the last lesson. Every line here was run for real against the same live weather API and demo API as the curl lab, and the outputs you'll see are the genuine responses — replayed here exactly, so the identical session works in a real python3 when you try it. No library beyond what ships with Python.
  • Everything you create stays alive for the rest of the lesson — a variable from exercise 2 is still there in exercise 6.
Done

A library doesn't hide the request. It just types it for you.

urlopen() is doing exactly what curl did — same method, same headers, same body, same status code. The only real difference: a failed request doesn't print an error and move on, it raises an exception, and Python makes you decide on purpose whether to catch it. That decision — check it now, or let it crash later — is the whole difference between a script and a script somebody can trust.
1 / 1
ends with a "mark complete" step