A Python helper library for swapi.co - the Star Wars API
NOTE: Tests will run against hosted API as opposed to data from github repo
- Free software: BSD license
- Documentation: https://swapi-python.readthedocs.org.
At the command line:
$ pip install swapi
To use swapi-python in a project:
import swapi
All resources are accessible through the top-level get_resource() methods:
luke = swapi.get_person(1) tatooine = swapi.get_planet(1)
These are the top-level methods you can use to get resources from swapi.co. To learn more about the models and objects that are returned, see the models page.
Return a single Person resource.
Example:
swapi.get_person(1) >>> <Person - Luke Skywalker>
Return a single Planet resource.
Example:
swapi.get_planet(1) >>> <Planet - Tatooine>
Return a single Starship resource.
Example:
swapi.get_starship(6) >>> <Starship - Death Star>
Return a single Vehicle resource.
Example:
swapi.get_vehicle(4) >>> <Vehicle - Sand Crawler>
Return a single Film resource.
Example:
swapi.get_film(1) >>> <Film - A New Hope>
Return a QuerySet containing all the items in a single resource. See the `models` page for more information on the models used in swapi-python.
Example:
swapi.get_all("films")
>>> <FilmQuerySet - 6>