Request API data using Python in 8 minutes! ↩️

แชร์
ฝัง
  • เผยแพร่เมื่อ 5 ก.พ. 2025

ความคิดเห็น •

  • @BroCodez
    @BroCodez  6 หลายเดือนก่อน +15

    # pokeapi.co/
    #How to connect to an API using Python
    import requests
    base_url = "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"]}")

    • @acexpanda09
      @acexpanda09 3 หลายเดือนก่อน

      Do request. Status_code is in built? Only the status_code

  • @yourkidelias
    @yourkidelias 3 หลายเดือนก่อน +12

    Yo, I've finished what I needed from your Python 2024 course and I want to say that ur way of explaining these concepts was much better than any other course I could find, and much more quicker! Thank you very much ^^.

  • @sohailali3274
    @sohailali3274 6 หลายเดือนก่อน +18

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

  • @APL33025
    @APL33025 หลายเดือนก่อน +5

    This was an excellent example of displaying API data, thank you

  • @andredubbs4854
    @andredubbs4854 6 หลายเดือนก่อน +2

    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

  • @GigelBosket
    @GigelBosket 6 หลายเดือนก่อน +6

    Bro , you have the best programming tutorials!

  • @materwelone6026
    @materwelone6026 6 หลายเดือนก่อน +30

    i love bro code

  • @oliya_b
    @oliya_b 2 หลายเดือนก่อน

    Thank you a lot! That's exactly what i needed! Thank you a looooot!!!!! 😊😊

  • @Xidphel
    @Xidphel 18 วันที่ผ่านมา +1

    So looks like the height and weight values are in m and kg respectively. The values returned are 10x the actual value. So for Pikachu, it's 0.4m and 6.0kg.
    There's also a quirk going on with the gender_rate value as well when you look up pokemon-species/{id or name}/. It's an int value going from -1 to 8. -1 means the Pokemon is genderless. The values 0-8 is used to calculate the female percentage using (gender / 8) * 100. Pikachu's gender_rate value is 4 which means the gender ratio for Pikachu is 50:50. Bulbasaur, on the other hand, has a gender ratio of 1, which make its gender ratio 12.5% female and 87.5% male.

  • @sleepingforest2047
    @sleepingforest2047 2 หลายเดือนก่อน

    wonderful, simple to explain and easy to understand.

  • @wombozombo
    @wombozombo 3 หลายเดือนก่อน +1

    This helped a lot, thanks!

  • @szybkafoka69
    @szybkafoka69 6 หลายเดือนก่อน +5

    Nice tutorial,
    I'm waiting for PyGame

  • @israelrios1916
    @israelrios1916 4 หลายเดือนก่อน +1

    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 😄

  • @courtneycurtis
    @courtneycurtis 4 หลายเดือนก่อน

    Really fun tutorial, thank you!

  • @HassanFakhry-x5x
    @HassanFakhry-x5x 6 หลายเดือนก่อน +3

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

  • @freelance-writer
    @freelance-writer 4 หลายเดือนก่อน +3

    6:49 You've got nested double quotes in the print function, which throws me an error. So it's better to use single quotes inside double quotes.

  • @cross_guy
    @cross_guy หลายเดือนก่อน

    so helpful, thanks.

  • @ranataha8500
    @ranataha8500 6 หลายเดือนก่อน +2

    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.

  • @seanmorley2601
    @seanmorley2601 4 หลายเดือนก่อน

    Love it! Any similar videos for oauth2 authentication before we can use api?

  • @EthanWinters176
    @EthanWinters176 2 หลายเดือนก่อน +2

    "I will pick my favorite pokemon of Typhlosion"💀

  • @talhaalmamun6073
    @talhaalmamun6073 หลายเดือนก่อน

    Bro, you are the boss

  • @Bezxywny
    @Bezxywny 3 หลายเดือนก่อน

    Name: Charizard
    ID: 6
    Height: 17
    Weight: 905
    someone in the comments below explaind units of pikachu
    "height: 0.4m(1'04") , weight: 6.o kg (13.2 lbs) "
    so it looks that Charizard is 1.7m tall and weights around 90kg
    btw pikachu could weight 60kg, I remember that Ash was carrying him on his back xD
    Bro, thank you for your work :)

  • @johnneisler6552
    @johnneisler6552 6 หลายเดือนก่อน

    Love your channel

  • @Fireman9143
    @Fireman9143 6 หลายเดือนก่อน

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

  • @notofthematrix
    @notofthematrix หลายเดือนก่อน

    very helpful at first I got the 404 error and you didn't explain how to fix it the I realized I made a small yet crucial mistake to no put a / somewhere in the code. Thanks

  • @jmac2050
    @jmac2050 4 หลายเดือนก่อน

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

  • @SumitRanjanBahalia
    @SumitRanjanBahalia 6 หลายเดือนก่อน

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

  • @SanjaySankar-b1t
    @SanjaySankar-b1t 6 หลายเดือนก่อน

    Mr.Bro is every api's arcitecture different ?

  • @Mr152478000
    @Mr152478000 3 หลายเดือนก่อน

    APIkachu, thanks Bro !!!

  • @digital_down
    @digital_down 4 หลายเดือนก่อน

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

  • @kapibara2440
    @kapibara2440 6 หลายเดือนก่อน

    Greetings from Poland Bro 🎉🎉🎉

  • @dhiyanabdurazack5257
    @dhiyanabdurazack5257 2 หลายเดือนก่อน

    NICE

  • @أملاكعبدالله-س3ع
    @أملاكعبدالله-س3ع หลายเดือนก่อน

    I want call all data and save in files , without pass parameters how can do that? The api is soap

  • @xnaifu8517
    @xnaifu8517 วันที่ผ่านมา

    Did this for ablosutely 0 reason.
    But its fun.

  • @kashifrana6798
    @kashifrana6798 2 หลายเดือนก่อน

    How to handle authentication for rest API and using session?

  • @okman4300
    @okman4300 4 หลายเดือนก่อน

    thank you so much

  • @ahmedashraf4371
    @ahmedashraf4371 6 หลายเดือนก่อน +1

    hmm , i think Mewtwo is my favourite pokemon

  • @BishanTamang-hl3pn
    @BishanTamang-hl3pn 6 หลายเดือนก่อน

    Hello Brother make java with Data Structure and Algorithms course

  • @joebucket1471
    @joebucket1471 หลายเดือนก่อน

    Is this pycharm ?

  • @kedarppopuri2776
    @kedarppopuri2776 6 หลายเดือนก่อน +1

    Bro please me pandas tutorial too

  • @mohsenmk2537
    @mohsenmk2537 6 หลายเดือนก่อน +1

    Please teach us api in JavaScript

  • @patrickwheeler7107
    @patrickwheeler7107 2 หลายเดือนก่อน

    Jiggly Puff errrrr jigglypuff

  • @MusaddikulIslam-r7i
    @MusaddikulIslam-r7i หลายเดือนก่อน

    Me!: gardeviour
    My bro: arcious

  • @zakariaabdulrauf
    @zakariaabdulrauf 5 หลายเดือนก่อน

    Help mine shows errors

  • @unknownk1992
    @unknownk1992 6 หลายเดือนก่อน

    Day 1 : Asking to walkthrough Rust language

  • @andrewanderson9261
    @andrewanderson9261 5 หลายเดือนก่อน

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

    • @irvinrodriguez931
      @irvinrodriguez931 3 หลายเดือนก่อน +1

      not sure if you have gotten your answer to this yet, but look into using pandas, once you have your dictionary from this pokemon api you can use pandas to write into your csv or excel file

  • @darthnihilus777
    @darthnihilus777 4 หลายเดือนก่อน

    Yes Pikachu's height is probably 4 inches

  • @Bobble2520
    @Bobble2520 5 หลายเดือนก่อน

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

  • @Po7322-6
    @Po7322-6 3 หลายเดือนก่อน

  • @user-yackoob
    @user-yackoob 6 หลายเดือนก่อน

    tutorial for django....

  • @Hasnain-mahdi
    @Hasnain-mahdi หลายเดือนก่อน

    Bro do you even code

  • @LethalAscend
    @LethalAscend 2 หลายเดือนก่อน

    lotad