Skip to main content
Brave Programmer Logo

BraveProgrammer

BraveProgrammer

HomeProjectsBlogsCoursesLessonsAbout

Site footer

BraveProgrammer

Free coding courses, practical tutorials, and real projects from BraveProgrammer. Learn web development with React, Next.js, and TypeScript.

Navigation

  • Home
  • Projects
  • Blogs
  • Courses

Resources

  • About
  • Lessons
  • Teach on BraveProgrammer

© 2026 BraveProgrammer. All rights reserved.

Working with APIs | Python Fundamentals lesson | BraveProgrammer
  1. Courses
  2. /
  3. Python Fundamentals

Lesson 41 of 55

·Python

Working with APIs

20 minutes

Course progress75%

What you'll learn

Keep these ideas in mind as you work through the lesson.

4 points
  • Use `requests.get`, `post`, `put`, `delete` for HTTP verbs.
  • `resp.json()` parses a JSON response into a Python dict.
  • Check `resp.status_code` or call `resp.raise_for_status()` for error handling.
  • Pass headers (e.g., `Authorization`) for authenticated endpoints.

Working with APIs

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.

Make it stickPractice what you've learned1 quiz · 5 practical tests · Optional activities from Python FundamentalsBrowse activities
Previous lessonWeb Scraping with requests and BeautifulSoupContinue to lesson 42AsyncIO BasicsBack to Python Fundamentals curriculum