[CentralOH] Web API usage demo

Catherine Devlin catherine.devlin at gmail.com
Thu Feb 25 20:19:13 EST 2021

Hi, folks!  I did a little demo at Thursday's dojo of using requests to get
JSON data from a RESTful API, so here's the code:

import requests
BASE_URL = 'https://ghibliapi.herokuapp.com'
url = f"{BASE_URL}/people"
people = requests.get(url).json()
for person in people:
    for film in person['films']:
        film_response = requests.get(film)
        print(f"    {film_response.json()['title']}")

Of course, you'll need to `pip install requests` first...

- Catherine
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.python.org/pipermail/centraloh/attachments/20210225/8c13e4b7/attachment.html>

More information about the CentralOH mailing list