🔌Requests (Python)
Also known as Python Requests, requests library, import requests
A Python tool for calling web APIs. One line gets a page.
Think of it like
Think of it like a polite messenger. You say where to go and what to ask, and it brings back the answer.
Example
Lucy writes a Python script with Requests. Every hour it asks a weather API for the forecast and saves it.
Why it matters
Definition
Example code
python
import requests
res = requests.get("https://api.example.com/orders/42", timeout=10)
print(res.status_code, res.json()["total"])Common mistake
Key takeaways
- 1One line. requests.get fetches it.
- 2JSON built in. res.json() reads the body.
- 3Set a timeout. Never wait forever.