Lesson 10 of 10
APIs & JSON
Python can fetch data from the internet using the requests library. APIs return data in JSON format, which Python converts to dictionaries automatically.
PYTHON
# Install first: pip install requests
import requests
response = requests.get("https://api.example.com/users")
data = response.json()
print(data[0]["name"])
print(f"Total users: {len(data)}")