How to Access Web APIs using Python Requests and JSON

preview_player
Показать описание
In this video I'll show you how to quickly and easily access web apis and convert the resulting JSON data into a Python dictionary, pull the relevant information out, and print it. We'll be using TV Maze to get information about various TV shows.

Links:

Code:

import requests
import json
import pprint

show = input("Please input a show name. ")
params = {"q":show}


name = data['name']
premiered = data['premiered']
summary = data['summary']

print(f"{name} premiered on {premiered}.")
print(summary)

else:

NEED HELP?

❤️❤️ SHOW SOME LOVE AND SUPPORT THE CHANNEL ❤️❤️

Click Join and Become a Channel Member Today!
Channel members can get preferential comment replies, early access to new content, members only live streams, and access to my private Discord.

LINKS

LEARN MORE PYTHON

LEARN MORE JAVA

#Python #Tutorial #API #JSON
Рекомендации по теме
Комментарии
Автор

I learned to make a simple game from the turtle module from you i think a year ago and thats how i started my python journey...and then learnt a lot of stuff like data science and i was thinking to learn about accesing web api s and this video got recommended to me and i had a quick glance on my journey...thanks a lot mate

abinsyaseen
Автор

Tysm for this tutorial! I appreciate how clear and straight-forward it was. I have a project coming up and after some googling, decided it would be quicker to completely relearn HTTP requests in python rather than fight the other language I was using lol.

lonelypizzaslice
Автор

Thanks for helping me out, just started this week learning Python as my first language. I started the first time coding with js but i'm really not a very motivated learner when i dont have a goal to reach.
For my first learning project i wanted to make a fake donation programm for Twitch streamers using the stream elements api and a simple GUI with customTKinter. Really didnt know why i was having problems with it since i thought it was returning a dictionary. Now i know, appreciate your content even tho this video is 2 years old!

PLAYCOREE
Автор

I came here from Pong video and just wanted to say that you are the best at explaining coding. Thanks!

OK-
Автор

You have literally saved me from failing my class. The explanation is better than what my professor was trying show in the class. Thank you

preciousudo
Автор

This was exactly what I was searching for thank you!

thebdceigal
Автор

I like the way you explain your code Sir. Makes everything very clear... Thanks... 🎉

hdzgrjb
Автор

Simple and easy to follow! Thanks TokyoEdtech

bvladimirpl
Автор

good afternoon!!! nice to meet you, I love your didactics. I'm from Argentina and I'm not fluent in English, but thanks to Python and tutorials of such quality as this one, I'm doing well.
very good explanation, I'm interested in everything about python!!!!, thank you very much, greetings.

luiscarlostrotta
Автор

man ive been waiting for a video on this

jonathanantfolk
Автор

You are the best and you don't get what you deserve

berkayavclar
Автор

thanks, this helped me create a simple program to hopefully get rich in Albion Online

CloroxBleach-vcpw
Автор

very helpful video! btw, you can s
also do response.json() to convert it to a dict instead lf using json module

seadve
Автор

I was wondering if I could have your opinion on something: I’ve been using an animation program for a few months now called Source Filmmaker where you do 3D animation on. I wanted to script for some IK rigs so I looked around on Google to find out how to that when I found this article that shows you how to do that. I read it and right off the bat, the guide told me I needed Python for making the scripts and saving them into Source Filmmakers directory. I spent mostly all of today trying to figure out how to use it and I’ve pretty much have come to the conclusion that I’m gonna have to learn Python step by step. What would you suggest I try?

fx
Автор

Youtube just notified me about this. I am subbed and it ain't sending me notifications :(

thechsen
Автор

Hello! I have recently started to learn things about APIs (what they are, different kinds of requests, etc) and as ive seen, Postman is used alot by data scientists to send HTTP requests to APIs. What are the pros of using Postman? (As ive seen, it sends a http request just as you showed in the video, the only thing that i can notice is that Postman is more efficient, but what other pros does it have?)

sand
Автор

Thanks for the video.
I have an URL in json. How do I make that URL open in browser?

azghar.suhail
Автор

hi, i have a question, when i do the pprint.pprint, it comes up as an error, and says it is undefinied. is there any reason why this would happen?
edit: simple mistake, forgot to import pprint

Butssy
Автор

I know a lot of people have been asking but when are you going to continue space arena

gummies
Автор

This is what I get when I run the help.

Traceback (most recent call last):
File "c:\Users\edemd\Documents\DoamPrograms\py4e\practice\workpage.py", line 15, in <module>
name = data['name']
TypeError: list indices must be integers or slices, not str

stephendoamekpor