Course Hive
Search

Welcome

Sign in or create your account

Continue with Google
or
Request API data using Python in 8 minutes! ↩️
Play lesson

Python tutorial for beginners 🐍 - Request API data using Python in 8 minutes! ↩️

4.0 (0)
8 learners

What you'll learn

This course includes

  • 14.3 hours of video
  • Certificate of completion
  • Access on mobile and TV

Summary

Keywords

Full Transcript

#python #pythonprogramming #pythontutorial https://pokeapi.co/ 00:00:00 Pokeapi intro 00:00:40 import requests 00:01:09 pip install requests 00:01:44 url 00:03:17 response.get(url) 00:03:35 response.status_code 00:06:22 display API data # How to connect to an API using Python import requests base_url = "https://pokeapi.co/api/v2/" def get_pokemon_info(name): url = f"{base_url}/pokemon/{name}" response = requests.get(url) if response.status_code == 200: pokemon_data = response.json() return pokemon_data else: print(f"Failed to retrieve data {response.status_code}") pokemon_name = "pikachu" pokemon_info = get_pokemon_info(pokemon_name) if pokemon_info: print(f"Name: {pokemon_info["name"].capitalize()}") print(f"Id: {pokemon_info["id"]}") print(f"Height: {pokemon_info["height"]}") print(f"Weight: {pokemon_info["weight"]}")

Course Hive

Continue this lesson in the app

Install CourseHive on Android or iOS to keep learning while you move.

Related Courses

FAQs

Course Hive
Download CourseHive
Keep learning anywhere