#100DaysOfCode in Python Transcripts
Chapter: Days 43-45: Consuming HTTP services
Lecture: Concepts

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.
0:03 We started out by consuming the MovieDb service,
0:06 at movie_service.talkpython.fm.
0:10 We saw that we could get postmen,
0:12 which is a really nice way to
0:14 explore and interact with the API,
0:16 the full spectrum of HTTP APIs.
0:19 And we use requests in Python to actually
0:22 do the direct interaction in code.
0:26 When we zoom down to the code level,
0:28 you can see that we start by importing requests.
0:31 We're going to need to use this library,
0:32 so we got to import it, and remember we had to install it
0:34 with pip as well, or make it part of the requirements
0:38 and PyCharm helped us,
0:40 but we could have also said pip install -r requirements.txt
0:43 and achieve the same effect.
0:45 Then we're going to go and actually download the data.
0:49 Take the URL and say, request.get URL.
0:51 Like, this is a response, this is what we work with
0:53 for the rest of the time.
0:55 We want to make sure everything worked,
0:56 so we're going to check for success with raise for status,
0:59 and then we want to take that string of JSON
1:02 and turn it into a Python dictionary.
1:04 So we do that by calling .json.
1:07 Notice if the format is not actually JSON, this will crash.
1:10 But it was JSON in our example, so it completely worked.
1:13 After this it's plain Python,
1:15 there's no more HTTP service involved,
1:17 we just have a Python dictionary,
1:19 and you work with it like you do regular data in Python