Lesson 41 of 55
PythonWorking with APIs
20 minutes
Course progress75%
What you'll learn
Keep these ideas in mind as you work through the lesson.
Lesson 41 of 55
Python20 minutes
Keep these ideas in mind as you work through the lesson.
Most modern services expose a JSON‑based HTTP API. The requests library makes consuming these APIs effortless.
import requests
api_url = 'https://api.github.com/repos/python/cpython'
resp = requests.get(api_url)
if resp.ok:
data = resp.json()
print('Stars:', data['stargazers_count'])
else:
print('Error:', resp.status_code)
Authentication (API keys, OAuth) and pagination are common advanced topics you’ll encounter in real‑world integrations.