{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Exploring the Python Request Library\n", "Many online tools provide Application Programming Interfaces (APIs) through which users can programmatically interact with the tool. Learning to work with APIs in Python can open the door to some exciting and interesting results. The requests library is especially intuitive and effective.\n", "\n", "We'll play around with the https://swapi.co API because it allows access without need for tokens or passwords and has some fun data.\n", "\n", "## About REST APIs\n", "Many APIs are categorized as REST APIs (or perhaps a RESTful APIs). There is quite a bit of quasi-religious discussion about what exactly qualifies as a REST API. Here's what you need to know for this class:\n", " - REST stands for \"representational state transfer\" (which tells us nothing)\n", " - REST APIs use HTTP requests (GET, POST, PUT, and DELETE) to communicate. HTTP is the protocol that runs the web\n", " - REST APIs have become the common approach to providing programmatic access to online applications because they are relatively easy to use\n", "\n", "Since REST APIs are based on HTTP it can be helpful to know the typical semantics of HTTP requests. First, there are four common request types:\n", " 1. GET -- used to request information\n", " 1. POST -- used to create a new item\n", " 1. PUT -- used to modify an existing item\n", " 1. DELETE -- used to delete/remove an item\n", " \n", "Requests typically include a status code. A few common codes:\n", " - 200 -- \"OK\" ... request was handled properly\n", " - 400 -- \"Bad Request\" ... request was malformed or otherwise could not be understood\n", " - 401 -- \"Unauthorized\" ... you don't have permission to access the requested resource\n", " - 404 -- \"Not Found\" ... requested resource wasn't found\n", " - 500 -- \"Internal Server Error\" ... request caused a problem in the server\n", " \n", "It is common for APIs to put a limit on the number of requests made by a client in a day. For this reason it can be helpful to use a Jupyter Notebook such as this for playing with a new API. You can get a single result and play around with the result in subsequent cells without have to re-request the same resource.\n", "\n", "## About JSON\n", "An API can provide responses to GET requests in whatever form it likes. It has become common/conventional for many APIs to provide their repsonse using JSON (JavaScript Object Notation). According to https://www.json.org/ JSON is built on two structures:\n", " - A collection of name/value pairs (like Python's dictionaries)\n", " - An ordered list of values (like Python's lists).\n", "The notation, therefore, will seem very familiar to a Python programmer. To illustrate, suppose we issue a GET request to an API and it responds with a JSON string:\n", "\n", "`'{\"name\":\"John\", \"age\":31, \"city\":\"New York\"}'`\n", "\n", "When we initially retrieve it in a Python program it will be a string. There are a number of libraries and tools, however that can convert a JSON string to a Python variable. Once we convert the string to a variable (say x) it will be stored in our program as a dictionary.\n", "\n", "\n", "## The Requests library\n", "There is a Python library called \"requests\" that provides an elegant notation for working with APIs. To use the requests library you'll need to install it. It can be installed through pip as follows:\n", "> `pip install requests`\n", "\n", "And here we go ..." ] }, { "cell_type": "code", "execution_count": 1, "metadata": { "collapsed": true }, "outputs": [], "source": [ "import requests" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "200" ] }, "execution_count": 2, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# The simplest form of request is to do a get request\n", "# To see the response \n", "r = requests.get(\"https://swapi.co/api/people/1/\")\n", "r.status_code" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "404" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# if we try something that doesn't exist ...\n", "s = requests.get(\"https://swapi.co/api/peo/1/\")\n", "s.status_code" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "'{\"name\":\"Luke Skywalker\",\"height\":\"172\",\"mass\":\"77\",\"hair_color\":\"blond\",\"skin_color\":\"fair\",\"eye_color\":\"blue\",\"birth_year\":\"19BBY\",\"gender\":\"male\",\"homeworld\":\"https://swapi.co/api/planets/1/\",\"films\":[\"https://swapi.co/api/films/2/\",\"https://swapi.co/api/films/6/\",\"https://swapi.co/api/films/3/\",\"https://swapi.co/api/films/1/\",\"https://swapi.co/api/films/7/\"],\"species\":[\"https://swapi.co/api/species/1/\"],\"vehicles\":[\"https://swapi.co/api/vehicles/14/\",\"https://swapi.co/api/vehicles/30/\"],\"starships\":[\"https://swapi.co/api/starships/12/\",\"https://swapi.co/api/starships/22/\"],\"created\":\"2014-12-09T13:50:51.644000Z\",\"edited\":\"2014-12-20T21:17:56.891000Z\",\"url\":\"https://swapi.co/api/people/1/\"}'" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# Let's look back at our successful request ...\n", "r.text" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## JSON string vs. objects \n", "This API returns its results as JSON strings. A variable of type string in Python can be useful sometimes, but the data in the string would be more accessible if it were converted to a Python dictionary. The requests library provides a function for that purpose: .json()\n", "\n", "When manually examining JSON values it can be useful to view results in an indented way. To do so we can import Python's standard json library and use its `.dumps()` function." ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "{'name': 'Luke Skywalker', 'height': '172', 'mass': '77', 'hair_color': 'blond', 'skin_color': 'fair', 'eye_color': 'blue', 'birth_year': '19BBY', 'gender': 'male', 'homeworld': 'https://swapi.co/api/planets/1/', 'films': ['https://swapi.co/api/films/2/', 'https://swapi.co/api/films/6/', 'https://swapi.co/api/films/3/', 'https://swapi.co/api/films/1/', 'https://swapi.co/api/films/7/'], 'species': ['https://swapi.co/api/species/1/'], 'vehicles': ['https://swapi.co/api/vehicles/14/', 'https://swapi.co/api/vehicles/30/'], 'starships': ['https://swapi.co/api/starships/12/', 'https://swapi.co/api/starships/22/'], 'created': '2014-12-09T13:50:51.644000Z', 'edited': '2014-12-20T21:17:56.891000Z', 'url': 'https://swapi.co/api/people/1/'}\n", "['https://swapi.co/api/starships/12/', 'https://swapi.co/api/starships/22/']\n", "https://swapi.co/api/starships/22/\n" ] } ], "source": [ "# we convert the result from a string to a Python dictionary\n", "luke = r.json()\n", "print(luke) # luke is a dictionary\n", "print(luke['starships']) # luke['starships'] is a list\n", "print(luke['starships'][1]) # luke['starships'][0] is a string" ] }, { "cell_type": "code", "execution_count": 6, "metadata": { "collapsed": true }, "outputs": [], "source": [ "# Python's standard JSON library has some useful functionality\n", "import json" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "{\n", " \"name\": \"Luke Skywalker\",\n", " \"height\": \"172\",\n", " \"mass\": \"77\",\n", " \"hair_color\": \"blond\",\n", " \"skin_color\": \"fair\",\n", " \"eye_color\": \"blue\",\n", " \"birth_year\": \"19BBY\",\n", " \"gender\": \"male\",\n", " \"homeworld\": \"https://swapi.co/api/planets/1/\",\n", " \"films\": [\n", " \"https://swapi.co/api/films/2/\",\n", " \"https://swapi.co/api/films/6/\",\n", " \"https://swapi.co/api/films/3/\",\n", " \"https://swapi.co/api/films/1/\",\n", " \"https://swapi.co/api/films/7/\"\n", " ],\n", " \"species\": [\n", " \"https://swapi.co/api/species/1/\"\n", " ],\n", " \"vehicles\": [\n", " \"https://swapi.co/api/vehicles/14/\",\n", " \"https://swapi.co/api/vehicles/30/\"\n", " ],\n", " \"starships\": [\n", " \"https://swapi.co/api/starships/12/\",\n", " \"https://swapi.co/api/starships/22/\"\n", " ],\n", " \"created\": \"2014-12-09T13:50:51.644000Z\",\n", " \"edited\": \"2014-12-20T21:17:56.891000Z\",\n", " \"url\": \"https://swapi.co/api/people/1/\"\n", "}\n" ] } ], "source": [ "# Here we call the dumps function to view the object in an indented way\n", "# ... which is significantly easier for a human to read.\n", "print(json.dumps(luke, indent=4))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Reasoning about URIs\n", "You might guess that since https://swapi.co/api/people/1/ returns information about Luke Skywalker that https://swapi.co/api/people/2/ might give information about another person. And you'd be correct!\n", "\n", "You might also guess that https://swapi.co/api/people/ might return information about all the people. And you'd be partially correct!" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "{'count': 87, 'next': 'https://swapi.co/api/people/?page=2', 'previous': None, 'results': [{'name': 'Luke Skywalker', 'height': '172', 'mass': '77', 'hair_color': 'blond', 'skin_color': 'fair', 'eye_color': 'blue', 'birth_year': '19BBY', 'gender': 'male', 'homeworld': 'https://swapi.co/api/planets/1/', 'films': ['https://swapi.co/api/films/2/', 'https://swapi.co/api/films/6/', 'https://swapi.co/api/films/3/', 'https://swapi.co/api/films/1/', 'https://swapi.co/api/films/7/'], 'species': ['https://swapi.co/api/species/1/'], 'vehicles': ['https://swapi.co/api/vehicles/14/', 'https://swapi.co/api/vehicles/30/'], 'starships': ['https://swapi.co/api/starships/12/', 'https://swapi.co/api/starships/22/'], 'created': '2014-12-09T13:50:51.644000Z', 'edited': '2014-12-20T21:17:56.891000Z', 'url': 'https://swapi.co/api/people/1/'}, {'name': 'C-3PO', 'height': '167', 'mass': '75', 'hair_color': 'n/a', 'skin_color': 'gold', 'eye_color': 'yellow', 'birth_year': '112BBY', 'gender': 'n/a', 'homeworld': 'https://swapi.co/api/planets/1/', 'films': ['https://swapi.co/api/films/2/', 'https://swapi.co/api/films/5/', 'https://swapi.co/api/films/4/', 'https://swapi.co/api/films/6/', 'https://swapi.co/api/films/3/', 'https://swapi.co/api/films/1/'], 'species': ['https://swapi.co/api/species/2/'], 'vehicles': [], 'starships': [], 'created': '2014-12-10T15:10:51.357000Z', 'edited': '2014-12-20T21:17:50.309000Z', 'url': 'https://swapi.co/api/people/2/'}, {'name': 'R2-D2', 'height': '96', 'mass': '32', 'hair_color': 'n/a', 'skin_color': 'white, blue', 'eye_color': 'red', 'birth_year': '33BBY', 'gender': 'n/a', 'homeworld': 'https://swapi.co/api/planets/8/', 'films': ['https://swapi.co/api/films/2/', 'https://swapi.co/api/films/5/', 'https://swapi.co/api/films/4/', 'https://swapi.co/api/films/6/', 'https://swapi.co/api/films/3/', 'https://swapi.co/api/films/1/', 'https://swapi.co/api/films/7/'], 'species': ['https://swapi.co/api/species/2/'], 'vehicles': [], 'starships': [], 'created': '2014-12-10T15:11:50.376000Z', 'edited': '2014-12-20T21:17:50.311000Z', 'url': 'https://swapi.co/api/people/3/'}, {'name': 'Darth Vader', 'height': '202', 'mass': '136', 'hair_color': 'none', 'skin_color': 'white', 'eye_color': 'yellow', 'birth_year': '41.9BBY', 'gender': 'male', 'homeworld': 'https://swapi.co/api/planets/1/', 'films': ['https://swapi.co/api/films/2/', 'https://swapi.co/api/films/6/', 'https://swapi.co/api/films/3/', 'https://swapi.co/api/films/1/'], 'species': ['https://swapi.co/api/species/1/'], 'vehicles': [], 'starships': ['https://swapi.co/api/starships/13/'], 'created': '2014-12-10T15:18:20.704000Z', 'edited': '2014-12-20T21:17:50.313000Z', 'url': 'https://swapi.co/api/people/4/'}, {'name': 'Leia Organa', 'height': '150', 'mass': '49', 'hair_color': 'brown', 'skin_color': 'light', 'eye_color': 'brown', 'birth_year': '19BBY', 'gender': 'female', 'homeworld': 'https://swapi.co/api/planets/2/', 'films': ['https://swapi.co/api/films/2/', 'https://swapi.co/api/films/6/', 'https://swapi.co/api/films/3/', 'https://swapi.co/api/films/1/', 'https://swapi.co/api/films/7/'], 'species': ['https://swapi.co/api/species/1/'], 'vehicles': ['https://swapi.co/api/vehicles/30/'], 'starships': [], 'created': '2014-12-10T15:20:09.791000Z', 'edited': '2014-12-20T21:17:50.315000Z', 'url': 'https://swapi.co/api/people/5/'}, {'name': 'Owen Lars', 'height': '178', 'mass': '120', 'hair_color': 'brown, grey', 'skin_color': 'light', 'eye_color': 'blue', 'birth_year': '52BBY', 'gender': 'male', 'homeworld': 'https://swapi.co/api/planets/1/', 'films': ['https://swapi.co/api/films/5/', 'https://swapi.co/api/films/6/', 'https://swapi.co/api/films/1/'], 'species': ['https://swapi.co/api/species/1/'], 'vehicles': [], 'starships': [], 'created': '2014-12-10T15:52:14.024000Z', 'edited': '2014-12-20T21:17:50.317000Z', 'url': 'https://swapi.co/api/people/6/'}, {'name': 'Beru Whitesun lars', 'height': '165', 'mass': '75', 'hair_color': 'brown', 'skin_color': 'light', 'eye_color': 'blue', 'birth_year': '47BBY', 'gender': 'female', 'homeworld': 'https://swapi.co/api/planets/1/', 'films': ['https://swapi.co/api/films/5/', 'https://swapi.co/api/films/6/', 'https://swapi.co/api/films/1/'], 'species': ['https://swapi.co/api/species/1/'], 'vehicles': [], 'starships': [], 'created': '2014-12-10T15:53:41.121000Z', 'edited': '2014-12-20T21:17:50.319000Z', 'url': 'https://swapi.co/api/people/7/'}, {'name': 'R5-D4', 'height': '97', 'mass': '32', 'hair_color': 'n/a', 'skin_color': 'white, red', 'eye_color': 'red', 'birth_year': 'unknown', 'gender': 'n/a', 'homeworld': 'https://swapi.co/api/planets/1/', 'films': ['https://swapi.co/api/films/1/'], 'species': ['https://swapi.co/api/species/2/'], 'vehicles': [], 'starships': [], 'created': '2014-12-10T15:57:50.959000Z', 'edited': '2014-12-20T21:17:50.321000Z', 'url': 'https://swapi.co/api/people/8/'}, {'name': 'Biggs Darklighter', 'height': '183', 'mass': '84', 'hair_color': 'black', 'skin_color': 'light', 'eye_color': 'brown', 'birth_year': '24BBY', 'gender': 'male', 'homeworld': 'https://swapi.co/api/planets/1/', 'films': ['https://swapi.co/api/films/1/'], 'species': ['https://swapi.co/api/species/1/'], 'vehicles': [], 'starships': ['https://swapi.co/api/starships/12/'], 'created': '2014-12-10T15:59:50.509000Z', 'edited': '2014-12-20T21:17:50.323000Z', 'url': 'https://swapi.co/api/people/9/'}, {'name': 'Obi-Wan Kenobi', 'height': '182', 'mass': '77', 'hair_color': 'auburn, white', 'skin_color': 'fair', 'eye_color': 'blue-gray', 'birth_year': '57BBY', 'gender': 'male', 'homeworld': 'https://swapi.co/api/planets/20/', 'films': ['https://swapi.co/api/films/2/', 'https://swapi.co/api/films/5/', 'https://swapi.co/api/films/4/', 'https://swapi.co/api/films/6/', 'https://swapi.co/api/films/3/', 'https://swapi.co/api/films/1/'], 'species': ['https://swapi.co/api/species/1/'], 'vehicles': ['https://swapi.co/api/vehicles/38/'], 'starships': ['https://swapi.co/api/starships/48/', 'https://swapi.co/api/starships/59/', 'https://swapi.co/api/starships/64/', 'https://swapi.co/api/starships/65/', 'https://swapi.co/api/starships/74/'], 'created': '2014-12-10T16:16:29.192000Z', 'edited': '2014-12-20T21:17:50.325000Z', 'url': 'https://swapi.co/api/people/10/'}]}\n" ] } ], "source": [ "people = requests.get(\"https://swapi.co/api/people/\").json()\n", "print(people)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Handling partial lists\n", "It is pretty common for APIs to give paginated results for requests that match a large data set. Some APIs allow you to specify a query string to indicate you want to retrieve more than the default number of matching items. In other cases, they give \"previous\" and \"next\" URIs to guide you toward getting additional entries. Inspection of the result above show that SWAPI provides its response as a dictionary with 4 entries:\n", " - previous: URI of previous page of results\n", " - results: the actual results that were requested (10 maximum)\n", " - count: the number of results that are available\n", " - next: URI of the next page of results" ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "None\n", "87\n", "https://swapi.co/api/people/?page=2\n" ] } ], "source": [ "print(people[\"previous\"])\n", "print(people[\"count\"])\n", "print(people[\"next\"])" ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "{'count': 87, 'next': 'https://swapi.co/api/people/?page=3', 'previous': 'https://swapi.co/api/people/?page=1', 'results': [{'name': 'Anakin Skywalker', 'height': '188', 'mass': '84', 'hair_color': 'blond', 'skin_color': 'fair', 'eye_color': 'blue', 'birth_year': '41.9BBY', 'gender': 'male', 'homeworld': 'https://swapi.co/api/planets/1/', 'films': ['https://swapi.co/api/films/5/', 'https://swapi.co/api/films/4/', 'https://swapi.co/api/films/6/'], 'species': ['https://swapi.co/api/species/1/'], 'vehicles': ['https://swapi.co/api/vehicles/44/', 'https://swapi.co/api/vehicles/46/'], 'starships': ['https://swapi.co/api/starships/59/', 'https://swapi.co/api/starships/65/', 'https://swapi.co/api/starships/39/'], 'created': '2014-12-10T16:20:44.310000Z', 'edited': '2014-12-20T21:17:50.327000Z', 'url': 'https://swapi.co/api/people/11/'}, {'name': 'Wilhuff Tarkin', 'height': '180', 'mass': 'unknown', 'hair_color': 'auburn, grey', 'skin_color': 'fair', 'eye_color': 'blue', 'birth_year': '64BBY', 'gender': 'male', 'homeworld': 'https://swapi.co/api/planets/21/', 'films': ['https://swapi.co/api/films/6/', 'https://swapi.co/api/films/1/'], 'species': ['https://swapi.co/api/species/1/'], 'vehicles': [], 'starships': [], 'created': '2014-12-10T16:26:56.138000Z', 'edited': '2014-12-20T21:17:50.330000Z', 'url': 'https://swapi.co/api/people/12/'}, {'name': 'Chewbacca', 'height': '228', 'mass': '112', 'hair_color': 'brown', 'skin_color': 'unknown', 'eye_color': 'blue', 'birth_year': '200BBY', 'gender': 'male', 'homeworld': 'https://swapi.co/api/planets/14/', 'films': ['https://swapi.co/api/films/2/', 'https://swapi.co/api/films/6/', 'https://swapi.co/api/films/3/', 'https://swapi.co/api/films/1/', 'https://swapi.co/api/films/7/'], 'species': ['https://swapi.co/api/species/3/'], 'vehicles': ['https://swapi.co/api/vehicles/19/'], 'starships': ['https://swapi.co/api/starships/10/', 'https://swapi.co/api/starships/22/'], 'created': '2014-12-10T16:42:45.066000Z', 'edited': '2014-12-20T21:17:50.332000Z', 'url': 'https://swapi.co/api/people/13/'}, {'name': 'Han Solo', 'height': '180', 'mass': '80', 'hair_color': 'brown', 'skin_color': 'fair', 'eye_color': 'brown', 'birth_year': '29BBY', 'gender': 'male', 'homeworld': 'https://swapi.co/api/planets/22/', 'films': ['https://swapi.co/api/films/2/', 'https://swapi.co/api/films/3/', 'https://swapi.co/api/films/1/', 'https://swapi.co/api/films/7/'], 'species': ['https://swapi.co/api/species/1/'], 'vehicles': [], 'starships': ['https://swapi.co/api/starships/10/', 'https://swapi.co/api/starships/22/'], 'created': '2014-12-10T16:49:14.582000Z', 'edited': '2014-12-20T21:17:50.334000Z', 'url': 'https://swapi.co/api/people/14/'}, {'name': 'Greedo', 'height': '173', 'mass': '74', 'hair_color': 'n/a', 'skin_color': 'green', 'eye_color': 'black', 'birth_year': '44BBY', 'gender': 'male', 'homeworld': 'https://swapi.co/api/planets/23/', 'films': ['https://swapi.co/api/films/1/'], 'species': ['https://swapi.co/api/species/4/'], 'vehicles': [], 'starships': [], 'created': '2014-12-10T17:03:30.334000Z', 'edited': '2014-12-20T21:17:50.336000Z', 'url': 'https://swapi.co/api/people/15/'}, {'name': 'Jabba Desilijic Tiure', 'height': '175', 'mass': '1,358', 'hair_color': 'n/a', 'skin_color': 'green-tan, brown', 'eye_color': 'orange', 'birth_year': '600BBY', 'gender': 'hermaphrodite', 'homeworld': 'https://swapi.co/api/planets/24/', 'films': ['https://swapi.co/api/films/4/', 'https://swapi.co/api/films/3/', 'https://swapi.co/api/films/1/'], 'species': ['https://swapi.co/api/species/5/'], 'vehicles': [], 'starships': [], 'created': '2014-12-10T17:11:31.638000Z', 'edited': '2014-12-20T21:17:50.338000Z', 'url': 'https://swapi.co/api/people/16/'}, {'name': 'Wedge Antilles', 'height': '170', 'mass': '77', 'hair_color': 'brown', 'skin_color': 'fair', 'eye_color': 'hazel', 'birth_year': '21BBY', 'gender': 'male', 'homeworld': 'https://swapi.co/api/planets/22/', 'films': ['https://swapi.co/api/films/2/', 'https://swapi.co/api/films/3/', 'https://swapi.co/api/films/1/'], 'species': ['https://swapi.co/api/species/1/'], 'vehicles': ['https://swapi.co/api/vehicles/14/'], 'starships': ['https://swapi.co/api/starships/12/'], 'created': '2014-12-12T11:08:06.469000Z', 'edited': '2014-12-20T21:17:50.341000Z', 'url': 'https://swapi.co/api/people/18/'}, {'name': 'Jek Tono Porkins', 'height': '180', 'mass': '110', 'hair_color': 'brown', 'skin_color': 'fair', 'eye_color': 'blue', 'birth_year': 'unknown', 'gender': 'male', 'homeworld': 'https://swapi.co/api/planets/26/', 'films': ['https://swapi.co/api/films/1/'], 'species': ['https://swapi.co/api/species/1/'], 'vehicles': [], 'starships': ['https://swapi.co/api/starships/12/'], 'created': '2014-12-12T11:16:56.569000Z', 'edited': '2014-12-20T21:17:50.343000Z', 'url': 'https://swapi.co/api/people/19/'}, {'name': 'Yoda', 'height': '66', 'mass': '17', 'hair_color': 'white', 'skin_color': 'green', 'eye_color': 'brown', 'birth_year': '896BBY', 'gender': 'male', 'homeworld': 'https://swapi.co/api/planets/28/', 'films': ['https://swapi.co/api/films/2/', 'https://swapi.co/api/films/5/', 'https://swapi.co/api/films/4/', 'https://swapi.co/api/films/6/', 'https://swapi.co/api/films/3/'], 'species': ['https://swapi.co/api/species/6/'], 'vehicles': [], 'starships': [], 'created': '2014-12-15T12:26:01.042000Z', 'edited': '2014-12-20T21:17:50.345000Z', 'url': 'https://swapi.co/api/people/20/'}, {'name': 'Palpatine', 'height': '170', 'mass': '75', 'hair_color': 'grey', 'skin_color': 'pale', 'eye_color': 'yellow', 'birth_year': '82BBY', 'gender': 'male', 'homeworld': 'https://swapi.co/api/planets/8/', 'films': ['https://swapi.co/api/films/2/', 'https://swapi.co/api/films/5/', 'https://swapi.co/api/films/4/', 'https://swapi.co/api/films/6/', 'https://swapi.co/api/films/3/'], 'species': ['https://swapi.co/api/species/1/'], 'vehicles': [], 'starships': [], 'created': '2014-12-15T12:48:05.971000Z', 'edited': '2014-12-20T21:17:50.347000Z', 'url': 'https://swapi.co/api/people/21/'}]}\n" ] } ], "source": [ "# Let's see the next page ...\n", "people2 = requests.get(\"https://swapi.co/api/people/?page=2\").json()\n", "print(people2)" ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "https://swapi.co/api/people/?page=1\n", "87\n", "https://swapi.co/api/people/?page=3\n" ] } ], "source": [ "print(people2[\"previous\"])\n", "print(people2[\"count\"])\n", "print(people2[\"next\"])" ] }, { "cell_type": "code", "execution_count": 12, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "[{'birth_year': '19BBY',\n", " 'created': '2014-12-09T13:50:51.644000Z',\n", " 'edited': '2014-12-20T21:17:56.891000Z',\n", " 'eye_color': 'blue',\n", " 'films': ['https://swapi.co/api/films/2/',\n", " 'https://swapi.co/api/films/6/',\n", " 'https://swapi.co/api/films/3/',\n", " 'https://swapi.co/api/films/1/',\n", " 'https://swapi.co/api/films/7/'],\n", " 'gender': 'male',\n", " 'hair_color': 'blond',\n", " 'height': '172',\n", " 'homeworld': 'https://swapi.co/api/planets/1/',\n", " 'mass': '77',\n", " 'name': 'Luke Skywalker',\n", " 'skin_color': 'fair',\n", " 'species': ['https://swapi.co/api/species/1/'],\n", " 'starships': ['https://swapi.co/api/starships/12/',\n", " 'https://swapi.co/api/starships/22/'],\n", " 'url': 'https://swapi.co/api/people/1/',\n", " 'vehicles': ['https://swapi.co/api/vehicles/14/',\n", " 'https://swapi.co/api/vehicles/30/']},\n", " {'birth_year': '112BBY',\n", " 'created': '2014-12-10T15:10:51.357000Z',\n", " 'edited': '2014-12-20T21:17:50.309000Z',\n", " 'eye_color': 'yellow',\n", " 'films': ['https://swapi.co/api/films/2/',\n", " 'https://swapi.co/api/films/5/',\n", " 'https://swapi.co/api/films/4/',\n", " 'https://swapi.co/api/films/6/',\n", " 'https://swapi.co/api/films/3/',\n", " 'https://swapi.co/api/films/1/'],\n", " 'gender': 'n/a',\n", " 'hair_color': 'n/a',\n", " 'height': '167',\n", " 'homeworld': 'https://swapi.co/api/planets/1/',\n", " 'mass': '75',\n", " 'name': 'C-3PO',\n", " 'skin_color': 'gold',\n", " 'species': ['https://swapi.co/api/species/2/'],\n", " 'starships': [],\n", " 'url': 'https://swapi.co/api/people/2/',\n", " 'vehicles': []},\n", " {'birth_year': '33BBY',\n", " 'created': '2014-12-10T15:11:50.376000Z',\n", " 'edited': '2014-12-20T21:17:50.311000Z',\n", " 'eye_color': 'red',\n", " 'films': ['https://swapi.co/api/films/2/',\n", " 'https://swapi.co/api/films/5/',\n", " 'https://swapi.co/api/films/4/',\n", " 'https://swapi.co/api/films/6/',\n", " 'https://swapi.co/api/films/3/',\n", " 'https://swapi.co/api/films/1/',\n", " 'https://swapi.co/api/films/7/'],\n", " 'gender': 'n/a',\n", " 'hair_color': 'n/a',\n", " 'height': '96',\n", " 'homeworld': 'https://swapi.co/api/planets/8/',\n", " 'mass': '32',\n", " 'name': 'R2-D2',\n", " 'skin_color': 'white, blue',\n", " 'species': ['https://swapi.co/api/species/2/'],\n", " 'starships': [],\n", " 'url': 'https://swapi.co/api/people/3/',\n", " 'vehicles': []},\n", " {'birth_year': '41.9BBY',\n", " 'created': '2014-12-10T15:18:20.704000Z',\n", " 'edited': '2014-12-20T21:17:50.313000Z',\n", " 'eye_color': 'yellow',\n", " 'films': ['https://swapi.co/api/films/2/',\n", " 'https://swapi.co/api/films/6/',\n", " 'https://swapi.co/api/films/3/',\n", " 'https://swapi.co/api/films/1/'],\n", " 'gender': 'male',\n", " 'hair_color': 'none',\n", " 'height': '202',\n", " 'homeworld': 'https://swapi.co/api/planets/1/',\n", " 'mass': '136',\n", " 'name': 'Darth Vader',\n", " 'skin_color': 'white',\n", " 'species': ['https://swapi.co/api/species/1/'],\n", " 'starships': ['https://swapi.co/api/starships/13/'],\n", " 'url': 'https://swapi.co/api/people/4/',\n", " 'vehicles': []},\n", " {'birth_year': '19BBY',\n", " 'created': '2014-12-10T15:20:09.791000Z',\n", " 'edited': '2014-12-20T21:17:50.315000Z',\n", " 'eye_color': 'brown',\n", " 'films': ['https://swapi.co/api/films/2/',\n", " 'https://swapi.co/api/films/6/',\n", " 'https://swapi.co/api/films/3/',\n", " 'https://swapi.co/api/films/1/',\n", " 'https://swapi.co/api/films/7/'],\n", " 'gender': 'female',\n", " 'hair_color': 'brown',\n", " 'height': '150',\n", " 'homeworld': 'https://swapi.co/api/planets/2/',\n", " 'mass': '49',\n", " 'name': 'Leia Organa',\n", " 'skin_color': 'light',\n", " 'species': ['https://swapi.co/api/species/1/'],\n", " 'starships': [],\n", " 'url': 'https://swapi.co/api/people/5/',\n", " 'vehicles': ['https://swapi.co/api/vehicles/30/']},\n", " {'birth_year': '52BBY',\n", " 'created': '2014-12-10T15:52:14.024000Z',\n", " 'edited': '2014-12-20T21:17:50.317000Z',\n", " 'eye_color': 'blue',\n", " 'films': ['https://swapi.co/api/films/5/',\n", " 'https://swapi.co/api/films/6/',\n", " 'https://swapi.co/api/films/1/'],\n", " 'gender': 'male',\n", " 'hair_color': 'brown, grey',\n", " 'height': '178',\n", " 'homeworld': 'https://swapi.co/api/planets/1/',\n", " 'mass': '120',\n", " 'name': 'Owen Lars',\n", " 'skin_color': 'light',\n", " 'species': ['https://swapi.co/api/species/1/'],\n", " 'starships': [],\n", " 'url': 'https://swapi.co/api/people/6/',\n", " 'vehicles': []},\n", " {'birth_year': '47BBY',\n", " 'created': '2014-12-10T15:53:41.121000Z',\n", " 'edited': '2014-12-20T21:17:50.319000Z',\n", " 'eye_color': 'blue',\n", " 'films': ['https://swapi.co/api/films/5/',\n", " 'https://swapi.co/api/films/6/',\n", " 'https://swapi.co/api/films/1/'],\n", " 'gender': 'female',\n", " 'hair_color': 'brown',\n", " 'height': '165',\n", " 'homeworld': 'https://swapi.co/api/planets/1/',\n", " 'mass': '75',\n", " 'name': 'Beru Whitesun lars',\n", " 'skin_color': 'light',\n", " 'species': ['https://swapi.co/api/species/1/'],\n", " 'starships': [],\n", " 'url': 'https://swapi.co/api/people/7/',\n", " 'vehicles': []},\n", " {'birth_year': 'unknown',\n", " 'created': '2014-12-10T15:57:50.959000Z',\n", " 'edited': '2014-12-20T21:17:50.321000Z',\n", " 'eye_color': 'red',\n", " 'films': ['https://swapi.co/api/films/1/'],\n", " 'gender': 'n/a',\n", " 'hair_color': 'n/a',\n", " 'height': '97',\n", " 'homeworld': 'https://swapi.co/api/planets/1/',\n", " 'mass': '32',\n", " 'name': 'R5-D4',\n", " 'skin_color': 'white, red',\n", " 'species': ['https://swapi.co/api/species/2/'],\n", " 'starships': [],\n", " 'url': 'https://swapi.co/api/people/8/',\n", " 'vehicles': []},\n", " {'birth_year': '24BBY',\n", " 'created': '2014-12-10T15:59:50.509000Z',\n", " 'edited': '2014-12-20T21:17:50.323000Z',\n", " 'eye_color': 'brown',\n", " 'films': ['https://swapi.co/api/films/1/'],\n", " 'gender': 'male',\n", " 'hair_color': 'black',\n", " 'height': '183',\n", " 'homeworld': 'https://swapi.co/api/planets/1/',\n", " 'mass': '84',\n", " 'name': 'Biggs Darklighter',\n", " 'skin_color': 'light',\n", " 'species': ['https://swapi.co/api/species/1/'],\n", " 'starships': ['https://swapi.co/api/starships/12/'],\n", " 'url': 'https://swapi.co/api/people/9/',\n", " 'vehicles': []},\n", " {'birth_year': '57BBY',\n", " 'created': '2014-12-10T16:16:29.192000Z',\n", " 'edited': '2014-12-20T21:17:50.325000Z',\n", " 'eye_color': 'blue-gray',\n", " 'films': ['https://swapi.co/api/films/2/',\n", " 'https://swapi.co/api/films/5/',\n", " 'https://swapi.co/api/films/4/',\n", " 'https://swapi.co/api/films/6/',\n", " 'https://swapi.co/api/films/3/',\n", " 'https://swapi.co/api/films/1/'],\n", " 'gender': 'male',\n", " 'hair_color': 'auburn, white',\n", " 'height': '182',\n", " 'homeworld': 'https://swapi.co/api/planets/20/',\n", " 'mass': '77',\n", " 'name': 'Obi-Wan Kenobi',\n", " 'skin_color': 'fair',\n", " 'species': ['https://swapi.co/api/species/1/'],\n", " 'starships': ['https://swapi.co/api/starships/48/',\n", " 'https://swapi.co/api/starships/59/',\n", " 'https://swapi.co/api/starships/64/',\n", " 'https://swapi.co/api/starships/65/',\n", " 'https://swapi.co/api/starships/74/'],\n", " 'url': 'https://swapi.co/api/people/10/',\n", " 'vehicles': ['https://swapi.co/api/vehicles/38/']},\n", " {'birth_year': '41.9BBY',\n", " 'created': '2014-12-10T16:20:44.310000Z',\n", " 'edited': '2014-12-20T21:17:50.327000Z',\n", " 'eye_color': 'blue',\n", " 'films': ['https://swapi.co/api/films/5/',\n", " 'https://swapi.co/api/films/4/',\n", " 'https://swapi.co/api/films/6/'],\n", " 'gender': 'male',\n", " 'hair_color': 'blond',\n", " 'height': '188',\n", " 'homeworld': 'https://swapi.co/api/planets/1/',\n", " 'mass': '84',\n", " 'name': 'Anakin Skywalker',\n", " 'skin_color': 'fair',\n", " 'species': ['https://swapi.co/api/species/1/'],\n", " 'starships': ['https://swapi.co/api/starships/59/',\n", " 'https://swapi.co/api/starships/65/',\n", " 'https://swapi.co/api/starships/39/'],\n", " 'url': 'https://swapi.co/api/people/11/',\n", " 'vehicles': ['https://swapi.co/api/vehicles/44/',\n", " 'https://swapi.co/api/vehicles/46/']},\n", " {'birth_year': '64BBY',\n", " 'created': '2014-12-10T16:26:56.138000Z',\n", " 'edited': '2014-12-20T21:17:50.330000Z',\n", " 'eye_color': 'blue',\n", " 'films': ['https://swapi.co/api/films/6/', 'https://swapi.co/api/films/1/'],\n", " 'gender': 'male',\n", " 'hair_color': 'auburn, grey',\n", " 'height': '180',\n", " 'homeworld': 'https://swapi.co/api/planets/21/',\n", " 'mass': 'unknown',\n", " 'name': 'Wilhuff Tarkin',\n", " 'skin_color': 'fair',\n", " 'species': ['https://swapi.co/api/species/1/'],\n", " 'starships': [],\n", " 'url': 'https://swapi.co/api/people/12/',\n", " 'vehicles': []},\n", " {'birth_year': '200BBY',\n", " 'created': '2014-12-10T16:42:45.066000Z',\n", " 'edited': '2014-12-20T21:17:50.332000Z',\n", " 'eye_color': 'blue',\n", " 'films': ['https://swapi.co/api/films/2/',\n", " 'https://swapi.co/api/films/6/',\n", " 'https://swapi.co/api/films/3/',\n", " 'https://swapi.co/api/films/1/',\n", " 'https://swapi.co/api/films/7/'],\n", " 'gender': 'male',\n", " 'hair_color': 'brown',\n", " 'height': '228',\n", " 'homeworld': 'https://swapi.co/api/planets/14/',\n", " 'mass': '112',\n", " 'name': 'Chewbacca',\n", " 'skin_color': 'unknown',\n", " 'species': ['https://swapi.co/api/species/3/'],\n", " 'starships': ['https://swapi.co/api/starships/10/',\n", " 'https://swapi.co/api/starships/22/'],\n", " 'url': 'https://swapi.co/api/people/13/',\n", " 'vehicles': ['https://swapi.co/api/vehicles/19/']},\n", " {'birth_year': '29BBY',\n", " 'created': '2014-12-10T16:49:14.582000Z',\n", " 'edited': '2014-12-20T21:17:50.334000Z',\n", " 'eye_color': 'brown',\n", " 'films': ['https://swapi.co/api/films/2/',\n", " 'https://swapi.co/api/films/3/',\n", " 'https://swapi.co/api/films/1/',\n", " 'https://swapi.co/api/films/7/'],\n", " 'gender': 'male',\n", " 'hair_color': 'brown',\n", " 'height': '180',\n", " 'homeworld': 'https://swapi.co/api/planets/22/',\n", " 'mass': '80',\n", " 'name': 'Han Solo',\n", " 'skin_color': 'fair',\n", " 'species': ['https://swapi.co/api/species/1/'],\n", " 'starships': ['https://swapi.co/api/starships/10/',\n", " 'https://swapi.co/api/starships/22/'],\n", " 'url': 'https://swapi.co/api/people/14/',\n", " 'vehicles': []},\n", " {'birth_year': '44BBY',\n", " 'created': '2014-12-10T17:03:30.334000Z',\n", " 'edited': '2014-12-20T21:17:50.336000Z',\n", " 'eye_color': 'black',\n", " 'films': ['https://swapi.co/api/films/1/'],\n", " 'gender': 'male',\n", " 'hair_color': 'n/a',\n", " 'height': '173',\n", " 'homeworld': 'https://swapi.co/api/planets/23/',\n", " 'mass': '74',\n", " 'name': 'Greedo',\n", " 'skin_color': 'green',\n", " 'species': ['https://swapi.co/api/species/4/'],\n", " 'starships': [],\n", " 'url': 'https://swapi.co/api/people/15/',\n", " 'vehicles': []},\n", " {'birth_year': '600BBY',\n", " 'created': '2014-12-10T17:11:31.638000Z',\n", " 'edited': '2014-12-20T21:17:50.338000Z',\n", " 'eye_color': 'orange',\n", " 'films': ['https://swapi.co/api/films/4/',\n", " 'https://swapi.co/api/films/3/',\n", " 'https://swapi.co/api/films/1/'],\n", " 'gender': 'hermaphrodite',\n", " 'hair_color': 'n/a',\n", " 'height': '175',\n", " 'homeworld': 'https://swapi.co/api/planets/24/',\n", " 'mass': '1,358',\n", " 'name': 'Jabba Desilijic Tiure',\n", " 'skin_color': 'green-tan, brown',\n", " 'species': ['https://swapi.co/api/species/5/'],\n", " 'starships': [],\n", " 'url': 'https://swapi.co/api/people/16/',\n", " 'vehicles': []},\n", " {'birth_year': '21BBY',\n", " 'created': '2014-12-12T11:08:06.469000Z',\n", " 'edited': '2014-12-20T21:17:50.341000Z',\n", " 'eye_color': 'hazel',\n", " 'films': ['https://swapi.co/api/films/2/',\n", " 'https://swapi.co/api/films/3/',\n", " 'https://swapi.co/api/films/1/'],\n", " 'gender': 'male',\n", " 'hair_color': 'brown',\n", " 'height': '170',\n", " 'homeworld': 'https://swapi.co/api/planets/22/',\n", " 'mass': '77',\n", " 'name': 'Wedge Antilles',\n", " 'skin_color': 'fair',\n", " 'species': ['https://swapi.co/api/species/1/'],\n", " 'starships': ['https://swapi.co/api/starships/12/'],\n", " 'url': 'https://swapi.co/api/people/18/',\n", " 'vehicles': ['https://swapi.co/api/vehicles/14/']},\n", " {'birth_year': 'unknown',\n", " 'created': '2014-12-12T11:16:56.569000Z',\n", " 'edited': '2014-12-20T21:17:50.343000Z',\n", " 'eye_color': 'blue',\n", " 'films': ['https://swapi.co/api/films/1/'],\n", " 'gender': 'male',\n", " 'hair_color': 'brown',\n", " 'height': '180',\n", " 'homeworld': 'https://swapi.co/api/planets/26/',\n", " 'mass': '110',\n", " 'name': 'Jek Tono Porkins',\n", " 'skin_color': 'fair',\n", " 'species': ['https://swapi.co/api/species/1/'],\n", " 'starships': ['https://swapi.co/api/starships/12/'],\n", " 'url': 'https://swapi.co/api/people/19/',\n", " 'vehicles': []},\n", " {'birth_year': '896BBY',\n", " 'created': '2014-12-15T12:26:01.042000Z',\n", " 'edited': '2014-12-20T21:17:50.345000Z',\n", " 'eye_color': 'brown',\n", " 'films': ['https://swapi.co/api/films/2/',\n", " 'https://swapi.co/api/films/5/',\n", " 'https://swapi.co/api/films/4/',\n", " 'https://swapi.co/api/films/6/',\n", " 'https://swapi.co/api/films/3/'],\n", " 'gender': 'male',\n", " 'hair_color': 'white',\n", " 'height': '66',\n", " 'homeworld': 'https://swapi.co/api/planets/28/',\n", " 'mass': '17',\n", " 'name': 'Yoda',\n", " 'skin_color': 'green',\n", " 'species': ['https://swapi.co/api/species/6/'],\n", " 'starships': [],\n", " 'url': 'https://swapi.co/api/people/20/',\n", " 'vehicles': []},\n", " {'birth_year': '82BBY',\n", " 'created': '2014-12-15T12:48:05.971000Z',\n", " 'edited': '2014-12-20T21:17:50.347000Z',\n", " 'eye_color': 'yellow',\n", " 'films': ['https://swapi.co/api/films/2/',\n", " 'https://swapi.co/api/films/5/',\n", " 'https://swapi.co/api/films/4/',\n", " 'https://swapi.co/api/films/6/',\n", " 'https://swapi.co/api/films/3/'],\n", " 'gender': 'male',\n", " 'hair_color': 'grey',\n", " 'height': '170',\n", " 'homeworld': 'https://swapi.co/api/planets/8/',\n", " 'mass': '75',\n", " 'name': 'Palpatine',\n", " 'skin_color': 'pale',\n", " 'species': ['https://swapi.co/api/species/1/'],\n", " 'starships': [],\n", " 'url': 'https://swapi.co/api/people/21/',\n", " 'vehicles': []},\n", " {'birth_year': '31.5BBY',\n", " 'created': '2014-12-15T12:49:32.457000Z',\n", " 'edited': '2014-12-20T21:17:50.349000Z',\n", " 'eye_color': 'brown',\n", " 'films': ['https://swapi.co/api/films/2/',\n", " 'https://swapi.co/api/films/5/',\n", " 'https://swapi.co/api/films/3/'],\n", " 'gender': 'male',\n", " 'hair_color': 'black',\n", " 'height': '183',\n", " 'homeworld': 'https://swapi.co/api/planets/10/',\n", " 'mass': '78.2',\n", " 'name': 'Boba Fett',\n", " 'skin_color': 'fair',\n", " 'species': ['https://swapi.co/api/species/1/'],\n", " 'starships': ['https://swapi.co/api/starships/21/'],\n", " 'url': 'https://swapi.co/api/people/22/',\n", " 'vehicles': []},\n", " {'birth_year': '15BBY',\n", " 'created': '2014-12-15T12:51:10.076000Z',\n", " 'edited': '2014-12-20T21:17:50.351000Z',\n", " 'eye_color': 'red',\n", " 'films': ['https://swapi.co/api/films/2/'],\n", " 'gender': 'none',\n", " 'hair_color': 'none',\n", " 'height': '200',\n", " 'homeworld': 'https://swapi.co/api/planets/28/',\n", " 'mass': '140',\n", " 'name': 'IG-88',\n", " 'skin_color': 'metal',\n", " 'species': ['https://swapi.co/api/species/2/'],\n", " 'starships': [],\n", " 'url': 'https://swapi.co/api/people/23/',\n", " 'vehicles': []},\n", " {'birth_year': '53BBY',\n", " 'created': '2014-12-15T12:53:49.297000Z',\n", " 'edited': '2014-12-20T21:17:50.355000Z',\n", " 'eye_color': 'red',\n", " 'films': ['https://swapi.co/api/films/2/'],\n", " 'gender': 'male',\n", " 'hair_color': 'none',\n", " 'height': '190',\n", " 'homeworld': 'https://swapi.co/api/planets/29/',\n", " 'mass': '113',\n", " 'name': 'Bossk',\n", " 'skin_color': 'green',\n", " 'species': ['https://swapi.co/api/species/7/'],\n", " 'starships': [],\n", " 'url': 'https://swapi.co/api/people/24/',\n", " 'vehicles': []},\n", " {'birth_year': '31BBY',\n", " 'created': '2014-12-15T12:56:32.683000Z',\n", " 'edited': '2014-12-20T21:17:50.357000Z',\n", " 'eye_color': 'brown',\n", " 'films': ['https://swapi.co/api/films/2/', 'https://swapi.co/api/films/3/'],\n", " 'gender': 'male',\n", " 'hair_color': 'black',\n", " 'height': '177',\n", " 'homeworld': 'https://swapi.co/api/planets/30/',\n", " 'mass': '79',\n", " 'name': 'Lando Calrissian',\n", " 'skin_color': 'dark',\n", " 'species': ['https://swapi.co/api/species/1/'],\n", " 'starships': ['https://swapi.co/api/starships/10/'],\n", " 'url': 'https://swapi.co/api/people/25/',\n", " 'vehicles': []},\n", " {'birth_year': '37BBY',\n", " 'created': '2014-12-15T13:01:57.178000Z',\n", " 'edited': '2014-12-20T21:17:50.359000Z',\n", " 'eye_color': 'blue',\n", " 'films': ['https://swapi.co/api/films/2/'],\n", " 'gender': 'male',\n", " 'hair_color': 'none',\n", " 'height': '175',\n", " 'homeworld': 'https://swapi.co/api/planets/6/',\n", " 'mass': '79',\n", " 'name': 'Lobot',\n", " 'skin_color': 'light',\n", " 'species': ['https://swapi.co/api/species/1/'],\n", " 'starships': [],\n", " 'url': 'https://swapi.co/api/people/26/',\n", " 'vehicles': []},\n", " {'birth_year': '41BBY',\n", " 'created': '2014-12-18T11:07:50.584000Z',\n", " 'edited': '2014-12-20T21:17:50.362000Z',\n", " 'eye_color': 'orange',\n", " 'films': ['https://swapi.co/api/films/3/', 'https://swapi.co/api/films/7/'],\n", " 'gender': 'male',\n", " 'hair_color': 'none',\n", " 'height': '180',\n", " 'homeworld': 'https://swapi.co/api/planets/31/',\n", " 'mass': '83',\n", " 'name': 'Ackbar',\n", " 'skin_color': 'brown mottle',\n", " 'species': ['https://swapi.co/api/species/8/'],\n", " 'starships': [],\n", " 'url': 'https://swapi.co/api/people/27/',\n", " 'vehicles': []},\n", " {'birth_year': '48BBY',\n", " 'created': '2014-12-18T11:12:38.895000Z',\n", " 'edited': '2014-12-20T21:17:50.364000Z',\n", " 'eye_color': 'blue',\n", " 'films': ['https://swapi.co/api/films/3/'],\n", " 'gender': 'female',\n", " 'hair_color': 'auburn',\n", " 'height': '150',\n", " 'homeworld': 'https://swapi.co/api/planets/32/',\n", " 'mass': 'unknown',\n", " 'name': 'Mon Mothma',\n", " 'skin_color': 'fair',\n", " 'species': ['https://swapi.co/api/species/1/'],\n", " 'starships': [],\n", " 'url': 'https://swapi.co/api/people/28/',\n", " 'vehicles': []},\n", " {'birth_year': 'unknown',\n", " 'created': '2014-12-18T11:16:33.020000Z',\n", " 'edited': '2014-12-20T21:17:50.367000Z',\n", " 'eye_color': 'brown',\n", " 'films': ['https://swapi.co/api/films/3/'],\n", " 'gender': 'male',\n", " 'hair_color': 'brown',\n", " 'height': 'unknown',\n", " 'homeworld': 'https://swapi.co/api/planets/28/',\n", " 'mass': 'unknown',\n", " 'name': 'Arvel Crynyd',\n", " 'skin_color': 'fair',\n", " 'species': ['https://swapi.co/api/species/1/'],\n", " 'starships': ['https://swapi.co/api/starships/28/'],\n", " 'url': 'https://swapi.co/api/people/29/',\n", " 'vehicles': []},\n", " {'birth_year': '8BBY',\n", " 'created': '2014-12-18T11:21:58.954000Z',\n", " 'edited': '2014-12-20T21:17:50.369000Z',\n", " 'eye_color': 'brown',\n", " 'films': ['https://swapi.co/api/films/3/'],\n", " 'gender': 'male',\n", " 'hair_color': 'brown',\n", " 'height': '88',\n", " 'homeworld': 'https://swapi.co/api/planets/7/',\n", " 'mass': '20',\n", " 'name': 'Wicket Systri Warrick',\n", " 'skin_color': 'brown',\n", " 'species': ['https://swapi.co/api/species/9/'],\n", " 'starships': [],\n", " 'url': 'https://swapi.co/api/people/30/',\n", " 'vehicles': []},\n", " {'birth_year': 'unknown',\n", " 'created': '2014-12-18T11:26:18.541000Z',\n", " 'edited': '2014-12-20T21:17:50.371000Z',\n", " 'eye_color': 'black',\n", " 'films': ['https://swapi.co/api/films/3/'],\n", " 'gender': 'male',\n", " 'hair_color': 'none',\n", " 'height': '160',\n", " 'homeworld': 'https://swapi.co/api/planets/33/',\n", " 'mass': '68',\n", " 'name': 'Nien Nunb',\n", " 'skin_color': 'grey',\n", " 'species': ['https://swapi.co/api/species/10/'],\n", " 'starships': ['https://swapi.co/api/starships/10/'],\n", " 'url': 'https://swapi.co/api/people/31/',\n", " 'vehicles': []},\n", " {'birth_year': '92BBY',\n", " 'created': '2014-12-19T16:54:53.618000Z',\n", " 'edited': '2014-12-20T21:17:50.375000Z',\n", " 'eye_color': 'blue',\n", " 'films': ['https://swapi.co/api/films/4/'],\n", " 'gender': 'male',\n", " 'hair_color': 'brown',\n", " 'height': '193',\n", " 'homeworld': 'https://swapi.co/api/planets/28/',\n", " 'mass': '89',\n", " 'name': 'Qui-Gon Jinn',\n", " 'skin_color': 'fair',\n", " 'species': ['https://swapi.co/api/species/1/'],\n", " 'starships': [],\n", " 'url': 'https://swapi.co/api/people/32/',\n", " 'vehicles': ['https://swapi.co/api/vehicles/38/']},\n", " {'birth_year': 'unknown',\n", " 'created': '2014-12-19T17:05:57.357000Z',\n", " 'edited': '2014-12-20T21:17:50.377000Z',\n", " 'eye_color': 'red',\n", " 'films': ['https://swapi.co/api/films/5/',\n", " 'https://swapi.co/api/films/4/',\n", " 'https://swapi.co/api/films/6/'],\n", " 'gender': 'male',\n", " 'hair_color': 'none',\n", " 'height': '191',\n", " 'homeworld': 'https://swapi.co/api/planets/18/',\n", " 'mass': '90',\n", " 'name': 'Nute Gunray',\n", " 'skin_color': 'mottled green',\n", " 'species': ['https://swapi.co/api/species/11/'],\n", " 'starships': [],\n", " 'url': 'https://swapi.co/api/people/33/',\n", " 'vehicles': []},\n", " {'birth_year': '91BBY',\n", " 'created': '2014-12-19T17:21:45.915000Z',\n", " 'edited': '2014-12-20T21:17:50.379000Z',\n", " 'eye_color': 'blue',\n", " 'films': ['https://swapi.co/api/films/4/'],\n", " 'gender': 'male',\n", " 'hair_color': 'blond',\n", " 'height': '170',\n", " 'homeworld': 'https://swapi.co/api/planets/9/',\n", " 'mass': 'unknown',\n", " 'name': 'Finis Valorum',\n", " 'skin_color': 'fair',\n", " 'species': ['https://swapi.co/api/species/1/'],\n", " 'starships': [],\n", " 'url': 'https://swapi.co/api/people/34/',\n", " 'vehicles': []},\n", " {'birth_year': '52BBY',\n", " 'created': '2014-12-19T17:29:32.489000Z',\n", " 'edited': '2014-12-20T21:17:50.383000Z',\n", " 'eye_color': 'orange',\n", " 'films': ['https://swapi.co/api/films/5/', 'https://swapi.co/api/films/4/'],\n", " 'gender': 'male',\n", " 'hair_color': 'none',\n", " 'height': '196',\n", " 'homeworld': 'https://swapi.co/api/planets/8/',\n", " 'mass': '66',\n", " 'name': 'Jar Jar Binks',\n", " 'skin_color': 'orange',\n", " 'species': ['https://swapi.co/api/species/12/'],\n", " 'starships': [],\n", " 'url': 'https://swapi.co/api/people/36/',\n", " 'vehicles': []},\n", " {'birth_year': 'unknown',\n", " 'created': '2014-12-19T17:32:56.741000Z',\n", " 'edited': '2014-12-20T21:17:50.385000Z',\n", " 'eye_color': 'orange',\n", " 'films': ['https://swapi.co/api/films/4/'],\n", " 'gender': 'male',\n", " 'hair_color': 'none',\n", " 'height': '224',\n", " 'homeworld': 'https://swapi.co/api/planets/8/',\n", " 'mass': '82',\n", " 'name': 'Roos Tarpals',\n", " 'skin_color': 'grey',\n", " 'species': ['https://swapi.co/api/species/12/'],\n", " 'starships': [],\n", " 'url': 'https://swapi.co/api/people/37/',\n", " 'vehicles': []},\n", " {'birth_year': 'unknown',\n", " 'created': '2014-12-19T17:33:38.909000Z',\n", " 'edited': '2014-12-20T21:17:50.388000Z',\n", " 'eye_color': 'orange',\n", " 'films': ['https://swapi.co/api/films/4/'],\n", " 'gender': 'male',\n", " 'hair_color': 'none',\n", " 'height': '206',\n", " 'homeworld': 'https://swapi.co/api/planets/8/',\n", " 'mass': 'unknown',\n", " 'name': 'Rugor Nass',\n", " 'skin_color': 'green',\n", " 'species': ['https://swapi.co/api/species/12/'],\n", " 'starships': [],\n", " 'url': 'https://swapi.co/api/people/38/',\n", " 'vehicles': []},\n", " {'birth_year': 'unknown',\n", " 'created': '2014-12-19T17:45:01.522000Z',\n", " 'edited': '2014-12-20T21:17:50.392000Z',\n", " 'eye_color': 'blue',\n", " 'films': ['https://swapi.co/api/films/4/'],\n", " 'gender': 'male',\n", " 'hair_color': 'brown',\n", " 'height': '183',\n", " 'homeworld': 'https://swapi.co/api/planets/8/',\n", " 'mass': 'unknown',\n", " 'name': 'Ric OliƩ',\n", " 'skin_color': 'fair',\n", " 'species': [],\n", " 'starships': ['https://swapi.co/api/starships/40/'],\n", " 'url': 'https://swapi.co/api/people/39/',\n", " 'vehicles': []},\n", " {'birth_year': 'unknown',\n", " 'created': '2014-12-19T17:48:54.647000Z',\n", " 'edited': '2014-12-20T21:17:50.395000Z',\n", " 'eye_color': 'yellow',\n", " 'films': ['https://swapi.co/api/films/5/', 'https://swapi.co/api/films/4/'],\n", " 'gender': 'male',\n", " 'hair_color': 'black',\n", " 'height': '137',\n", " 'homeworld': 'https://swapi.co/api/planets/34/',\n", " 'mass': 'unknown',\n", " 'name': 'Watto',\n", " 'skin_color': 'blue, grey',\n", " 'species': ['https://swapi.co/api/species/13/'],\n", " 'starships': [],\n", " 'url': 'https://swapi.co/api/people/40/',\n", " 'vehicles': []},\n", " {'birth_year': 'unknown',\n", " 'created': '2014-12-19T17:53:02.586000Z',\n", " 'edited': '2014-12-20T21:17:50.397000Z',\n", " 'eye_color': 'orange',\n", " 'films': ['https://swapi.co/api/films/4/'],\n", " 'gender': 'male',\n", " 'hair_color': 'none',\n", " 'height': '112',\n", " 'homeworld': 'https://swapi.co/api/planets/35/',\n", " 'mass': '40',\n", " 'name': 'Sebulba',\n", " 'skin_color': 'grey, red',\n", " 'species': ['https://swapi.co/api/species/14/'],\n", " 'starships': [],\n", " 'url': 'https://swapi.co/api/people/41/',\n", " 'vehicles': []},\n", " {'birth_year': '62BBY',\n", " 'created': '2014-12-19T17:55:43.348000Z',\n", " 'edited': '2014-12-20T21:17:50.399000Z',\n", " 'eye_color': 'brown',\n", " 'films': ['https://swapi.co/api/films/4/'],\n", " 'gender': 'male',\n", " 'hair_color': 'black',\n", " 'height': '183',\n", " 'homeworld': 'https://swapi.co/api/planets/8/',\n", " 'mass': 'unknown',\n", " 'name': 'Quarsh Panaka',\n", " 'skin_color': 'dark',\n", " 'species': [],\n", " 'starships': [],\n", " 'url': 'https://swapi.co/api/people/42/',\n", " 'vehicles': []},\n", " {'birth_year': '72BBY',\n", " 'created': '2014-12-19T17:57:41.191000Z',\n", " 'edited': '2014-12-20T21:17:50.401000Z',\n", " 'eye_color': 'brown',\n", " 'films': ['https://swapi.co/api/films/5/', 'https://swapi.co/api/films/4/'],\n", " 'gender': 'female',\n", " 'hair_color': 'black',\n", " 'height': '163',\n", " 'homeworld': 'https://swapi.co/api/planets/1/',\n", " 'mass': 'unknown',\n", " 'name': 'Shmi Skywalker',\n", " 'skin_color': 'fair',\n", " 'species': ['https://swapi.co/api/species/1/'],\n", " 'starships': [],\n", " 'url': 'https://swapi.co/api/people/43/',\n", " 'vehicles': []},\n", " {'birth_year': '54BBY',\n", " 'created': '2014-12-19T18:00:41.929000Z',\n", " 'edited': '2014-12-20T21:17:50.403000Z',\n", " 'eye_color': 'yellow',\n", " 'films': ['https://swapi.co/api/films/4/'],\n", " 'gender': 'male',\n", " 'hair_color': 'none',\n", " 'height': '175',\n", " 'homeworld': 'https://swapi.co/api/planets/36/',\n", " 'mass': '80',\n", " 'name': 'Darth Maul',\n", " 'skin_color': 'red',\n", " 'species': ['https://swapi.co/api/species/22/'],\n", " 'starships': ['https://swapi.co/api/starships/41/'],\n", " 'url': 'https://swapi.co/api/people/44/',\n", " 'vehicles': ['https://swapi.co/api/vehicles/42/']},\n", " {'birth_year': 'unknown',\n", " 'created': '2014-12-20T09:47:02.512000Z',\n", " 'edited': '2014-12-20T21:17:50.407000Z',\n", " 'eye_color': 'pink',\n", " 'films': ['https://swapi.co/api/films/3/'],\n", " 'gender': 'male',\n", " 'hair_color': 'none',\n", " 'height': '180',\n", " 'homeworld': 'https://swapi.co/api/planets/37/',\n", " 'mass': 'unknown',\n", " 'name': 'Bib Fortuna',\n", " 'skin_color': 'pale',\n", " 'species': ['https://swapi.co/api/species/15/'],\n", " 'starships': [],\n", " 'url': 'https://swapi.co/api/people/45/',\n", " 'vehicles': []},\n", " {'birth_year': '48BBY',\n", " 'created': '2014-12-20T09:48:01.172000Z',\n", " 'edited': '2014-12-20T21:17:50.409000Z',\n", " 'eye_color': 'hazel',\n", " 'films': ['https://swapi.co/api/films/5/',\n", " 'https://swapi.co/api/films/4/',\n", " 'https://swapi.co/api/films/6/'],\n", " 'gender': 'female',\n", " 'hair_color': 'none',\n", " 'height': '178',\n", " 'homeworld': 'https://swapi.co/api/planets/37/',\n", " 'mass': '55',\n", " 'name': 'Ayla Secura',\n", " 'skin_color': 'blue',\n", " 'species': ['https://swapi.co/api/species/15/'],\n", " 'starships': [],\n", " 'url': 'https://swapi.co/api/people/46/',\n", " 'vehicles': []},\n", " {'birth_year': 'unknown',\n", " 'created': '2014-12-20T09:57:31.858000Z',\n", " 'edited': '2014-12-20T21:17:50.414000Z',\n", " 'eye_color': 'yellow',\n", " 'films': ['https://swapi.co/api/films/4/'],\n", " 'gender': 'male',\n", " 'hair_color': 'none',\n", " 'height': '94',\n", " 'homeworld': 'https://swapi.co/api/planets/39/',\n", " 'mass': '45',\n", " 'name': 'Dud Bolt',\n", " 'skin_color': 'blue, grey',\n", " 'species': ['https://swapi.co/api/species/17/'],\n", " 'starships': [],\n", " 'url': 'https://swapi.co/api/people/48/',\n", " 'vehicles': []},\n", " {'birth_year': 'unknown',\n", " 'created': '2014-12-20T10:02:12.223000Z',\n", " 'edited': '2014-12-20T21:17:50.416000Z',\n", " 'eye_color': 'black',\n", " 'films': ['https://swapi.co/api/films/4/'],\n", " 'gender': 'male',\n", " 'hair_color': 'none',\n", " 'height': '122',\n", " 'homeworld': 'https://swapi.co/api/planets/40/',\n", " 'mass': 'unknown',\n", " 'name': 'Gasgano',\n", " 'skin_color': 'white, blue',\n", " 'species': ['https://swapi.co/api/species/18/'],\n", " 'starships': [],\n", " 'url': 'https://swapi.co/api/people/49/',\n", " 'vehicles': []},\n", " {'birth_year': 'unknown',\n", " 'created': '2014-12-20T10:08:33.777000Z',\n", " 'edited': '2014-12-20T21:17:50.417000Z',\n", " 'eye_color': 'orange',\n", " 'films': ['https://swapi.co/api/films/4/'],\n", " 'gender': 'male',\n", " 'hair_color': 'none',\n", " 'height': '163',\n", " 'homeworld': 'https://swapi.co/api/planets/41/',\n", " 'mass': '65',\n", " 'name': 'Ben Quadinaros',\n", " 'skin_color': 'grey, green, yellow',\n", " 'species': ['https://swapi.co/api/species/19/'],\n", " 'starships': [],\n", " 'url': 'https://swapi.co/api/people/50/',\n", " 'vehicles': []},\n", " {'birth_year': '72BBY',\n", " 'created': '2014-12-20T10:12:30.846000Z',\n", " 'edited': '2014-12-20T21:17:50.420000Z',\n", " 'eye_color': 'brown',\n", " 'films': ['https://swapi.co/api/films/5/',\n", " 'https://swapi.co/api/films/4/',\n", " 'https://swapi.co/api/films/6/'],\n", " 'gender': 'male',\n", " 'hair_color': 'none',\n", " 'height': '188',\n", " 'homeworld': 'https://swapi.co/api/planets/42/',\n", " 'mass': '84',\n", " 'name': 'Mace Windu',\n", " 'skin_color': 'dark',\n", " 'species': ['https://swapi.co/api/species/1/'],\n", " 'starships': [],\n", " 'url': 'https://swapi.co/api/people/51/',\n", " 'vehicles': []},\n", " {'birth_year': '92BBY',\n", " 'created': '2014-12-20T10:15:32.293000Z',\n", " 'edited': '2014-12-20T21:17:50.422000Z',\n", " 'eye_color': 'yellow',\n", " 'films': ['https://swapi.co/api/films/5/',\n", " 'https://swapi.co/api/films/4/',\n", " 'https://swapi.co/api/films/6/'],\n", " 'gender': 'male',\n", " 'hair_color': 'white',\n", " 'height': '198',\n", " 'homeworld': 'https://swapi.co/api/planets/43/',\n", " 'mass': '82',\n", " 'name': 'Ki-Adi-Mundi',\n", " 'skin_color': 'pale',\n", " 'species': ['https://swapi.co/api/species/20/'],\n", " 'starships': [],\n", " 'url': 'https://swapi.co/api/people/52/',\n", " 'vehicles': []},\n", " {'birth_year': 'unknown',\n", " 'created': '2014-12-20T10:18:57.202000Z',\n", " 'edited': '2014-12-20T21:17:50.424000Z',\n", " 'eye_color': 'black',\n", " 'films': ['https://swapi.co/api/films/5/',\n", " 'https://swapi.co/api/films/4/',\n", " 'https://swapi.co/api/films/6/'],\n", " 'gender': 'male',\n", " 'hair_color': 'none',\n", " 'height': '196',\n", " 'homeworld': 'https://swapi.co/api/planets/44/',\n", " 'mass': '87',\n", " 'name': 'Kit Fisto',\n", " 'skin_color': 'green',\n", " 'species': ['https://swapi.co/api/species/21/'],\n", " 'starships': [],\n", " 'url': 'https://swapi.co/api/people/53/',\n", " 'vehicles': []},\n", " {'birth_year': 'unknown',\n", " 'created': '2014-12-20T10:26:47.902000Z',\n", " 'edited': '2014-12-20T21:17:50.427000Z',\n", " 'eye_color': 'brown',\n", " 'films': ['https://swapi.co/api/films/4/', 'https://swapi.co/api/films/6/'],\n", " 'gender': 'male',\n", " 'hair_color': 'black',\n", " 'height': '171',\n", " 'homeworld': 'https://swapi.co/api/planets/45/',\n", " 'mass': 'unknown',\n", " 'name': 'Eeth Koth',\n", " 'skin_color': 'brown',\n", " 'species': ['https://swapi.co/api/species/22/'],\n", " 'starships': [],\n", " 'url': 'https://swapi.co/api/people/54/',\n", " 'vehicles': []},\n", " {'birth_year': 'unknown',\n", " 'created': '2014-12-20T10:29:11.661000Z',\n", " 'edited': '2014-12-20T21:17:50.432000Z',\n", " 'eye_color': 'blue',\n", " 'films': ['https://swapi.co/api/films/4/', 'https://swapi.co/api/films/6/'],\n", " 'gender': 'female',\n", " 'hair_color': 'none',\n", " 'height': '184',\n", " 'homeworld': 'https://swapi.co/api/planets/9/',\n", " 'mass': '50',\n", " 'name': 'Adi Gallia',\n", " 'skin_color': 'dark',\n", " 'species': ['https://swapi.co/api/species/23/'],\n", " 'starships': [],\n", " 'url': 'https://swapi.co/api/people/55/',\n", " 'vehicles': []},\n", " {'birth_year': 'unknown',\n", " 'created': '2014-12-20T10:32:11.669000Z',\n", " 'edited': '2014-12-20T21:17:50.434000Z',\n", " 'eye_color': 'orange',\n", " 'films': ['https://swapi.co/api/films/4/', 'https://swapi.co/api/films/6/'],\n", " 'gender': 'male',\n", " 'hair_color': 'none',\n", " 'height': '188',\n", " 'homeworld': 'https://swapi.co/api/planets/47/',\n", " 'mass': 'unknown',\n", " 'name': 'Saesee Tiin',\n", " 'skin_color': 'pale',\n", " 'species': ['https://swapi.co/api/species/24/'],\n", " 'starships': [],\n", " 'url': 'https://swapi.co/api/people/56/',\n", " 'vehicles': []},\n", " {'birth_year': 'unknown',\n", " 'created': '2014-12-20T10:34:48.725000Z',\n", " 'edited': '2014-12-20T21:17:50.437000Z',\n", " 'eye_color': 'yellow',\n", " 'films': ['https://swapi.co/api/films/4/'],\n", " 'gender': 'male',\n", " 'hair_color': 'none',\n", " 'height': '264',\n", " 'homeworld': 'https://swapi.co/api/planets/48/',\n", " 'mass': 'unknown',\n", " 'name': 'Yarael Poof',\n", " 'skin_color': 'white',\n", " 'species': ['https://swapi.co/api/species/25/'],\n", " 'starships': [],\n", " 'url': 'https://swapi.co/api/people/57/',\n", " 'vehicles': []},\n", " {'birth_year': '22BBY',\n", " 'created': '2014-12-20T10:49:19.859000Z',\n", " 'edited': '2014-12-20T21:17:50.439000Z',\n", " 'eye_color': 'black',\n", " 'films': ['https://swapi.co/api/films/5/',\n", " 'https://swapi.co/api/films/4/',\n", " 'https://swapi.co/api/films/6/'],\n", " 'gender': 'male',\n", " 'hair_color': 'none',\n", " 'height': '188',\n", " 'homeworld': 'https://swapi.co/api/planets/49/',\n", " 'mass': '80',\n", " 'name': 'Plo Koon',\n", " 'skin_color': 'orange',\n", " 'species': ['https://swapi.co/api/species/26/'],\n", " 'starships': ['https://swapi.co/api/starships/48/'],\n", " 'url': 'https://swapi.co/api/people/58/',\n", " 'vehicles': []},\n", " {'birth_year': 'unknown',\n", " 'created': '2014-12-20T10:53:26.457000Z',\n", " 'edited': '2014-12-20T21:17:50.442000Z',\n", " 'eye_color': 'blue',\n", " 'films': ['https://swapi.co/api/films/5/', 'https://swapi.co/api/films/4/'],\n", " 'gender': 'male',\n", " 'hair_color': 'none',\n", " 'height': '196',\n", " 'homeworld': 'https://swapi.co/api/planets/50/',\n", " 'mass': 'unknown',\n", " 'name': 'Mas Amedda',\n", " 'skin_color': 'blue',\n", " 'species': ['https://swapi.co/api/species/27/'],\n", " 'starships': [],\n", " 'url': 'https://swapi.co/api/people/59/',\n", " 'vehicles': []},\n", " {'birth_year': 'unknown',\n", " 'created': '2014-12-20T11:10:10.381000Z',\n", " 'edited': '2014-12-20T21:17:50.445000Z',\n", " 'eye_color': 'brown',\n", " 'films': ['https://swapi.co/api/films/5/'],\n", " 'gender': 'male',\n", " 'hair_color': 'black',\n", " 'height': '185',\n", " 'homeworld': 'https://swapi.co/api/planets/8/',\n", " 'mass': '85',\n", " 'name': 'Gregar Typho',\n", " 'skin_color': 'dark',\n", " 'species': ['https://swapi.co/api/species/1/'],\n", " 'starships': ['https://swapi.co/api/starships/39/'],\n", " 'url': 'https://swapi.co/api/people/60/',\n", " 'vehicles': []},\n", " {'birth_year': 'unknown',\n", " 'created': '2014-12-20T11:11:39.630000Z',\n", " 'edited': '2014-12-20T21:17:50.449000Z',\n", " 'eye_color': 'brown',\n", " 'films': ['https://swapi.co/api/films/5/'],\n", " 'gender': 'female',\n", " 'hair_color': 'brown',\n", " 'height': '157',\n", " 'homeworld': 'https://swapi.co/api/planets/8/',\n", " 'mass': 'unknown',\n", " 'name': 'CordƩ',\n", " 'skin_color': 'light',\n", " 'species': ['https://swapi.co/api/species/1/'],\n", " 'starships': [],\n", " 'url': 'https://swapi.co/api/people/61/',\n", " 'vehicles': []},\n", " {'birth_year': '82BBY',\n", " 'created': '2014-12-20T15:59:03.958000Z',\n", " 'edited': '2014-12-20T21:17:50.451000Z',\n", " 'eye_color': 'blue',\n", " 'films': ['https://swapi.co/api/films/5/'],\n", " 'gender': 'male',\n", " 'hair_color': 'brown',\n", " 'height': '183',\n", " 'homeworld': 'https://swapi.co/api/planets/1/',\n", " 'mass': 'unknown',\n", " 'name': 'Cliegg Lars',\n", " 'skin_color': 'fair',\n", " 'species': ['https://swapi.co/api/species/1/'],\n", " 'starships': [],\n", " 'url': 'https://swapi.co/api/people/62/',\n", " 'vehicles': []},\n", " {'birth_year': 'unknown',\n", " 'created': '2014-12-20T16:40:43.977000Z',\n", " 'edited': '2014-12-20T21:17:50.453000Z',\n", " 'eye_color': 'yellow',\n", " 'films': ['https://swapi.co/api/films/5/', 'https://swapi.co/api/films/6/'],\n", " 'gender': 'male',\n", " 'hair_color': 'none',\n", " 'height': '183',\n", " 'homeworld': 'https://swapi.co/api/planets/11/',\n", " 'mass': '80',\n", " 'name': 'Poggle the Lesser',\n", " 'skin_color': 'green',\n", " 'species': ['https://swapi.co/api/species/28/'],\n", " 'starships': [],\n", " 'url': 'https://swapi.co/api/people/63/',\n", " 'vehicles': []},\n", " {'birth_year': '58BBY',\n", " 'created': '2014-12-20T16:45:53.668000Z',\n", " 'edited': '2014-12-20T21:17:50.455000Z',\n", " 'eye_color': 'blue',\n", " 'films': ['https://swapi.co/api/films/5/', 'https://swapi.co/api/films/6/'],\n", " 'gender': 'female',\n", " 'hair_color': 'black',\n", " 'height': '170',\n", " 'homeworld': 'https://swapi.co/api/planets/51/',\n", " 'mass': '56.2',\n", " 'name': 'Luminara Unduli',\n", " 'skin_color': 'yellow',\n", " 'species': ['https://swapi.co/api/species/29/'],\n", " 'starships': [],\n", " 'url': 'https://swapi.co/api/people/64/',\n", " 'vehicles': []},\n", " {'birth_year': '40BBY',\n", " 'created': '2014-12-20T16:46:40.440000Z',\n", " 'edited': '2014-12-20T21:17:50.457000Z',\n", " 'eye_color': 'blue',\n", " 'films': ['https://swapi.co/api/films/5/'],\n", " 'gender': 'female',\n", " 'hair_color': 'black',\n", " 'height': '166',\n", " 'homeworld': 'https://swapi.co/api/planets/51/',\n", " 'mass': '50',\n", " 'name': 'Barriss Offee',\n", " 'skin_color': 'yellow',\n", " 'species': ['https://swapi.co/api/species/29/'],\n", " 'starships': [],\n", " 'url': 'https://swapi.co/api/people/65/',\n", " 'vehicles': []},\n", " {'birth_year': 'unknown',\n", " 'created': '2014-12-20T16:49:14.640000Z',\n", " 'edited': '2014-12-20T21:17:50.460000Z',\n", " 'eye_color': 'brown',\n", " 'films': ['https://swapi.co/api/films/5/'],\n", " 'gender': 'female',\n", " 'hair_color': 'brown',\n", " 'height': '165',\n", " 'homeworld': 'https://swapi.co/api/planets/8/',\n", " 'mass': 'unknown',\n", " 'name': 'DormƩ',\n", " 'skin_color': 'light',\n", " 'species': ['https://swapi.co/api/species/1/'],\n", " 'starships': [],\n", " 'url': 'https://swapi.co/api/people/66/',\n", " 'vehicles': []},\n", " {'birth_year': '102BBY',\n", " 'created': '2014-12-20T16:52:14.726000Z',\n", " 'edited': '2014-12-20T21:17:50.462000Z',\n", " 'eye_color': 'brown',\n", " 'films': ['https://swapi.co/api/films/5/', 'https://swapi.co/api/films/6/'],\n", " 'gender': 'male',\n", " 'hair_color': 'white',\n", " 'height': '193',\n", " 'homeworld': 'https://swapi.co/api/planets/52/',\n", " 'mass': '80',\n", " 'name': 'Dooku',\n", " 'skin_color': 'fair',\n", " 'species': ['https://swapi.co/api/species/1/'],\n", " 'starships': [],\n", " 'url': 'https://swapi.co/api/people/67/',\n", " 'vehicles': ['https://swapi.co/api/vehicles/55/']},\n", " {'birth_year': '67BBY',\n", " 'created': '2014-12-20T16:53:08.575000Z',\n", " 'edited': '2014-12-20T21:17:50.463000Z',\n", " 'eye_color': 'brown',\n", " 'films': ['https://swapi.co/api/films/5/', 'https://swapi.co/api/films/6/'],\n", " 'gender': 'male',\n", " 'hair_color': 'black',\n", " 'height': '191',\n", " 'homeworld': 'https://swapi.co/api/planets/2/',\n", " 'mass': 'unknown',\n", " 'name': 'Bail Prestor Organa',\n", " 'skin_color': 'tan',\n", " 'species': ['https://swapi.co/api/species/1/'],\n", " 'starships': [],\n", " 'url': 'https://swapi.co/api/people/68/',\n", " 'vehicles': []},\n", " {'birth_year': '66BBY',\n", " 'created': '2014-12-20T16:54:41.620000Z',\n", " 'edited': '2014-12-20T21:17:50.465000Z',\n", " 'eye_color': 'brown',\n", " 'films': ['https://swapi.co/api/films/5/'],\n", " 'gender': 'male',\n", " 'hair_color': 'black',\n", " 'height': '183',\n", " 'homeworld': 'https://swapi.co/api/planets/53/',\n", " 'mass': '79',\n", " 'name': 'Jango Fett',\n", " 'skin_color': 'tan',\n", " 'species': ['https://swapi.co/api/species/1/'],\n", " 'starships': [],\n", " 'url': 'https://swapi.co/api/people/69/',\n", " 'vehicles': []},\n", " {'birth_year': 'unknown',\n", " 'created': '2014-12-20T16:57:44.471000Z',\n", " 'edited': '2014-12-20T21:17:50.468000Z',\n", " 'eye_color': 'yellow',\n", " 'films': ['https://swapi.co/api/films/5/'],\n", " 'gender': 'female',\n", " 'hair_color': 'blonde',\n", " 'height': '168',\n", " 'homeworld': 'https://swapi.co/api/planets/54/',\n", " 'mass': '55',\n", " 'name': 'Zam Wesell',\n", " 'skin_color': 'fair, green, yellow',\n", " 'species': ['https://swapi.co/api/species/30/'],\n", " 'starships': [],\n", " 'url': 'https://swapi.co/api/people/70/',\n", " 'vehicles': ['https://swapi.co/api/vehicles/45/']},\n", " {'birth_year': 'unknown',\n", " 'created': '2014-12-20T17:28:27.248000Z',\n", " 'edited': '2014-12-20T21:17:50.470000Z',\n", " 'eye_color': 'yellow',\n", " 'films': ['https://swapi.co/api/films/5/'],\n", " 'gender': 'male',\n", " 'hair_color': 'none',\n", " 'height': '198',\n", " 'homeworld': 'https://swapi.co/api/planets/55/',\n", " 'mass': '102',\n", " 'name': 'Dexter Jettster',\n", " 'skin_color': 'brown',\n", " 'species': ['https://swapi.co/api/species/31/'],\n", " 'starships': [],\n", " 'url': 'https://swapi.co/api/people/71/',\n", " 'vehicles': []},\n", " {'birth_year': 'unknown',\n", " 'created': '2014-12-20T17:30:50.416000Z',\n", " 'edited': '2014-12-20T21:17:50.473000Z',\n", " 'eye_color': 'black',\n", " 'films': ['https://swapi.co/api/films/5/'],\n", " 'gender': 'male',\n", " 'hair_color': 'none',\n", " 'height': '229',\n", " 'homeworld': 'https://swapi.co/api/planets/10/',\n", " 'mass': '88',\n", " 'name': 'Lama Su',\n", " 'skin_color': 'grey',\n", " 'species': ['https://swapi.co/api/species/32/'],\n", " 'starships': [],\n", " 'url': 'https://swapi.co/api/people/72/',\n", " 'vehicles': []},\n", " {'birth_year': 'unknown',\n", " 'created': '2014-12-20T17:31:21.195000Z',\n", " 'edited': '2014-12-20T21:17:50.474000Z',\n", " 'eye_color': 'black',\n", " 'films': ['https://swapi.co/api/films/5/'],\n", " 'gender': 'female',\n", " 'hair_color': 'none',\n", " 'height': '213',\n", " 'homeworld': 'https://swapi.co/api/planets/10/',\n", " 'mass': 'unknown',\n", " 'name': 'Taun We',\n", " 'skin_color': 'grey',\n", " 'species': ['https://swapi.co/api/species/32/'],\n", " 'starships': [],\n", " 'url': 'https://swapi.co/api/people/73/',\n", " 'vehicles': []},\n", " {'birth_year': 'unknown',\n", " 'created': '2014-12-20T17:32:51.996000Z',\n", " 'edited': '2014-12-20T21:17:50.476000Z',\n", " 'eye_color': 'blue',\n", " 'films': ['https://swapi.co/api/films/5/'],\n", " 'gender': 'female',\n", " 'hair_color': 'white',\n", " 'height': '167',\n", " 'homeworld': 'https://swapi.co/api/planets/9/',\n", " 'mass': 'unknown',\n", " 'name': 'Jocasta Nu',\n", " 'skin_color': 'fair',\n", " 'species': ['https://swapi.co/api/species/1/'],\n", " 'starships': [],\n", " 'url': 'https://swapi.co/api/people/74/',\n", " 'vehicles': []},\n", " {'birth_year': 'unknown',\n", " 'created': '2014-12-20T09:53:15.086000Z',\n", " 'edited': '2016-06-30T12:52:19.604868Z',\n", " 'eye_color': 'unknown',\n", " 'films': ['https://swapi.co/api/films/4/'],\n", " 'gender': 'male',\n", " 'hair_color': 'none',\n", " 'height': '79',\n", " 'homeworld': 'https://swapi.co/api/planets/38/',\n", " 'mass': '15',\n", " 'name': 'Ratts Tyerell',\n", " 'skin_color': 'grey, blue',\n", " 'species': ['https://swapi.co/api/species/16/'],\n", " 'starships': [],\n", " 'url': 'https://swapi.co/api/people/47/',\n", " 'vehicles': []},\n", " {'birth_year': 'unknown',\n", " 'created': '2014-12-20T17:43:36.409000Z',\n", " 'edited': '2014-12-20T21:17:50.478000Z',\n", " 'eye_color': 'red, blue',\n", " 'films': ['https://swapi.co/api/films/5/', 'https://swapi.co/api/films/6/'],\n", " 'gender': 'female',\n", " 'hair_color': 'none',\n", " 'height': '96',\n", " 'homeworld': 'https://swapi.co/api/planets/28/',\n", " 'mass': 'unknown',\n", " 'name': 'R4-P17',\n", " 'skin_color': 'silver, red',\n", " 'species': [],\n", " 'starships': [],\n", " 'url': 'https://swapi.co/api/people/75/',\n", " 'vehicles': []},\n", " {'birth_year': 'unknown',\n", " 'created': '2014-12-20T17:53:52.607000Z',\n", " 'edited': '2014-12-20T21:17:50.481000Z',\n", " 'eye_color': 'unknown',\n", " 'films': ['https://swapi.co/api/films/5/'],\n", " 'gender': 'male',\n", " 'hair_color': 'none',\n", " 'height': '193',\n", " 'homeworld': 'https://swapi.co/api/planets/56/',\n", " 'mass': '48',\n", " 'name': 'Wat Tambor',\n", " 'skin_color': 'green, grey',\n", " 'species': ['https://swapi.co/api/species/33/'],\n", " 'starships': [],\n", " 'url': 'https://swapi.co/api/people/76/',\n", " 'vehicles': []},\n", " {'birth_year': 'unknown',\n", " 'created': '2014-12-20T17:58:17.049000Z',\n", " 'edited': '2014-12-20T21:17:50.484000Z',\n", " 'eye_color': 'gold',\n", " 'films': ['https://swapi.co/api/films/5/'],\n", " 'gender': 'male',\n", " 'hair_color': 'none',\n", " 'height': '191',\n", " 'homeworld': 'https://swapi.co/api/planets/57/',\n", " 'mass': 'unknown',\n", " 'name': 'San Hill',\n", " 'skin_color': 'grey',\n", " 'species': ['https://swapi.co/api/species/34/'],\n", " 'starships': [],\n", " 'url': 'https://swapi.co/api/people/77/',\n", " 'vehicles': []},\n", " {'birth_year': 'unknown',\n", " 'created': '2014-12-20T18:44:01.103000Z',\n", " 'edited': '2014-12-20T21:17:50.486000Z',\n", " 'eye_color': 'black',\n", " 'films': ['https://swapi.co/api/films/5/', 'https://swapi.co/api/films/6/'],\n", " 'gender': 'female',\n", " 'hair_color': 'none',\n", " 'height': '178',\n", " 'homeworld': 'https://swapi.co/api/planets/58/',\n", " 'mass': '57',\n", " 'name': 'Shaak Ti',\n", " 'skin_color': 'red, blue, white',\n", " 'species': ['https://swapi.co/api/species/35/'],\n", " 'starships': [],\n", " 'url': 'https://swapi.co/api/people/78/',\n", " 'vehicles': []},\n", " {'birth_year': 'unknown',\n", " 'created': '2014-12-20T19:43:53.348000Z',\n", " 'edited': '2014-12-20T21:17:50.488000Z',\n", " 'eye_color': 'green, yellow',\n", " 'films': ['https://swapi.co/api/films/6/'],\n", " 'gender': 'male',\n", " 'hair_color': 'none',\n", " 'height': '216',\n", " 'homeworld': 'https://swapi.co/api/planets/59/',\n", " 'mass': '159',\n", " 'name': 'Grievous',\n", " 'skin_color': 'brown, white',\n", " 'species': ['https://swapi.co/api/species/36/'],\n", " 'starships': ['https://swapi.co/api/starships/74/'],\n", " 'url': 'https://swapi.co/api/people/79/',\n", " 'vehicles': ['https://swapi.co/api/vehicles/60/']},\n", " {'birth_year': 'unknown',\n", " 'created': '2014-12-20T19:46:34.209000Z',\n", " 'edited': '2014-12-20T21:17:50.491000Z',\n", " 'eye_color': 'blue',\n", " 'films': ['https://swapi.co/api/films/6/'],\n", " 'gender': 'male',\n", " 'hair_color': 'brown',\n", " 'height': '234',\n", " 'homeworld': 'https://swapi.co/api/planets/14/',\n", " 'mass': '136',\n", " 'name': 'Tarfful',\n", " 'skin_color': 'brown',\n", " 'species': ['https://swapi.co/api/species/3/'],\n", " 'starships': [],\n", " 'url': 'https://swapi.co/api/people/80/',\n", " 'vehicles': []},\n", " {'birth_year': 'unknown',\n", " 'created': '2014-12-20T19:49:35.583000Z',\n", " 'edited': '2014-12-20T21:17:50.493000Z',\n", " 'eye_color': 'brown',\n", " 'films': ['https://swapi.co/api/films/6/', 'https://swapi.co/api/films/1/'],\n", " 'gender': 'male',\n", " 'hair_color': 'brown',\n", " 'height': '188',\n", " 'homeworld': 'https://swapi.co/api/planets/2/',\n", " 'mass': '79',\n", " 'name': 'Raymus Antilles',\n", " 'skin_color': 'light',\n", " 'species': ['https://swapi.co/api/species/1/'],\n", " 'starships': [],\n", " 'url': 'https://swapi.co/api/people/81/',\n", " 'vehicles': []},\n", " {'birth_year': 'unknown',\n", " 'created': '2014-12-20T20:18:37.619000Z',\n", " 'edited': '2014-12-20T21:17:50.496000Z',\n", " 'eye_color': 'white',\n", " 'films': ['https://swapi.co/api/films/5/', 'https://swapi.co/api/films/6/'],\n", " 'gender': 'female',\n", " 'hair_color': 'none',\n", " 'height': '178',\n", " 'homeworld': 'https://swapi.co/api/planets/60/',\n", " 'mass': '48',\n", " 'name': 'Sly Moore',\n", " 'skin_color': 'pale',\n", " 'species': [],\n", " 'starships': [],\n", " 'url': 'https://swapi.co/api/people/82/',\n", " 'vehicles': []},\n", " {'birth_year': 'unknown',\n", " 'created': '2014-12-20T20:35:04.260000Z',\n", " 'edited': '2014-12-20T21:17:50.498000Z',\n", " 'eye_color': 'black',\n", " 'films': ['https://swapi.co/api/films/6/'],\n", " 'gender': 'male',\n", " 'hair_color': 'none',\n", " 'height': '206',\n", " 'homeworld': 'https://swapi.co/api/planets/12/',\n", " 'mass': '80',\n", " 'name': 'Tion Medon',\n", " 'skin_color': 'grey',\n", " 'species': ['https://swapi.co/api/species/37/'],\n", " 'starships': [],\n", " 'url': 'https://swapi.co/api/people/83/',\n", " 'vehicles': []},\n", " {'birth_year': 'unknown',\n", " 'created': '2015-04-17T06:52:40.793621Z',\n", " 'edited': '2015-04-17T06:52:40.793674Z',\n", " 'eye_color': 'dark',\n", " 'films': ['https://swapi.co/api/films/7/'],\n", " 'gender': 'male',\n", " 'hair_color': 'black',\n", " 'height': 'unknown',\n", " 'homeworld': 'https://swapi.co/api/planets/28/',\n", " 'mass': 'unknown',\n", " 'name': 'Finn',\n", " 'skin_color': 'dark',\n", " 'species': ['https://swapi.co/api/species/1/'],\n", " 'starships': [],\n", " 'url': 'https://swapi.co/api/people/84/',\n", " 'vehicles': []},\n", " {'birth_year': 'unknown',\n", " 'created': '2015-04-17T06:54:01.495077Z',\n", " 'edited': '2015-04-17T06:54:01.495128Z',\n", " 'eye_color': 'hazel',\n", " 'films': ['https://swapi.co/api/films/7/'],\n", " 'gender': 'female',\n", " 'hair_color': 'brown',\n", " 'height': 'unknown',\n", " 'homeworld': 'https://swapi.co/api/planets/28/',\n", " 'mass': 'unknown',\n", " 'name': 'Rey',\n", " 'skin_color': 'light',\n", " 'species': ['https://swapi.co/api/species/1/'],\n", " 'starships': [],\n", " 'url': 'https://swapi.co/api/people/85/',\n", " 'vehicles': []},\n", " {'birth_year': 'unknown',\n", " 'created': '2015-04-17T06:55:21.622786Z',\n", " 'edited': '2015-04-17T06:55:21.622835Z',\n", " 'eye_color': 'brown',\n", " 'films': ['https://swapi.co/api/films/7/'],\n", " 'gender': 'male',\n", " 'hair_color': 'brown',\n", " 'height': 'unknown',\n", " 'homeworld': 'https://swapi.co/api/planets/28/',\n", " 'mass': 'unknown',\n", " 'name': 'Poe Dameron',\n", " 'skin_color': 'light',\n", " 'species': ['https://swapi.co/api/species/1/'],\n", " 'starships': ['https://swapi.co/api/starships/77/'],\n", " 'url': 'https://swapi.co/api/people/86/',\n", " 'vehicles': []},\n", " {'birth_year': 'unknown',\n", " 'created': '2015-04-17T06:57:38.061346Z',\n", " 'edited': '2015-04-17T06:57:38.061453Z',\n", " 'eye_color': 'black',\n", " 'films': ['https://swapi.co/api/films/7/'],\n", " 'gender': 'none',\n", " 'hair_color': 'none',\n", " 'height': 'unknown',\n", " 'homeworld': 'https://swapi.co/api/planets/28/',\n", " 'mass': 'unknown',\n", " 'name': 'BB8',\n", " 'skin_color': 'none',\n", " 'species': ['https://swapi.co/api/species/2/'],\n", " 'starships': [],\n", " 'url': 'https://swapi.co/api/people/87/',\n", " 'vehicles': []},\n", " {'birth_year': 'unknown',\n", " 'created': '2015-10-13T10:35:39.229823Z',\n", " 'edited': '2015-10-13T10:35:39.229894Z',\n", " 'eye_color': 'unknown',\n", " 'films': ['https://swapi.co/api/films/7/'],\n", " 'gender': 'female',\n", " 'hair_color': 'unknown',\n", " 'height': 'unknown',\n", " 'homeworld': 'https://swapi.co/api/planets/28/',\n", " 'mass': 'unknown',\n", " 'name': 'Captain Phasma',\n", " 'skin_color': 'unknown',\n", " 'species': [],\n", " 'starships': [],\n", " 'url': 'https://swapi.co/api/people/88/',\n", " 'vehicles': []},\n", " {'birth_year': '46BBY',\n", " 'created': '2014-12-19T17:28:26.926000Z',\n", " 'edited': '2016-04-20T17:06:31.502555Z',\n", " 'eye_color': 'brown',\n", " 'films': ['https://swapi.co/api/films/5/',\n", " 'https://swapi.co/api/films/4/',\n", " 'https://swapi.co/api/films/6/'],\n", " 'gender': 'female',\n", " 'hair_color': 'brown',\n", " 'height': '165',\n", " 'homeworld': 'https://swapi.co/api/planets/8/',\n", " 'mass': '45',\n", " 'name': 'PadmƩ Amidala',\n", " 'skin_color': 'light',\n", " 'species': ['https://swapi.co/api/species/1/'],\n", " 'starships': ['https://swapi.co/api/starships/49/',\n", " 'https://swapi.co/api/starships/64/',\n", " 'https://swapi.co/api/starships/39/'],\n", " 'url': 'https://swapi.co/api/people/35/',\n", " 'vehicles': []}]" ] }, "execution_count": 12, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# So to get a complete dictionary of all the people in the SWAPI universe we can try this:\n", "# There are 87 people with 10 per page so that will be 9 pages\n", "n = 1\n", "people = []\n", "for i in range(9):\n", " page = requests.get(\"https://swapi.co/api/people/?page=\"+str(i+1)).json()\n", " people = people + page[\"results\"]\n", "people" ] }, { "cell_type": "code", "execution_count": 13, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "87" ] }, "execution_count": 13, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# make sure we got all 87 of them\n", "len(people)" ] }, { "cell_type": "code", "execution_count": 14, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Luke Skywalker\n", "C-3PO\n", "R2-D2\n", "Darth Vader\n", "Leia Organa\n", "Owen Lars\n", "Beru Whitesun lars\n", "R5-D4\n", "Biggs Darklighter\n", "Obi-Wan Kenobi\n", "Anakin Skywalker\n", "Wilhuff Tarkin\n", "Chewbacca\n", "Han Solo\n", "Greedo\n", "Jabba Desilijic Tiure\n", "Wedge Antilles\n", "Jek Tono Porkins\n", "Yoda\n", "Palpatine\n", "Boba Fett\n", "IG-88\n", "Bossk\n", "Lando Calrissian\n", "Lobot\n", "Ackbar\n", "Mon Mothma\n", "Arvel Crynyd\n", "Wicket Systri Warrick\n", "Nien Nunb\n", "Qui-Gon Jinn\n", "Nute Gunray\n", "Finis Valorum\n", "Jar Jar Binks\n", "Roos Tarpals\n", "Rugor Nass\n", "Ric OliƩ\n", "Watto\n", "Sebulba\n", "Quarsh Panaka\n", "Shmi Skywalker\n", "Darth Maul\n", "Bib Fortuna\n", "Ayla Secura\n", "Dud Bolt\n", "Gasgano\n", "Ben Quadinaros\n", "Mace Windu\n", "Ki-Adi-Mundi\n", "Kit Fisto\n", "Eeth Koth\n", "Adi Gallia\n", "Saesee Tiin\n", "Yarael Poof\n", "Plo Koon\n", "Mas Amedda\n", "Gregar Typho\n", "CordƩ\n", "Cliegg Lars\n", "Poggle the Lesser\n", "Luminara Unduli\n", "Barriss Offee\n", "DormƩ\n", "Dooku\n", "Bail Prestor Organa\n", "Jango Fett\n", "Zam Wesell\n", "Dexter Jettster\n", "Lama Su\n", "Taun We\n", "Jocasta Nu\n", "Ratts Tyerell\n", "R4-P17\n", "Wat Tambor\n", "San Hill\n", "Shaak Ti\n", "Grievous\n", "Tarfful\n", "Raymus Antilles\n", "Sly Moore\n", "Tion Medon\n", "Finn\n", "Rey\n", "Poe Dameron\n", "BB8\n", "Captain Phasma\n", "PadmƩ Amidala\n" ] } ], "source": [ "# Let's see their names:\n", "for person in people:\n", " print(person[\"name\"])" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## An Exercise\n", "Take a moment to browse the SWAPI documentation: https://swapi.co/documentation\n", "\n", "Then, as an exercise, write a section of code that will display each film's title and api id number and then let the user select a film by number. Then display the names of all the characters that appear in the specified film. Plan to do this exercise on your own and refer to the following cells if you need help.\n", "\n", "For part of this exercise it will be helpful to be able to extract an id number from a URI. For example, if we have the URI: https://swapi.co/api/species/5/ we need to pull out the 5. Perhaps the most convenient way to do this is through the use of regular expressions. It is beyond the scope of this exercise to delve into the larger (and very useful) topic of regular expressions. Suffice it to say that the code in the following cell will do this for us." ] }, { "cell_type": "code", "execution_count": 15, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "5\n" ] } ], "source": [ "import re # import Python's regular expression library\n", "sample_uri = 'https://swapi.co/api/species/5/'\n", "match = re.search('/(\\d+)/', sample_uri)\n", "number = int(match.group(1))\n", "print(number)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### One solution to the exercise\n", "Below is one approach to solving this exercise." ] }, { "cell_type": "code", "execution_count": 16, "metadata": { "collapsed": true }, "outputs": [], "source": [ "# Let's start by seeing how the films data is arranged\n", "films = requests.get(\"https://swapi.co/api/films\").json()" ] }, { "cell_type": "code", "execution_count": 17, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "{\n", " \"count\": 7,\n", " \"next\": null,\n", " \"previous\": null,\n", " \"results\": [\n", " {\n", " \"title\": \"A New Hope\",\n", " \"episode_id\": 4,\n", " \"opening_crawl\": \"It is a period of civil war.\\r\\nRebel spaceships, striking\\r\\nfrom a hidden base, have won\\r\\ntheir first victory against\\r\\nthe evil Galactic Empire.\\r\\n\\r\\nDuring the battle, Rebel\\r\\nspies managed to steal secret\\r\\nplans to the Empire's\\r\\nultimate weapon, the DEATH\\r\\nSTAR, an armored space\\r\\nstation with enough power\\r\\nto destroy an entire planet.\\r\\n\\r\\nPursued by the Empire's\\r\\nsinister agents, Princess\\r\\nLeia races home aboard her\\r\\nstarship, custodian of the\\r\\nstolen plans that can save her\\r\\npeople and restore\\r\\nfreedom to the galaxy....\",\n", " \"director\": \"George Lucas\",\n", " \"producer\": \"Gary Kurtz, Rick McCallum\",\n", " \"release_date\": \"1977-05-25\",\n", " \"characters\": [\n", " \"https://swapi.co/api/people/1/\",\n", " \"https://swapi.co/api/people/2/\",\n", " \"https://swapi.co/api/people/3/\",\n", " \"https://swapi.co/api/people/4/\",\n", " \"https://swapi.co/api/people/5/\",\n", " \"https://swapi.co/api/people/6/\",\n", " \"https://swapi.co/api/people/7/\",\n", " \"https://swapi.co/api/people/8/\",\n", " \"https://swapi.co/api/people/9/\",\n", " \"https://swapi.co/api/people/10/\",\n", " \"https://swapi.co/api/people/12/\",\n", " \"https://swapi.co/api/people/13/\",\n", " \"https://swapi.co/api/people/14/\",\n", " \"https://swapi.co/api/people/15/\",\n", " \"https://swapi.co/api/people/16/\",\n", " \"https://swapi.co/api/people/18/\",\n", " \"https://swapi.co/api/people/19/\",\n", " \"https://swapi.co/api/people/81/\"\n", " ],\n", " \"planets\": [\n", " \"https://swapi.co/api/planets/2/\",\n", " \"https://swapi.co/api/planets/3/\",\n", " \"https://swapi.co/api/planets/1/\"\n", " ],\n", " \"starships\": [\n", " \"https://swapi.co/api/starships/2/\",\n", " \"https://swapi.co/api/starships/3/\",\n", " \"https://swapi.co/api/starships/5/\",\n", " \"https://swapi.co/api/starships/9/\",\n", " \"https://swapi.co/api/starships/10/\",\n", " \"https://swapi.co/api/starships/11/\",\n", " \"https://swapi.co/api/starships/12/\",\n", " \"https://swapi.co/api/starships/13/\"\n", " ],\n", " \"vehicles\": [\n", " \"https://swapi.co/api/vehicles/4/\",\n", " \"https://swapi.co/api/vehicles/6/\",\n", " \"https://swapi.co/api/vehicles/7/\",\n", " \"https://swapi.co/api/vehicles/8/\"\n", " ],\n", " \"species\": [\n", " \"https://swapi.co/api/species/5/\",\n", " \"https://swapi.co/api/species/3/\",\n", " \"https://swapi.co/api/species/2/\",\n", " \"https://swapi.co/api/species/1/\",\n", " \"https://swapi.co/api/species/4/\"\n", " ],\n", " \"created\": \"2014-12-10T14:23:31.880000Z\",\n", " \"edited\": \"2015-04-11T09:46:52.774897Z\",\n", " \"url\": \"https://swapi.co/api/films/1/\"\n", " },\n", " {\n", " \"title\": \"Attack of the Clones\",\n", " \"episode_id\": 2,\n", " \"opening_crawl\": \"There is unrest in the Galactic\\r\\nSenate. Several thousand solar\\r\\nsystems have declared their\\r\\nintentions to leave the Republic.\\r\\n\\r\\nThis separatist movement,\\r\\nunder the leadership of the\\r\\nmysterious Count Dooku, has\\r\\nmade it difficult for the limited\\r\\nnumber of Jedi Knights to maintain \\r\\npeace and order in the galaxy.\\r\\n\\r\\nSenator Amidala, the former\\r\\nQueen of Naboo, is returning\\r\\nto the Galactic Senate to vote\\r\\non the critical issue of creating\\r\\nan ARMY OF THE REPUBLIC\\r\\nto assist the overwhelmed\\r\\nJedi....\",\n", " \"director\": \"George Lucas\",\n", " \"producer\": \"Rick McCallum\",\n", " \"release_date\": \"2002-05-16\",\n", " \"characters\": [\n", " \"https://swapi.co/api/people/2/\",\n", " \"https://swapi.co/api/people/3/\",\n", " \"https://swapi.co/api/people/6/\",\n", " \"https://swapi.co/api/people/7/\",\n", " \"https://swapi.co/api/people/10/\",\n", " \"https://swapi.co/api/people/11/\",\n", " \"https://swapi.co/api/people/20/\",\n", " \"https://swapi.co/api/people/21/\",\n", " \"https://swapi.co/api/people/22/\",\n", " \"https://swapi.co/api/people/33/\",\n", " \"https://swapi.co/api/people/36/\",\n", " \"https://swapi.co/api/people/40/\",\n", " \"https://swapi.co/api/people/43/\",\n", " \"https://swapi.co/api/people/46/\",\n", " \"https://swapi.co/api/people/51/\",\n", " \"https://swapi.co/api/people/52/\",\n", " \"https://swapi.co/api/people/53/\",\n", " \"https://swapi.co/api/people/58/\",\n", " \"https://swapi.co/api/people/59/\",\n", " \"https://swapi.co/api/people/60/\",\n", " \"https://swapi.co/api/people/61/\",\n", " \"https://swapi.co/api/people/62/\",\n", " \"https://swapi.co/api/people/63/\",\n", " \"https://swapi.co/api/people/64/\",\n", " \"https://swapi.co/api/people/65/\",\n", " \"https://swapi.co/api/people/66/\",\n", " \"https://swapi.co/api/people/67/\",\n", " \"https://swapi.co/api/people/68/\",\n", " \"https://swapi.co/api/people/69/\",\n", " \"https://swapi.co/api/people/70/\",\n", " \"https://swapi.co/api/people/71/\",\n", " \"https://swapi.co/api/people/72/\",\n", " \"https://swapi.co/api/people/73/\",\n", " \"https://swapi.co/api/people/74/\",\n", " \"https://swapi.co/api/people/75/\",\n", " \"https://swapi.co/api/people/76/\",\n", " \"https://swapi.co/api/people/77/\",\n", " \"https://swapi.co/api/people/78/\",\n", " \"https://swapi.co/api/people/82/\",\n", " \"https://swapi.co/api/people/35/\"\n", " ],\n", " \"planets\": [\n", " \"https://swapi.co/api/planets/8/\",\n", " \"https://swapi.co/api/planets/9/\",\n", " \"https://swapi.co/api/planets/10/\",\n", " \"https://swapi.co/api/planets/11/\",\n", " \"https://swapi.co/api/planets/1/\"\n", " ],\n", " \"starships\": [\n", " \"https://swapi.co/api/starships/21/\",\n", " \"https://swapi.co/api/starships/39/\",\n", " \"https://swapi.co/api/starships/43/\",\n", " \"https://swapi.co/api/starships/47/\",\n", " \"https://swapi.co/api/starships/48/\",\n", " \"https://swapi.co/api/starships/49/\",\n", " \"https://swapi.co/api/starships/32/\",\n", " \"https://swapi.co/api/starships/52/\",\n", " \"https://swapi.co/api/starships/58/\"\n", " ],\n", " \"vehicles\": [\n", " \"https://swapi.co/api/vehicles/4/\",\n", " \"https://swapi.co/api/vehicles/44/\",\n", " \"https://swapi.co/api/vehicles/45/\",\n", " \"https://swapi.co/api/vehicles/46/\",\n", " \"https://swapi.co/api/vehicles/50/\",\n", " \"https://swapi.co/api/vehicles/51/\",\n", " \"https://swapi.co/api/vehicles/53/\",\n", " \"https://swapi.co/api/vehicles/54/\",\n", " \"https://swapi.co/api/vehicles/55/\",\n", " \"https://swapi.co/api/vehicles/56/\",\n", " \"https://swapi.co/api/vehicles/57/\"\n", " ],\n", " \"species\": [\n", " \"https://swapi.co/api/species/32/\",\n", " \"https://swapi.co/api/species/33/\",\n", " \"https://swapi.co/api/species/2/\",\n", " \"https://swapi.co/api/species/35/\",\n", " \"https://swapi.co/api/species/6/\",\n", " \"https://swapi.co/api/species/1/\",\n", " \"https://swapi.co/api/species/12/\",\n", " \"https://swapi.co/api/species/34/\",\n", " \"https://swapi.co/api/species/13/\",\n", " \"https://swapi.co/api/species/15/\",\n", " \"https://swapi.co/api/species/28/\",\n", " \"https://swapi.co/api/species/29/\",\n", " \"https://swapi.co/api/species/30/\",\n", " \"https://swapi.co/api/species/31/\"\n", " ],\n", " \"created\": \"2014-12-20T10:57:57.886000Z\",\n", " \"edited\": \"2015-04-11T09:45:01.623982Z\",\n", " \"url\": \"https://swapi.co/api/films/5/\"\n", " },\n", " {\n", " \"title\": \"The Phantom Menace\",\n", " \"episode_id\": 1,\n", " \"opening_crawl\": \"Turmoil has engulfed the\\r\\nGalactic Republic. The taxation\\r\\nof trade routes to outlying star\\r\\nsystems is in dispute.\\r\\n\\r\\nHoping to resolve the matter\\r\\nwith a blockade of deadly\\r\\nbattleships, the greedy Trade\\r\\nFederation has stopped all\\r\\nshipping to the small planet\\r\\nof Naboo.\\r\\n\\r\\nWhile the Congress of the\\r\\nRepublic endlessly debates\\r\\nthis alarming chain of events,\\r\\nthe Supreme Chancellor has\\r\\nsecretly dispatched two Jedi\\r\\nKnights, the guardians of\\r\\npeace and justice in the\\r\\ngalaxy, to settle the conflict....\",\n", " \"director\": \"George Lucas\",\n", " \"producer\": \"Rick McCallum\",\n", " \"release_date\": \"1999-05-19\",\n", " \"characters\": [\n", " \"https://swapi.co/api/people/2/\",\n", " \"https://swapi.co/api/people/3/\",\n", " \"https://swapi.co/api/people/10/\",\n", " \"https://swapi.co/api/people/11/\",\n", " \"https://swapi.co/api/people/16/\",\n", " \"https://swapi.co/api/people/20/\",\n", " \"https://swapi.co/api/people/21/\",\n", " \"https://swapi.co/api/people/32/\",\n", " \"https://swapi.co/api/people/33/\",\n", " \"https://swapi.co/api/people/34/\",\n", " \"https://swapi.co/api/people/36/\",\n", " \"https://swapi.co/api/people/37/\",\n", " \"https://swapi.co/api/people/38/\",\n", " \"https://swapi.co/api/people/39/\",\n", " \"https://swapi.co/api/people/40/\",\n", " \"https://swapi.co/api/people/41/\",\n", " \"https://swapi.co/api/people/42/\",\n", " \"https://swapi.co/api/people/43/\",\n", " \"https://swapi.co/api/people/44/\",\n", " \"https://swapi.co/api/people/46/\",\n", " \"https://swapi.co/api/people/48/\",\n", " \"https://swapi.co/api/people/49/\",\n", " \"https://swapi.co/api/people/50/\",\n", " \"https://swapi.co/api/people/51/\",\n", " \"https://swapi.co/api/people/52/\",\n", " \"https://swapi.co/api/people/53/\",\n", " \"https://swapi.co/api/people/54/\",\n", " \"https://swapi.co/api/people/55/\",\n", " \"https://swapi.co/api/people/56/\",\n", " \"https://swapi.co/api/people/57/\",\n", " \"https://swapi.co/api/people/58/\",\n", " \"https://swapi.co/api/people/59/\",\n", " \"https://swapi.co/api/people/47/\",\n", " \"https://swapi.co/api/people/35/\"\n", " ],\n", " \"planets\": [\n", " \"https://swapi.co/api/planets/8/\",\n", " \"https://swapi.co/api/planets/9/\",\n", " \"https://swapi.co/api/planets/1/\"\n", " ],\n", " \"starships\": [\n", " \"https://swapi.co/api/starships/40/\",\n", " \"https://swapi.co/api/starships/41/\",\n", " \"https://swapi.co/api/starships/31/\",\n", " \"https://swapi.co/api/starships/32/\",\n", " \"https://swapi.co/api/starships/39/\"\n", " ],\n", " \"vehicles\": [\n", " \"https://swapi.co/api/vehicles/33/\",\n", " \"https://swapi.co/api/vehicles/34/\",\n", " \"https://swapi.co/api/vehicles/35/\",\n", " \"https://swapi.co/api/vehicles/36/\",\n", " \"https://swapi.co/api/vehicles/37/\",\n", " \"https://swapi.co/api/vehicles/38/\",\n", " \"https://swapi.co/api/vehicles/42/\"\n", " ],\n", " \"species\": [\n", " \"https://swapi.co/api/species/1/\",\n", " \"https://swapi.co/api/species/2/\",\n", " \"https://swapi.co/api/species/6/\",\n", " \"https://swapi.co/api/species/11/\",\n", " \"https://swapi.co/api/species/12/\",\n", " \"https://swapi.co/api/species/13/\",\n", " \"https://swapi.co/api/species/14/\",\n", " \"https://swapi.co/api/species/15/\",\n", " \"https://swapi.co/api/species/16/\",\n", " \"https://swapi.co/api/species/17/\",\n", " \"https://swapi.co/api/species/18/\",\n", " \"https://swapi.co/api/species/19/\",\n", " \"https://swapi.co/api/species/20/\",\n", " \"https://swapi.co/api/species/21/\",\n", " \"https://swapi.co/api/species/22/\",\n", " \"https://swapi.co/api/species/23/\",\n", " \"https://swapi.co/api/species/24/\",\n", " \"https://swapi.co/api/species/25/\",\n", " \"https://swapi.co/api/species/26/\",\n", " \"https://swapi.co/api/species/27/\"\n", " ],\n", " \"created\": \"2014-12-19T16:52:55.740000Z\",\n", " \"edited\": \"2015-04-11T09:45:18.689301Z\",\n", " \"url\": \"https://swapi.co/api/films/4/\"\n", " },\n", " {\n", " \"title\": \"Revenge of the Sith\",\n", " \"episode_id\": 3,\n", " \"opening_crawl\": \"War! The Republic is crumbling\\r\\nunder attacks by the ruthless\\r\\nSith Lord, Count Dooku.\\r\\nThere are heroes on both sides.\\r\\nEvil is everywhere.\\r\\n\\r\\nIn a stunning move, the\\r\\nfiendish droid leader, General\\r\\nGrievous, has swept into the\\r\\nRepublic capital and kidnapped\\r\\nChancellor Palpatine, leader of\\r\\nthe Galactic Senate.\\r\\n\\r\\nAs the Separatist Droid Army\\r\\nattempts to flee the besieged\\r\\ncapital with their valuable\\r\\nhostage, two Jedi Knights lead a\\r\\ndesperate mission to rescue the\\r\\ncaptive Chancellor....\",\n", " \"director\": \"George Lucas\",\n", " \"producer\": \"Rick McCallum\",\n", " \"release_date\": \"2005-05-19\",\n", " \"characters\": [\n", " \"https://swapi.co/api/people/1/\",\n", " \"https://swapi.co/api/people/2/\",\n", " \"https://swapi.co/api/people/3/\",\n", " \"https://swapi.co/api/people/4/\",\n", " \"https://swapi.co/api/people/5/\",\n", " \"https://swapi.co/api/people/6/\",\n", " \"https://swapi.co/api/people/7/\",\n", " \"https://swapi.co/api/people/10/\",\n", " \"https://swapi.co/api/people/11/\",\n", " \"https://swapi.co/api/people/12/\",\n", " \"https://swapi.co/api/people/13/\",\n", " \"https://swapi.co/api/people/20/\",\n", " \"https://swapi.co/api/people/21/\",\n", " \"https://swapi.co/api/people/33/\",\n", " \"https://swapi.co/api/people/46/\",\n", " \"https://swapi.co/api/people/51/\",\n", " \"https://swapi.co/api/people/52/\",\n", " \"https://swapi.co/api/people/53/\",\n", " \"https://swapi.co/api/people/54/\",\n", " \"https://swapi.co/api/people/55/\",\n", " \"https://swapi.co/api/people/56/\",\n", " \"https://swapi.co/api/people/58/\",\n", " \"https://swapi.co/api/people/63/\",\n", " \"https://swapi.co/api/people/64/\",\n", " \"https://swapi.co/api/people/67/\",\n", " \"https://swapi.co/api/people/68/\",\n", " \"https://swapi.co/api/people/75/\",\n", " \"https://swapi.co/api/people/78/\",\n", " \"https://swapi.co/api/people/79/\",\n", " \"https://swapi.co/api/people/80/\",\n", " \"https://swapi.co/api/people/81/\",\n", " \"https://swapi.co/api/people/82/\",\n", " \"https://swapi.co/api/people/83/\",\n", " \"https://swapi.co/api/people/35/\"\n", " ],\n", " \"planets\": [\n", " \"https://swapi.co/api/planets/2/\",\n", " \"https://swapi.co/api/planets/5/\",\n", " \"https://swapi.co/api/planets/8/\",\n", " \"https://swapi.co/api/planets/9/\",\n", " \"https://swapi.co/api/planets/12/\",\n", " \"https://swapi.co/api/planets/13/\",\n", " \"https://swapi.co/api/planets/14/\",\n", " \"https://swapi.co/api/planets/15/\",\n", " \"https://swapi.co/api/planets/16/\",\n", " \"https://swapi.co/api/planets/17/\",\n", " \"https://swapi.co/api/planets/18/\",\n", " \"https://swapi.co/api/planets/19/\",\n", " \"https://swapi.co/api/planets/1/\"\n", " ],\n", " \"starships\": [\n", " \"https://swapi.co/api/starships/48/\",\n", " \"https://swapi.co/api/starships/59/\",\n", " \"https://swapi.co/api/starships/61/\",\n", " \"https://swapi.co/api/starships/32/\",\n", " \"https://swapi.co/api/starships/63/\",\n", " \"https://swapi.co/api/starships/64/\",\n", " \"https://swapi.co/api/starships/65/\",\n", " \"https://swapi.co/api/starships/66/\",\n", " \"https://swapi.co/api/starships/74/\",\n", " \"https://swapi.co/api/starships/75/\",\n", " \"https://swapi.co/api/starships/2/\",\n", " \"https://swapi.co/api/starships/68/\"\n", " ],\n", " \"vehicles\": [\n", " \"https://swapi.co/api/vehicles/33/\",\n", " \"https://swapi.co/api/vehicles/50/\",\n", " \"https://swapi.co/api/vehicles/53/\",\n", " \"https://swapi.co/api/vehicles/56/\",\n", " \"https://swapi.co/api/vehicles/60/\",\n", " \"https://swapi.co/api/vehicles/62/\",\n", " \"https://swapi.co/api/vehicles/67/\",\n", " \"https://swapi.co/api/vehicles/69/\",\n", " \"https://swapi.co/api/vehicles/70/\",\n", " \"https://swapi.co/api/vehicles/71/\",\n", " \"https://swapi.co/api/vehicles/72/\",\n", " \"https://swapi.co/api/vehicles/73/\",\n", " \"https://swapi.co/api/vehicles/76/\"\n", " ],\n", " \"species\": [\n", " \"https://swapi.co/api/species/19/\",\n", " \"https://swapi.co/api/species/33/\",\n", " \"https://swapi.co/api/species/2/\",\n", " \"https://swapi.co/api/species/3/\",\n", " \"https://swapi.co/api/species/36/\",\n", " \"https://swapi.co/api/species/37/\",\n", " \"https://swapi.co/api/species/6/\",\n", " \"https://swapi.co/api/species/1/\",\n", " \"https://swapi.co/api/species/34/\",\n", " \"https://swapi.co/api/species/15/\",\n", " \"https://swapi.co/api/species/35/\",\n", " \"https://swapi.co/api/species/20/\",\n", " \"https://swapi.co/api/species/23/\",\n", " \"https://swapi.co/api/species/24/\",\n", " \"https://swapi.co/api/species/25/\",\n", " \"https://swapi.co/api/species/26/\",\n", " \"https://swapi.co/api/species/27/\",\n", " \"https://swapi.co/api/species/28/\",\n", " \"https://swapi.co/api/species/29/\",\n", " \"https://swapi.co/api/species/30/\"\n", " ],\n", " \"created\": \"2014-12-20T18:49:38.403000Z\",\n", " \"edited\": \"2015-04-11T09:45:44.862122Z\",\n", " \"url\": \"https://swapi.co/api/films/6/\"\n", " },\n", " {\n", " \"title\": \"Return of the Jedi\",\n", " \"episode_id\": 6,\n", " \"opening_crawl\": \"Luke Skywalker has returned to\\r\\nhis home planet of Tatooine in\\r\\nan attempt to rescue his\\r\\nfriend Han Solo from the\\r\\nclutches of the vile gangster\\r\\nJabba the Hutt.\\r\\n\\r\\nLittle does Luke know that the\\r\\nGALACTIC EMPIRE has secretly\\r\\nbegun construction on a new\\r\\narmored space station even\\r\\nmore powerful than the first\\r\\ndreaded Death Star.\\r\\n\\r\\nWhen completed, this ultimate\\r\\nweapon will spell certain doom\\r\\nfor the small band of rebels\\r\\nstruggling to restore freedom\\r\\nto the galaxy...\",\n", " \"director\": \"Richard Marquand\",\n", " \"producer\": \"Howard G. Kazanjian, George Lucas, Rick McCallum\",\n", " \"release_date\": \"1983-05-25\",\n", " \"characters\": [\n", " \"https://swapi.co/api/people/1/\",\n", " \"https://swapi.co/api/people/2/\",\n", " \"https://swapi.co/api/people/3/\",\n", " \"https://swapi.co/api/people/4/\",\n", " \"https://swapi.co/api/people/5/\",\n", " \"https://swapi.co/api/people/10/\",\n", " \"https://swapi.co/api/people/13/\",\n", " \"https://swapi.co/api/people/14/\",\n", " \"https://swapi.co/api/people/16/\",\n", " \"https://swapi.co/api/people/18/\",\n", " \"https://swapi.co/api/people/20/\",\n", " \"https://swapi.co/api/people/21/\",\n", " \"https://swapi.co/api/people/22/\",\n", " \"https://swapi.co/api/people/25/\",\n", " \"https://swapi.co/api/people/27/\",\n", " \"https://swapi.co/api/people/28/\",\n", " \"https://swapi.co/api/people/29/\",\n", " \"https://swapi.co/api/people/30/\",\n", " \"https://swapi.co/api/people/31/\",\n", " \"https://swapi.co/api/people/45/\"\n", " ],\n", " \"planets\": [\n", " \"https://swapi.co/api/planets/5/\",\n", " \"https://swapi.co/api/planets/7/\",\n", " \"https://swapi.co/api/planets/8/\",\n", " \"https://swapi.co/api/planets/9/\",\n", " \"https://swapi.co/api/planets/1/\"\n", " ],\n", " \"starships\": [\n", " \"https://swapi.co/api/starships/15/\",\n", " \"https://swapi.co/api/starships/10/\",\n", " \"https://swapi.co/api/starships/11/\",\n", " \"https://swapi.co/api/starships/12/\",\n", " \"https://swapi.co/api/starships/22/\",\n", " \"https://swapi.co/api/starships/23/\",\n", " \"https://swapi.co/api/starships/27/\",\n", " \"https://swapi.co/api/starships/28/\",\n", " \"https://swapi.co/api/starships/29/\",\n", " \"https://swapi.co/api/starships/3/\",\n", " \"https://swapi.co/api/starships/17/\",\n", " \"https://swapi.co/api/starships/2/\"\n", " ],\n", " \"vehicles\": [\n", " \"https://swapi.co/api/vehicles/8/\",\n", " \"https://swapi.co/api/vehicles/16/\",\n", " \"https://swapi.co/api/vehicles/18/\",\n", " \"https://swapi.co/api/vehicles/19/\",\n", " \"https://swapi.co/api/vehicles/24/\",\n", " \"https://swapi.co/api/vehicles/25/\",\n", " \"https://swapi.co/api/vehicles/26/\",\n", " \"https://swapi.co/api/vehicles/30/\"\n", " ],\n", " \"species\": [\n", " \"https://swapi.co/api/species/1/\",\n", " \"https://swapi.co/api/species/2/\",\n", " \"https://swapi.co/api/species/3/\",\n", " \"https://swapi.co/api/species/5/\",\n", " \"https://swapi.co/api/species/6/\",\n", " \"https://swapi.co/api/species/8/\",\n", " \"https://swapi.co/api/species/9/\",\n", " \"https://swapi.co/api/species/10/\",\n", " \"https://swapi.co/api/species/15/\"\n", " ],\n", " \"created\": \"2014-12-18T10:39:33.255000Z\",\n", " \"edited\": \"2015-04-11T09:46:05.220365Z\",\n", " \"url\": \"https://swapi.co/api/films/3/\"\n", " },\n", " {\n", " \"title\": \"The Empire Strikes Back\",\n", " \"episode_id\": 5,\n", " \"opening_crawl\": \"It is a dark time for the\\r\\nRebellion. Although the Death\\r\\nStar has been destroyed,\\r\\nImperial troops have driven the\\r\\nRebel forces from their hidden\\r\\nbase and pursued them across\\r\\nthe galaxy.\\r\\n\\r\\nEvading the dreaded Imperial\\r\\nStarfleet, a group of freedom\\r\\nfighters led by Luke Skywalker\\r\\nhas established a new secret\\r\\nbase on the remote ice world\\r\\nof Hoth.\\r\\n\\r\\nThe evil lord Darth Vader,\\r\\nobsessed with finding young\\r\\nSkywalker, has dispatched\\r\\nthousands of remote probes into\\r\\nthe far reaches of space....\",\n", " \"director\": \"Irvin Kershner\",\n", " \"producer\": \"Gary Kurtz, Rick McCallum\",\n", " \"release_date\": \"1980-05-17\",\n", " \"characters\": [\n", " \"https://swapi.co/api/people/1/\",\n", " \"https://swapi.co/api/people/2/\",\n", " \"https://swapi.co/api/people/3/\",\n", " \"https://swapi.co/api/people/4/\",\n", " \"https://swapi.co/api/people/5/\",\n", " \"https://swapi.co/api/people/10/\",\n", " \"https://swapi.co/api/people/13/\",\n", " \"https://swapi.co/api/people/14/\",\n", " \"https://swapi.co/api/people/18/\",\n", " \"https://swapi.co/api/people/20/\",\n", " \"https://swapi.co/api/people/21/\",\n", " \"https://swapi.co/api/people/22/\",\n", " \"https://swapi.co/api/people/23/\",\n", " \"https://swapi.co/api/people/24/\",\n", " \"https://swapi.co/api/people/25/\",\n", " \"https://swapi.co/api/people/26/\"\n", " ],\n", " \"planets\": [\n", " \"https://swapi.co/api/planets/4/\",\n", " \"https://swapi.co/api/planets/5/\",\n", " \"https://swapi.co/api/planets/6/\",\n", " \"https://swapi.co/api/planets/27/\"\n", " ],\n", " \"starships\": [\n", " \"https://swapi.co/api/starships/15/\",\n", " \"https://swapi.co/api/starships/10/\",\n", " \"https://swapi.co/api/starships/11/\",\n", " \"https://swapi.co/api/starships/12/\",\n", " \"https://swapi.co/api/starships/21/\",\n", " \"https://swapi.co/api/starships/22/\",\n", " \"https://swapi.co/api/starships/23/\",\n", " \"https://swapi.co/api/starships/3/\",\n", " \"https://swapi.co/api/starships/17/\"\n", " ],\n", " \"vehicles\": [\n", " \"https://swapi.co/api/vehicles/8/\",\n", " \"https://swapi.co/api/vehicles/14/\",\n", " \"https://swapi.co/api/vehicles/16/\",\n", " \"https://swapi.co/api/vehicles/18/\",\n", " \"https://swapi.co/api/vehicles/19/\",\n", " \"https://swapi.co/api/vehicles/20/\"\n", " ],\n", " \"species\": [\n", " \"https://swapi.co/api/species/6/\",\n", " \"https://swapi.co/api/species/7/\",\n", " \"https://swapi.co/api/species/3/\",\n", " \"https://swapi.co/api/species/2/\",\n", " \"https://swapi.co/api/species/1/\"\n", " ],\n", " \"created\": \"2014-12-12T11:26:24.656000Z\",\n", " \"edited\": \"2017-04-19T10:57:29.544256Z\",\n", " \"url\": \"https://swapi.co/api/films/2/\"\n", " },\n", " {\n", " \"title\": \"The Force Awakens\",\n", " \"episode_id\": 7,\n", " \"opening_crawl\": \"Luke Skywalker has vanished.\\r\\nIn his absence, the sinister\\r\\nFIRST ORDER has risen from\\r\\nthe ashes of the Empire\\r\\nand will not rest until\\r\\nSkywalker, the last Jedi,\\r\\nhas been destroyed.\\r\\n \\r\\nWith the support of the\\r\\nREPUBLIC, General Leia Organa\\r\\nleads a brave RESISTANCE.\\r\\nShe is desperate to find her\\r\\nbrother Luke and gain his\\r\\nhelp in restoring peace and\\r\\njustice to the galaxy.\\r\\n \\r\\nLeia has sent her most daring\\r\\npilot on a secret mission\\r\\nto Jakku, where an old ally\\r\\nhas discovered a clue to\\r\\nLuke's whereabouts....\",\n", " \"director\": \"J. J. Abrams\",\n", " \"producer\": \"Kathleen Kennedy, J. J. Abrams, Bryan Burk\",\n", " \"release_date\": \"2015-12-11\",\n", " \"characters\": [\n", " \"https://swapi.co/api/people/1/\",\n", " \"https://swapi.co/api/people/3/\",\n", " \"https://swapi.co/api/people/5/\",\n", " \"https://swapi.co/api/people/13/\",\n", " \"https://swapi.co/api/people/14/\",\n", " \"https://swapi.co/api/people/27/\",\n", " \"https://swapi.co/api/people/84/\",\n", " \"https://swapi.co/api/people/85/\",\n", " \"https://swapi.co/api/people/86/\",\n", " \"https://swapi.co/api/people/87/\",\n", " \"https://swapi.co/api/people/88/\"\n", " ],\n", " \"planets\": [\n", " \"https://swapi.co/api/planets/61/\"\n", " ],\n", " \"starships\": [\n", " \"https://swapi.co/api/starships/77/\",\n", " \"https://swapi.co/api/starships/10/\"\n", " ],\n", " \"vehicles\": [],\n", " \"species\": [\n", " \"https://swapi.co/api/species/3/\",\n", " \"https://swapi.co/api/species/2/\",\n", " \"https://swapi.co/api/species/1/\"\n", " ],\n", " \"created\": \"2015-04-17T06:51:30.504780Z\",\n", " \"edited\": \"2015-12-17T14:31:47.617768Z\",\n", " \"url\": \"https://swapi.co/api/films/7/\"\n", " }\n", " ]\n", "}\n" ] } ], "source": [ "print(json.dumps(films, indent=4))" ] }, { "cell_type": "code", "execution_count": 18, "metadata": { "scrolled": true }, "outputs": [ { "data": { "text/plain": [ "['https://swapi.co/api/people/1/',\n", " 'https://swapi.co/api/people/2/',\n", " 'https://swapi.co/api/people/3/',\n", " 'https://swapi.co/api/people/4/',\n", " 'https://swapi.co/api/people/5/',\n", " 'https://swapi.co/api/people/6/',\n", " 'https://swapi.co/api/people/7/',\n", " 'https://swapi.co/api/people/8/',\n", " 'https://swapi.co/api/people/9/',\n", " 'https://swapi.co/api/people/10/',\n", " 'https://swapi.co/api/people/12/',\n", " 'https://swapi.co/api/people/13/',\n", " 'https://swapi.co/api/people/14/',\n", " 'https://swapi.co/api/people/15/',\n", " 'https://swapi.co/api/people/16/',\n", " 'https://swapi.co/api/people/18/',\n", " 'https://swapi.co/api/people/19/',\n", " 'https://swapi.co/api/people/81/']" ] }, "execution_count": 18, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# looks like they list the characters for us ... \n", "# so we just need to extract the id numbers and find their corresponding index in the people list\n", "films[\"results\"][0][\"characters\"]" ] }, { "cell_type": "code", "execution_count": 19, "metadata": { "collapsed": true }, "outputs": [], "source": [ "import re" ] }, { "cell_type": "code", "execution_count": 20, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "1\n", "2\n", "3\n", "4\n", "5\n", "6\n", "7\n", "8\n", "9\n", "10\n", "12\n", "13\n", "14\n", "15\n", "16\n", "18\n", "19\n", "81\n" ] } ], "source": [ "# Well, seems we would benefit from being able to use regular expressions ...\n", "for person_uri in films[\"results\"][0][\"characters\"]:\n", " match = re.search('/(\\d+)/', person_uri)\n", " print(match.group(1))" ] }, { "cell_type": "code", "execution_count": 21, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Luke Skywalker\n", "C-3PO\n", "R2-D2\n", "Darth Vader\n", "Leia Organa\n", "Owen Lars\n", "Beru Whitesun lars\n", "R5-D4\n", "Biggs Darklighter\n", "Obi-Wan Kenobi\n", "Wilhuff Tarkin\n", "Chewbacca\n", "Han Solo\n", "Greedo\n", "Jabba Desilijic Tiure\n", "Jek Tono Porkins\n", "Yoda\n", "Tion Medon\n" ] } ], "source": [ "# Now we do the lookup\n", "for person_uri in films[\"results\"][0][\"characters\"]:\n", " match = re.search('/(\\d+)/', person_uri)\n", " print(people[int(match.group(1))-1][\"name\"])\n" ] }, { "cell_type": "code", "execution_count": 22, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "4 A New Hope\n", "2 Attack of the Clones\n", "1 The Phantom Menace\n", "3 Revenge of the Sith\n", "6 Return of the Jedi\n", "5 The Empire Strikes Back\n", "7 The Force Awakens\n", "Enter id number of movie: 3\n", "---------------------------------\n", "List of Characters\n", "---------------------------------\n", "C-3PO\n", "R2-D2\n", "Obi-Wan Kenobi\n", "Anakin Skywalker\n", "Jabba Desilijic Tiure\n", "Palpatine\n", "Boba Fett\n", "Nute Gunray\n", "Finis Valorum\n", "Jar Jar Binks\n", "Rugor Nass\n", "Ric OliƩ\n", "Watto\n", "Sebulba\n", "Quarsh Panaka\n", "Shmi Skywalker\n", "Darth Maul\n", "Bib Fortuna\n", "Ayla Secura\n", "Gasgano\n", "Mace Windu\n", "Ki-Adi-Mundi\n", "Kit Fisto\n", "Eeth Koth\n", "Adi Gallia\n", "Saesee Tiin\n", "Yarael Poof\n", "Plo Koon\n", "Mas Amedda\n", "Gregar Typho\n", "CordƩ\n", "Cliegg Lars\n", "Ben Quadinaros\n", "Roos Tarpals\n" ] } ], "source": [ "# Putting it all together ...\n", "# Display the movies ...\n", "for film in films[\"results\"]:\n", " print(str(film[\"episode_id\"])+\" \"+film[\"title\"])\n", " \n", "# Have use choose one ...\n", "film_id = int(input(\"Enter id number of movie: \"))\n", "\n", "# Display characters in the film\n", "print(\"---------------------------------\")\n", "print(\"List of Characters\")\n", "print(\"---------------------------------\")\n", "for person_uri in films[\"results\"][film_id-1][\"characters\"]:\n", " match = re.search('/(\\d+)/', person_uri)\n", " print(people[int(match.group(1))-1][\"name\"])\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## What About Pandas\n", "You may be wondering about the feasibility of creating a Pandas dataframe from a JSON string. Read on!" ] }, { "cell_type": "code", "execution_count": 23, "metadata": { "collapsed": true }, "outputs": [], "source": [ "import pandas as pd" ] }, { "cell_type": "code", "execution_count": 24, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", " | birth_year | \n", "created | \n", "edited | \n", "eye_color | \n", "films | \n", "gender | \n", "hair_color | \n", "height | \n", "homeworld | \n", "mass | \n", "name | \n", "skin_color | \n", "species | \n", "starships | \n", "url | \n", "vehicles | \n", "
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | \n", "19BBY | \n", "2014-12-09T13:50:51.644000Z | \n", "2014-12-20T21:17:56.891000Z | \n", "blue | \n", "[https://swapi.co/api/films/2/, https://swapi.... | \n", "male | \n", "blond | \n", "172 | \n", "https://swapi.co/api/planets/1/ | \n", "77 | \n", "Luke Skywalker | \n", "fair | \n", "[https://swapi.co/api/species/1/] | \n", "[https://swapi.co/api/starships/12/, https://s... | \n", "https://swapi.co/api/people/1/ | \n", "[https://swapi.co/api/vehicles/14/, https://sw... | \n", "
1 | \n", "112BBY | \n", "2014-12-10T15:10:51.357000Z | \n", "2014-12-20T21:17:50.309000Z | \n", "yellow | \n", "[https://swapi.co/api/films/2/, https://swapi.... | \n", "n/a | \n", "n/a | \n", "167 | \n", "https://swapi.co/api/planets/1/ | \n", "75 | \n", "C-3PO | \n", "gold | \n", "[https://swapi.co/api/species/2/] | \n", "[] | \n", "https://swapi.co/api/people/2/ | \n", "[] | \n", "
2 | \n", "33BBY | \n", "2014-12-10T15:11:50.376000Z | \n", "2014-12-20T21:17:50.311000Z | \n", "red | \n", "[https://swapi.co/api/films/2/, https://swapi.... | \n", "n/a | \n", "n/a | \n", "96 | \n", "https://swapi.co/api/planets/8/ | \n", "32 | \n", "R2-D2 | \n", "white, blue | \n", "[https://swapi.co/api/species/2/] | \n", "[] | \n", "https://swapi.co/api/people/3/ | \n", "[] | \n", "
3 | \n", "41.9BBY | \n", "2014-12-10T15:18:20.704000Z | \n", "2014-12-20T21:17:50.313000Z | \n", "yellow | \n", "[https://swapi.co/api/films/2/, https://swapi.... | \n", "male | \n", "none | \n", "202 | \n", "https://swapi.co/api/planets/1/ | \n", "136 | \n", "Darth Vader | \n", "white | \n", "[https://swapi.co/api/species/1/] | \n", "[https://swapi.co/api/starships/13/] | \n", "https://swapi.co/api/people/4/ | \n", "[] | \n", "
4 | \n", "19BBY | \n", "2014-12-10T15:20:09.791000Z | \n", "2014-12-20T21:17:50.315000Z | \n", "brown | \n", "[https://swapi.co/api/films/2/, https://swapi.... | \n", "female | \n", "brown | \n", "150 | \n", "https://swapi.co/api/planets/2/ | \n", "49 | \n", "Leia Organa | \n", "light | \n", "[https://swapi.co/api/species/1/] | \n", "[] | \n", "https://swapi.co/api/people/5/ | \n", "[https://swapi.co/api/vehicles/30/] | \n", "
5 | \n", "52BBY | \n", "2014-12-10T15:52:14.024000Z | \n", "2014-12-20T21:17:50.317000Z | \n", "blue | \n", "[https://swapi.co/api/films/5/, https://swapi.... | \n", "male | \n", "brown, grey | \n", "178 | \n", "https://swapi.co/api/planets/1/ | \n", "120 | \n", "Owen Lars | \n", "light | \n", "[https://swapi.co/api/species/1/] | \n", "[] | \n", "https://swapi.co/api/people/6/ | \n", "[] | \n", "
6 | \n", "47BBY | \n", "2014-12-10T15:53:41.121000Z | \n", "2014-12-20T21:17:50.319000Z | \n", "blue | \n", "[https://swapi.co/api/films/5/, https://swapi.... | \n", "female | \n", "brown | \n", "165 | \n", "https://swapi.co/api/planets/1/ | \n", "75 | \n", "Beru Whitesun lars | \n", "light | \n", "[https://swapi.co/api/species/1/] | \n", "[] | \n", "https://swapi.co/api/people/7/ | \n", "[] | \n", "
7 | \n", "unknown | \n", "2014-12-10T15:57:50.959000Z | \n", "2014-12-20T21:17:50.321000Z | \n", "red | \n", "[https://swapi.co/api/films/1/] | \n", "n/a | \n", "n/a | \n", "97 | \n", "https://swapi.co/api/planets/1/ | \n", "32 | \n", "R5-D4 | \n", "white, red | \n", "[https://swapi.co/api/species/2/] | \n", "[] | \n", "https://swapi.co/api/people/8/ | \n", "[] | \n", "
8 | \n", "24BBY | \n", "2014-12-10T15:59:50.509000Z | \n", "2014-12-20T21:17:50.323000Z | \n", "brown | \n", "[https://swapi.co/api/films/1/] | \n", "male | \n", "black | \n", "183 | \n", "https://swapi.co/api/planets/1/ | \n", "84 | \n", "Biggs Darklighter | \n", "light | \n", "[https://swapi.co/api/species/1/] | \n", "[https://swapi.co/api/starships/12/] | \n", "https://swapi.co/api/people/9/ | \n", "[] | \n", "
9 | \n", "57BBY | \n", "2014-12-10T16:16:29.192000Z | \n", "2014-12-20T21:17:50.325000Z | \n", "blue-gray | \n", "[https://swapi.co/api/films/2/, https://swapi.... | \n", "male | \n", "auburn, white | \n", "182 | \n", "https://swapi.co/api/planets/20/ | \n", "77 | \n", "Obi-Wan Kenobi | \n", "fair | \n", "[https://swapi.co/api/species/1/] | \n", "[https://swapi.co/api/starships/48/, https://s... | \n", "https://swapi.co/api/people/10/ | \n", "[https://swapi.co/api/vehicles/38/] | \n", "
10 | \n", "41.9BBY | \n", "2014-12-10T16:20:44.310000Z | \n", "2014-12-20T21:17:50.327000Z | \n", "blue | \n", "[https://swapi.co/api/films/5/, https://swapi.... | \n", "male | \n", "blond | \n", "188 | \n", "https://swapi.co/api/planets/1/ | \n", "84 | \n", "Anakin Skywalker | \n", "fair | \n", "[https://swapi.co/api/species/1/] | \n", "[https://swapi.co/api/starships/59/, https://s... | \n", "https://swapi.co/api/people/11/ | \n", "[https://swapi.co/api/vehicles/44/, https://sw... | \n", "
11 | \n", "64BBY | \n", "2014-12-10T16:26:56.138000Z | \n", "2014-12-20T21:17:50.330000Z | \n", "blue | \n", "[https://swapi.co/api/films/6/, https://swapi.... | \n", "male | \n", "auburn, grey | \n", "180 | \n", "https://swapi.co/api/planets/21/ | \n", "unknown | \n", "Wilhuff Tarkin | \n", "fair | \n", "[https://swapi.co/api/species/1/] | \n", "[] | \n", "https://swapi.co/api/people/12/ | \n", "[] | \n", "
12 | \n", "200BBY | \n", "2014-12-10T16:42:45.066000Z | \n", "2014-12-20T21:17:50.332000Z | \n", "blue | \n", "[https://swapi.co/api/films/2/, https://swapi.... | \n", "male | \n", "brown | \n", "228 | \n", "https://swapi.co/api/planets/14/ | \n", "112 | \n", "Chewbacca | \n", "unknown | \n", "[https://swapi.co/api/species/3/] | \n", "[https://swapi.co/api/starships/10/, https://s... | \n", "https://swapi.co/api/people/13/ | \n", "[https://swapi.co/api/vehicles/19/] | \n", "
13 | \n", "29BBY | \n", "2014-12-10T16:49:14.582000Z | \n", "2014-12-20T21:17:50.334000Z | \n", "brown | \n", "[https://swapi.co/api/films/2/, https://swapi.... | \n", "male | \n", "brown | \n", "180 | \n", "https://swapi.co/api/planets/22/ | \n", "80 | \n", "Han Solo | \n", "fair | \n", "[https://swapi.co/api/species/1/] | \n", "[https://swapi.co/api/starships/10/, https://s... | \n", "https://swapi.co/api/people/14/ | \n", "[] | \n", "
14 | \n", "44BBY | \n", "2014-12-10T17:03:30.334000Z | \n", "2014-12-20T21:17:50.336000Z | \n", "black | \n", "[https://swapi.co/api/films/1/] | \n", "male | \n", "n/a | \n", "173 | \n", "https://swapi.co/api/planets/23/ | \n", "74 | \n", "Greedo | \n", "green | \n", "[https://swapi.co/api/species/4/] | \n", "[] | \n", "https://swapi.co/api/people/15/ | \n", "[] | \n", "
15 | \n", "600BBY | \n", "2014-12-10T17:11:31.638000Z | \n", "2014-12-20T21:17:50.338000Z | \n", "orange | \n", "[https://swapi.co/api/films/4/, https://swapi.... | \n", "hermaphrodite | \n", "n/a | \n", "175 | \n", "https://swapi.co/api/planets/24/ | \n", "1,358 | \n", "Jabba Desilijic Tiure | \n", "green-tan, brown | \n", "[https://swapi.co/api/species/5/] | \n", "[] | \n", "https://swapi.co/api/people/16/ | \n", "[] | \n", "
16 | \n", "21BBY | \n", "2014-12-12T11:08:06.469000Z | \n", "2014-12-20T21:17:50.341000Z | \n", "hazel | \n", "[https://swapi.co/api/films/2/, https://swapi.... | \n", "male | \n", "brown | \n", "170 | \n", "https://swapi.co/api/planets/22/ | \n", "77 | \n", "Wedge Antilles | \n", "fair | \n", "[https://swapi.co/api/species/1/] | \n", "[https://swapi.co/api/starships/12/] | \n", "https://swapi.co/api/people/18/ | \n", "[https://swapi.co/api/vehicles/14/] | \n", "
17 | \n", "unknown | \n", "2014-12-12T11:16:56.569000Z | \n", "2014-12-20T21:17:50.343000Z | \n", "blue | \n", "[https://swapi.co/api/films/1/] | \n", "male | \n", "brown | \n", "180 | \n", "https://swapi.co/api/planets/26/ | \n", "110 | \n", "Jek Tono Porkins | \n", "fair | \n", "[https://swapi.co/api/species/1/] | \n", "[https://swapi.co/api/starships/12/] | \n", "https://swapi.co/api/people/19/ | \n", "[] | \n", "
18 | \n", "896BBY | \n", "2014-12-15T12:26:01.042000Z | \n", "2014-12-20T21:17:50.345000Z | \n", "brown | \n", "[https://swapi.co/api/films/2/, https://swapi.... | \n", "male | \n", "white | \n", "66 | \n", "https://swapi.co/api/planets/28/ | \n", "17 | \n", "Yoda | \n", "green | \n", "[https://swapi.co/api/species/6/] | \n", "[] | \n", "https://swapi.co/api/people/20/ | \n", "[] | \n", "
19 | \n", "82BBY | \n", "2014-12-15T12:48:05.971000Z | \n", "2014-12-20T21:17:50.347000Z | \n", "yellow | \n", "[https://swapi.co/api/films/2/, https://swapi.... | \n", "male | \n", "grey | \n", "170 | \n", "https://swapi.co/api/planets/8/ | \n", "75 | \n", "Palpatine | \n", "pale | \n", "[https://swapi.co/api/species/1/] | \n", "[] | \n", "https://swapi.co/api/people/21/ | \n", "[] | \n", "
20 | \n", "31.5BBY | \n", "2014-12-15T12:49:32.457000Z | \n", "2014-12-20T21:17:50.349000Z | \n", "brown | \n", "[https://swapi.co/api/films/2/, https://swapi.... | \n", "male | \n", "black | \n", "183 | \n", "https://swapi.co/api/planets/10/ | \n", "78.2 | \n", "Boba Fett | \n", "fair | \n", "[https://swapi.co/api/species/1/] | \n", "[https://swapi.co/api/starships/21/] | \n", "https://swapi.co/api/people/22/ | \n", "[] | \n", "
21 | \n", "15BBY | \n", "2014-12-15T12:51:10.076000Z | \n", "2014-12-20T21:17:50.351000Z | \n", "red | \n", "[https://swapi.co/api/films/2/] | \n", "none | \n", "none | \n", "200 | \n", "https://swapi.co/api/planets/28/ | \n", "140 | \n", "IG-88 | \n", "metal | \n", "[https://swapi.co/api/species/2/] | \n", "[] | \n", "https://swapi.co/api/people/23/ | \n", "[] | \n", "
22 | \n", "53BBY | \n", "2014-12-15T12:53:49.297000Z | \n", "2014-12-20T21:17:50.355000Z | \n", "red | \n", "[https://swapi.co/api/films/2/] | \n", "male | \n", "none | \n", "190 | \n", "https://swapi.co/api/planets/29/ | \n", "113 | \n", "Bossk | \n", "green | \n", "[https://swapi.co/api/species/7/] | \n", "[] | \n", "https://swapi.co/api/people/24/ | \n", "[] | \n", "
23 | \n", "31BBY | \n", "2014-12-15T12:56:32.683000Z | \n", "2014-12-20T21:17:50.357000Z | \n", "brown | \n", "[https://swapi.co/api/films/2/, https://swapi.... | \n", "male | \n", "black | \n", "177 | \n", "https://swapi.co/api/planets/30/ | \n", "79 | \n", "Lando Calrissian | \n", "dark | \n", "[https://swapi.co/api/species/1/] | \n", "[https://swapi.co/api/starships/10/] | \n", "https://swapi.co/api/people/25/ | \n", "[] | \n", "
24 | \n", "37BBY | \n", "2014-12-15T13:01:57.178000Z | \n", "2014-12-20T21:17:50.359000Z | \n", "blue | \n", "[https://swapi.co/api/films/2/] | \n", "male | \n", "none | \n", "175 | \n", "https://swapi.co/api/planets/6/ | \n", "79 | \n", "Lobot | \n", "light | \n", "[https://swapi.co/api/species/1/] | \n", "[] | \n", "https://swapi.co/api/people/26/ | \n", "[] | \n", "
25 | \n", "41BBY | \n", "2014-12-18T11:07:50.584000Z | \n", "2014-12-20T21:17:50.362000Z | \n", "orange | \n", "[https://swapi.co/api/films/3/, https://swapi.... | \n", "male | \n", "none | \n", "180 | \n", "https://swapi.co/api/planets/31/ | \n", "83 | \n", "Ackbar | \n", "brown mottle | \n", "[https://swapi.co/api/species/8/] | \n", "[] | \n", "https://swapi.co/api/people/27/ | \n", "[] | \n", "
26 | \n", "48BBY | \n", "2014-12-18T11:12:38.895000Z | \n", "2014-12-20T21:17:50.364000Z | \n", "blue | \n", "[https://swapi.co/api/films/3/] | \n", "female | \n", "auburn | \n", "150 | \n", "https://swapi.co/api/planets/32/ | \n", "unknown | \n", "Mon Mothma | \n", "fair | \n", "[https://swapi.co/api/species/1/] | \n", "[] | \n", "https://swapi.co/api/people/28/ | \n", "[] | \n", "
27 | \n", "unknown | \n", "2014-12-18T11:16:33.020000Z | \n", "2014-12-20T21:17:50.367000Z | \n", "brown | \n", "[https://swapi.co/api/films/3/] | \n", "male | \n", "brown | \n", "unknown | \n", "https://swapi.co/api/planets/28/ | \n", "unknown | \n", "Arvel Crynyd | \n", "fair | \n", "[https://swapi.co/api/species/1/] | \n", "[https://swapi.co/api/starships/28/] | \n", "https://swapi.co/api/people/29/ | \n", "[] | \n", "
28 | \n", "8BBY | \n", "2014-12-18T11:21:58.954000Z | \n", "2014-12-20T21:17:50.369000Z | \n", "brown | \n", "[https://swapi.co/api/films/3/] | \n", "male | \n", "brown | \n", "88 | \n", "https://swapi.co/api/planets/7/ | \n", "20 | \n", "Wicket Systri Warrick | \n", "brown | \n", "[https://swapi.co/api/species/9/] | \n", "[] | \n", "https://swapi.co/api/people/30/ | \n", "[] | \n", "
29 | \n", "unknown | \n", "2014-12-18T11:26:18.541000Z | \n", "2014-12-20T21:17:50.371000Z | \n", "black | \n", "[https://swapi.co/api/films/3/] | \n", "male | \n", "none | \n", "160 | \n", "https://swapi.co/api/planets/33/ | \n", "68 | \n", "Nien Nunb | \n", "grey | \n", "[https://swapi.co/api/species/10/] | \n", "[https://swapi.co/api/starships/10/] | \n", "https://swapi.co/api/people/31/ | \n", "[] | \n", "
... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "
57 | \n", "unknown | \n", "2014-12-20T11:11:39.630000Z | \n", "2014-12-20T21:17:50.449000Z | \n", "brown | \n", "[https://swapi.co/api/films/5/] | \n", "female | \n", "brown | \n", "157 | \n", "https://swapi.co/api/planets/8/ | \n", "unknown | \n", "CordƩ | \n", "light | \n", "[https://swapi.co/api/species/1/] | \n", "[] | \n", "https://swapi.co/api/people/61/ | \n", "[] | \n", "
58 | \n", "82BBY | \n", "2014-12-20T15:59:03.958000Z | \n", "2014-12-20T21:17:50.451000Z | \n", "blue | \n", "[https://swapi.co/api/films/5/] | \n", "male | \n", "brown | \n", "183 | \n", "https://swapi.co/api/planets/1/ | \n", "unknown | \n", "Cliegg Lars | \n", "fair | \n", "[https://swapi.co/api/species/1/] | \n", "[] | \n", "https://swapi.co/api/people/62/ | \n", "[] | \n", "
59 | \n", "unknown | \n", "2014-12-20T16:40:43.977000Z | \n", "2014-12-20T21:17:50.453000Z | \n", "yellow | \n", "[https://swapi.co/api/films/5/, https://swapi.... | \n", "male | \n", "none | \n", "183 | \n", "https://swapi.co/api/planets/11/ | \n", "80 | \n", "Poggle the Lesser | \n", "green | \n", "[https://swapi.co/api/species/28/] | \n", "[] | \n", "https://swapi.co/api/people/63/ | \n", "[] | \n", "
60 | \n", "58BBY | \n", "2014-12-20T16:45:53.668000Z | \n", "2014-12-20T21:17:50.455000Z | \n", "blue | \n", "[https://swapi.co/api/films/5/, https://swapi.... | \n", "female | \n", "black | \n", "170 | \n", "https://swapi.co/api/planets/51/ | \n", "56.2 | \n", "Luminara Unduli | \n", "yellow | \n", "[https://swapi.co/api/species/29/] | \n", "[] | \n", "https://swapi.co/api/people/64/ | \n", "[] | \n", "
61 | \n", "40BBY | \n", "2014-12-20T16:46:40.440000Z | \n", "2014-12-20T21:17:50.457000Z | \n", "blue | \n", "[https://swapi.co/api/films/5/] | \n", "female | \n", "black | \n", "166 | \n", "https://swapi.co/api/planets/51/ | \n", "50 | \n", "Barriss Offee | \n", "yellow | \n", "[https://swapi.co/api/species/29/] | \n", "[] | \n", "https://swapi.co/api/people/65/ | \n", "[] | \n", "
62 | \n", "unknown | \n", "2014-12-20T16:49:14.640000Z | \n", "2014-12-20T21:17:50.460000Z | \n", "brown | \n", "[https://swapi.co/api/films/5/] | \n", "female | \n", "brown | \n", "165 | \n", "https://swapi.co/api/planets/8/ | \n", "unknown | \n", "DormƩ | \n", "light | \n", "[https://swapi.co/api/species/1/] | \n", "[] | \n", "https://swapi.co/api/people/66/ | \n", "[] | \n", "
63 | \n", "102BBY | \n", "2014-12-20T16:52:14.726000Z | \n", "2014-12-20T21:17:50.462000Z | \n", "brown | \n", "[https://swapi.co/api/films/5/, https://swapi.... | \n", "male | \n", "white | \n", "193 | \n", "https://swapi.co/api/planets/52/ | \n", "80 | \n", "Dooku | \n", "fair | \n", "[https://swapi.co/api/species/1/] | \n", "[] | \n", "https://swapi.co/api/people/67/ | \n", "[https://swapi.co/api/vehicles/55/] | \n", "
64 | \n", "67BBY | \n", "2014-12-20T16:53:08.575000Z | \n", "2014-12-20T21:17:50.463000Z | \n", "brown | \n", "[https://swapi.co/api/films/5/, https://swapi.... | \n", "male | \n", "black | \n", "191 | \n", "https://swapi.co/api/planets/2/ | \n", "unknown | \n", "Bail Prestor Organa | \n", "tan | \n", "[https://swapi.co/api/species/1/] | \n", "[] | \n", "https://swapi.co/api/people/68/ | \n", "[] | \n", "
65 | \n", "66BBY | \n", "2014-12-20T16:54:41.620000Z | \n", "2014-12-20T21:17:50.465000Z | \n", "brown | \n", "[https://swapi.co/api/films/5/] | \n", "male | \n", "black | \n", "183 | \n", "https://swapi.co/api/planets/53/ | \n", "79 | \n", "Jango Fett | \n", "tan | \n", "[https://swapi.co/api/species/1/] | \n", "[] | \n", "https://swapi.co/api/people/69/ | \n", "[] | \n", "
66 | \n", "unknown | \n", "2014-12-20T16:57:44.471000Z | \n", "2014-12-20T21:17:50.468000Z | \n", "yellow | \n", "[https://swapi.co/api/films/5/] | \n", "female | \n", "blonde | \n", "168 | \n", "https://swapi.co/api/planets/54/ | \n", "55 | \n", "Zam Wesell | \n", "fair, green, yellow | \n", "[https://swapi.co/api/species/30/] | \n", "[] | \n", "https://swapi.co/api/people/70/ | \n", "[https://swapi.co/api/vehicles/45/] | \n", "
67 | \n", "unknown | \n", "2014-12-20T17:28:27.248000Z | \n", "2014-12-20T21:17:50.470000Z | \n", "yellow | \n", "[https://swapi.co/api/films/5/] | \n", "male | \n", "none | \n", "198 | \n", "https://swapi.co/api/planets/55/ | \n", "102 | \n", "Dexter Jettster | \n", "brown | \n", "[https://swapi.co/api/species/31/] | \n", "[] | \n", "https://swapi.co/api/people/71/ | \n", "[] | \n", "
68 | \n", "unknown | \n", "2014-12-20T17:30:50.416000Z | \n", "2014-12-20T21:17:50.473000Z | \n", "black | \n", "[https://swapi.co/api/films/5/] | \n", "male | \n", "none | \n", "229 | \n", "https://swapi.co/api/planets/10/ | \n", "88 | \n", "Lama Su | \n", "grey | \n", "[https://swapi.co/api/species/32/] | \n", "[] | \n", "https://swapi.co/api/people/72/ | \n", "[] | \n", "
69 | \n", "unknown | \n", "2014-12-20T17:31:21.195000Z | \n", "2014-12-20T21:17:50.474000Z | \n", "black | \n", "[https://swapi.co/api/films/5/] | \n", "female | \n", "none | \n", "213 | \n", "https://swapi.co/api/planets/10/ | \n", "unknown | \n", "Taun We | \n", "grey | \n", "[https://swapi.co/api/species/32/] | \n", "[] | \n", "https://swapi.co/api/people/73/ | \n", "[] | \n", "
70 | \n", "unknown | \n", "2014-12-20T17:32:51.996000Z | \n", "2014-12-20T21:17:50.476000Z | \n", "blue | \n", "[https://swapi.co/api/films/5/] | \n", "female | \n", "white | \n", "167 | \n", "https://swapi.co/api/planets/9/ | \n", "unknown | \n", "Jocasta Nu | \n", "fair | \n", "[https://swapi.co/api/species/1/] | \n", "[] | \n", "https://swapi.co/api/people/74/ | \n", "[] | \n", "
71 | \n", "unknown | \n", "2014-12-20T09:53:15.086000Z | \n", "2016-06-30T12:52:19.604868Z | \n", "unknown | \n", "[https://swapi.co/api/films/4/] | \n", "male | \n", "none | \n", "79 | \n", "https://swapi.co/api/planets/38/ | \n", "15 | \n", "Ratts Tyerell | \n", "grey, blue | \n", "[https://swapi.co/api/species/16/] | \n", "[] | \n", "https://swapi.co/api/people/47/ | \n", "[] | \n", "
72 | \n", "unknown | \n", "2014-12-20T17:43:36.409000Z | \n", "2014-12-20T21:17:50.478000Z | \n", "red, blue | \n", "[https://swapi.co/api/films/5/, https://swapi.... | \n", "female | \n", "none | \n", "96 | \n", "https://swapi.co/api/planets/28/ | \n", "unknown | \n", "R4-P17 | \n", "silver, red | \n", "[] | \n", "[] | \n", "https://swapi.co/api/people/75/ | \n", "[] | \n", "
73 | \n", "unknown | \n", "2014-12-20T17:53:52.607000Z | \n", "2014-12-20T21:17:50.481000Z | \n", "unknown | \n", "[https://swapi.co/api/films/5/] | \n", "male | \n", "none | \n", "193 | \n", "https://swapi.co/api/planets/56/ | \n", "48 | \n", "Wat Tambor | \n", "green, grey | \n", "[https://swapi.co/api/species/33/] | \n", "[] | \n", "https://swapi.co/api/people/76/ | \n", "[] | \n", "
74 | \n", "unknown | \n", "2014-12-20T17:58:17.049000Z | \n", "2014-12-20T21:17:50.484000Z | \n", "gold | \n", "[https://swapi.co/api/films/5/] | \n", "male | \n", "none | \n", "191 | \n", "https://swapi.co/api/planets/57/ | \n", "unknown | \n", "San Hill | \n", "grey | \n", "[https://swapi.co/api/species/34/] | \n", "[] | \n", "https://swapi.co/api/people/77/ | \n", "[] | \n", "
75 | \n", "unknown | \n", "2014-12-20T18:44:01.103000Z | \n", "2014-12-20T21:17:50.486000Z | \n", "black | \n", "[https://swapi.co/api/films/5/, https://swapi.... | \n", "female | \n", "none | \n", "178 | \n", "https://swapi.co/api/planets/58/ | \n", "57 | \n", "Shaak Ti | \n", "red, blue, white | \n", "[https://swapi.co/api/species/35/] | \n", "[] | \n", "https://swapi.co/api/people/78/ | \n", "[] | \n", "
76 | \n", "unknown | \n", "2014-12-20T19:43:53.348000Z | \n", "2014-12-20T21:17:50.488000Z | \n", "green, yellow | \n", "[https://swapi.co/api/films/6/] | \n", "male | \n", "none | \n", "216 | \n", "https://swapi.co/api/planets/59/ | \n", "159 | \n", "Grievous | \n", "brown, white | \n", "[https://swapi.co/api/species/36/] | \n", "[https://swapi.co/api/starships/74/] | \n", "https://swapi.co/api/people/79/ | \n", "[https://swapi.co/api/vehicles/60/] | \n", "
77 | \n", "unknown | \n", "2014-12-20T19:46:34.209000Z | \n", "2014-12-20T21:17:50.491000Z | \n", "blue | \n", "[https://swapi.co/api/films/6/] | \n", "male | \n", "brown | \n", "234 | \n", "https://swapi.co/api/planets/14/ | \n", "136 | \n", "Tarfful | \n", "brown | \n", "[https://swapi.co/api/species/3/] | \n", "[] | \n", "https://swapi.co/api/people/80/ | \n", "[] | \n", "
78 | \n", "unknown | \n", "2014-12-20T19:49:35.583000Z | \n", "2014-12-20T21:17:50.493000Z | \n", "brown | \n", "[https://swapi.co/api/films/6/, https://swapi.... | \n", "male | \n", "brown | \n", "188 | \n", "https://swapi.co/api/planets/2/ | \n", "79 | \n", "Raymus Antilles | \n", "light | \n", "[https://swapi.co/api/species/1/] | \n", "[] | \n", "https://swapi.co/api/people/81/ | \n", "[] | \n", "
79 | \n", "unknown | \n", "2014-12-20T20:18:37.619000Z | \n", "2014-12-20T21:17:50.496000Z | \n", "white | \n", "[https://swapi.co/api/films/5/, https://swapi.... | \n", "female | \n", "none | \n", "178 | \n", "https://swapi.co/api/planets/60/ | \n", "48 | \n", "Sly Moore | \n", "pale | \n", "[] | \n", "[] | \n", "https://swapi.co/api/people/82/ | \n", "[] | \n", "
80 | \n", "unknown | \n", "2014-12-20T20:35:04.260000Z | \n", "2014-12-20T21:17:50.498000Z | \n", "black | \n", "[https://swapi.co/api/films/6/] | \n", "male | \n", "none | \n", "206 | \n", "https://swapi.co/api/planets/12/ | \n", "80 | \n", "Tion Medon | \n", "grey | \n", "[https://swapi.co/api/species/37/] | \n", "[] | \n", "https://swapi.co/api/people/83/ | \n", "[] | \n", "
81 | \n", "unknown | \n", "2015-04-17T06:52:40.793621Z | \n", "2015-04-17T06:52:40.793674Z | \n", "dark | \n", "[https://swapi.co/api/films/7/] | \n", "male | \n", "black | \n", "unknown | \n", "https://swapi.co/api/planets/28/ | \n", "unknown | \n", "Finn | \n", "dark | \n", "[https://swapi.co/api/species/1/] | \n", "[] | \n", "https://swapi.co/api/people/84/ | \n", "[] | \n", "
82 | \n", "unknown | \n", "2015-04-17T06:54:01.495077Z | \n", "2015-04-17T06:54:01.495128Z | \n", "hazel | \n", "[https://swapi.co/api/films/7/] | \n", "female | \n", "brown | \n", "unknown | \n", "https://swapi.co/api/planets/28/ | \n", "unknown | \n", "Rey | \n", "light | \n", "[https://swapi.co/api/species/1/] | \n", "[] | \n", "https://swapi.co/api/people/85/ | \n", "[] | \n", "
83 | \n", "unknown | \n", "2015-04-17T06:55:21.622786Z | \n", "2015-04-17T06:55:21.622835Z | \n", "brown | \n", "[https://swapi.co/api/films/7/] | \n", "male | \n", "brown | \n", "unknown | \n", "https://swapi.co/api/planets/28/ | \n", "unknown | \n", "Poe Dameron | \n", "light | \n", "[https://swapi.co/api/species/1/] | \n", "[https://swapi.co/api/starships/77/] | \n", "https://swapi.co/api/people/86/ | \n", "[] | \n", "
84 | \n", "unknown | \n", "2015-04-17T06:57:38.061346Z | \n", "2015-04-17T06:57:38.061453Z | \n", "black | \n", "[https://swapi.co/api/films/7/] | \n", "none | \n", "none | \n", "unknown | \n", "https://swapi.co/api/planets/28/ | \n", "unknown | \n", "BB8 | \n", "none | \n", "[https://swapi.co/api/species/2/] | \n", "[] | \n", "https://swapi.co/api/people/87/ | \n", "[] | \n", "
85 | \n", "unknown | \n", "2015-10-13T10:35:39.229823Z | \n", "2015-10-13T10:35:39.229894Z | \n", "unknown | \n", "[https://swapi.co/api/films/7/] | \n", "female | \n", "unknown | \n", "unknown | \n", "https://swapi.co/api/planets/28/ | \n", "unknown | \n", "Captain Phasma | \n", "unknown | \n", "[] | \n", "[] | \n", "https://swapi.co/api/people/88/ | \n", "[] | \n", "
86 | \n", "46BBY | \n", "2014-12-19T17:28:26.926000Z | \n", "2016-04-20T17:06:31.502555Z | \n", "brown | \n", "[https://swapi.co/api/films/5/, https://swapi.... | \n", "female | \n", "brown | \n", "165 | \n", "https://swapi.co/api/planets/8/ | \n", "45 | \n", "PadmƩ Amidala | \n", "light | \n", "[https://swapi.co/api/species/1/] | \n", "[https://swapi.co/api/starships/49/, https://s... | \n", "https://swapi.co/api/people/35/ | \n", "[] | \n", "
87 rows Ć 16 columns
\n", "\n", " | name | \n", "height | \n", "
---|---|---|
2 | \n", "R2-D2 | \n", "96.0 | \n", "
7 | \n", "R5-D4 | \n", "97.0 | \n", "
18 | \n", "Yoda | \n", "66.0 | \n", "
28 | \n", "Wicket Systri Warrick | \n", "88.0 | \n", "
37 | \n", "Watto | \n", "137.0 | \n", "
38 | \n", "Sebulba | \n", "112.0 | \n", "
44 | \n", "Dud Bolt | \n", "94.0 | \n", "
45 | \n", "Gasgano | \n", "122.0 | \n", "
71 | \n", "Ratts Tyerell | \n", "79.0 | \n", "
72 | \n", "R4-P17 | \n", "96.0 | \n", "