#100DaysOfCode in Python Transcripts
Chapter: Days 43-45: Consuming HTTP services
Login or purchase this course to watch this video and the rest of the course contents.
0:00 Let's review the concepts in our search API. We started out by consuming the MovieDb service, at movie_service.talkpython.fm.
0:11 We saw that we could get postmen, which is a really nice way to explore and interact with the API, the full spectrum of HTTP APIs.
0:20 And we use requests in Python to actually do the direct interaction in code. When we zoom down to the code level,
0:29 you can see that we start by importing requests. We're going to need to use this library, so we got to import it, and remember we had to install it
0:35 with pip as well, or make it part of the requirements and PyCharm helped us, but we could have also said pip install -r requirements.txt
0:44 and achieve the same effect. Then we're going to go and actually download the data. Take the URL and say, request.get URL.
0:52 Like, this is a response, this is what we work with for the rest of the time. We want to make sure everything worked,
0:57 so we're going to check for success with raise for status, and then we want to take that string of JSON and turn it into a Python dictionary.
1:05 So we do that by calling .json. Notice if the format is not actually JSON, this will crash. But it was JSON in our example, so it completely worked.
1:14 After this it's plain Python, there's no more HTTP service involved, we just have a Python dictionary,
1:20 and you work with it like you do regular data in Python