https://github.com/phalt/swapi-python
The Python helper library for swapi.co
https://github.com/phalt/swapi-python
Last synced: about 1 year ago
JSON representation
The Python helper library for swapi.co
- Host: GitHub
- URL: https://github.com/phalt/swapi-python
- Owner: phalt
- License: bsd-3-clause
- Created: 2014-12-17T12:19:36.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2022-12-26T20:15:25.000Z (over 3 years ago)
- Last Synced: 2025-04-06T23:42:36.420Z (about 1 year ago)
- Language: Python
- Homepage: swapi.co
- Size: 39.1 KB
- Stars: 146
- Watchers: 11
- Forks: 43
- Open Issues: 11
-
Metadata Files:
- Readme: README.rst
- Changelog: HISTORY.rst
- Contributing: CONTRIBUTING.rst
- License: LICENSE
Awesome Lists containing this project
README
===============================
swapi-python
===============================
.. image:: https://badge.fury.io/py/swapi.png
:target: http://badge.fury.io/py/swapi
.. image:: https://travis-ci.org/phalt/swapi-python.png?branch=master
:target: https://travis-ci.org/phalt/swapi-python
.. image:: https://pypip.in/d/swapi/badge.png
:target: https://pypi.python.org/pypi/swapi
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.
============
Installation
============
At the command line::
$ pip install swapi
Basic Usage
========
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)
Methods
=======
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.
get_person(id)
------------
Return a single ``Person`` resource.
Example::
swapi.get_person(1)
>>>
get_planet(id)
------------
Return a single ``Planet`` resource.
Example::
swapi.get_planet(1)
>>>
get_starship(id)
------------
Return a single ``Starship`` resource.
Example::
swapi.get_starship(6)
>>>
get_vehicle(id)
------------
Return a single ``Vehicle`` resource.
Example::
swapi.get_vehicle(4)
>>>
get_film(id)
------------
Return a single ``Film`` resource.
Example::
swapi.get_film(1)
>>>
get_all("resource")
------------
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")
>>>