Request API data using Python in 8 minutes! ↩️

preview_player
Показать описание
#python #pythonprogramming #pythontutorial

00:00:00 Pokeapi intro
00:00:40 import requests
00:01:09 pip install requests
00:01:44 url
00:06:22 display API data

# How to connect to an API using Python
import requests

def get_pokemon_info(name):
url = f"{base_url}/pokemon/{name}"

return pokemon_data
else:

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"]}")
Рекомендации по теме
Комментарии
Автор

#How to connect to an API using Python

import requests


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 =

if pokemon_info:
print(f"Name:
print(f"Id: {pokemon_info["id"]}")
print(f"Height: {pokemon_info["height"]}")
print(f"Weight: {pokemon_info["weight"]}")

BroCodez
Автор

THIS IS EXACTLY WHAT I NEEDED, THANK YOU SO MUCH MAN

sohailali
Автор

Nice tutorial,
I'm waiting for PyGame

szybkafoka
Автор

Bro, you have the best programming tutorials!

GigelBosket
Автор

Brother, I really want to know, with all these skills, at what stage are you in your career? Are you working a job? Do you have your own software house? Or are you in a big tech company? Please tell me so I can get the motivation to learn.

ranataha
Автор

You have an extra slash (/) on the base_url, the output is going to have a double slash. It still works good anyways. Thank you 😄

israelrios
Автор

I keep atleast one video at a time of yours on in the background at all times just to boost the algorithm

HassanFakhry-xx
Автор

the king is back! im glad youre making content again man you have no idea how useful and helpful it is! i get that it takes a huge chunk of time and ur not even profiting from it, but its much appreciated

andredubbs
Автор

Could you please show how to pull the entire list of Pokemon and generate a csv or excel table with specific attributes?

andrewanderson
Автор

hmm, i think Mewtwo is my favourite pokemon

ahmedashraf
Автор

height: 0.4m(1'04") , weight: 6.o kg (13.2 lbs)
pika pkia

jmac
Автор

… Do a video on creating an API. That would be interesting

digital_down
Автор

This is the only bro code vid that failed me :(

Bobble
Автор

Hello Brother make java with Data Structure and Algorithms course

BishanTamang-hlpn
Автор

I'm your big fan sir, can u please start the mern stack development

SumitRanjanBahalia
Автор

I don't know pokemon. I know when it comes to BroCode videos, gotta catch em all!

Fireman
Автор

Day 1 : Asking to walkthrough Rust language

unknownk
Автор

Mr.Bro is every api's arcitecture different ?

SanjaySankar-bt