9 min read Intermediate Lesson 8 of 11
Part 3 — Working with Data

APIs & the Web

Python isn't limited to your local laptop. With HTTP clients, your Python scripts can query AI models, fetch real-time weather feeds, send automated Slack notifications, and interact with global cloud backends.

Making HTTP Requests in Python

import requests
url = "https://api.github.com/users/octocat"
response = requests.get(url, timeout=5.0)
if response.status_code == 200:
data = response.json()
print(f"User: {data['name']}, Public Repos: {data['public_repos']}")

Always provide a timeout=... parameter to prevent slow or unresponsive servers from hanging your Python program forever.

Quick Summary

  • Use HTTP methods (GET, POST, PUT, DELETE) to communicate with external web endpoints.
  • Next, we parse and serialize data with JSON & Data Exchange.