Skip to main content
===============================
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

* 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)
>>> <Person - Luke Skywalker>


get_planet(id)
------------

Return a single ``Planet`` resource.

Example::

swapi.get_planet(1)
>>> <Planet - Tatooine>


get_starship(id)
------------

Return a single ``Starship`` resource.

Example::

swapi.get_starship(6)
>>> <Starship - Death Star>


get_vehicle(id)
------------

Return a single ``Vehicle`` resource.

Example::

swapi.get_vehicle(4)
>>> <Vehicle - Sand Crawler>


get_film(id)
------------

Return a single ``Film`` resource.

Example::

swapi.get_film(1)
>>> <Film - A New Hope>


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")
>>> <FilmQuerySet - 6>




History
-------

0.1.0 (2014-12-21)
---------------------

* First release on PyPI.


0.1.2 (2014-12-22)
------------------

* Python 3.3 and Python 3.4 compatability


0.1.3 (2014-12-22)
-------------------

* Add "swapi-python" to User-Agent to help with analytics

Metadata

Release files for swapi 0.1.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for swapi 0.1.3
File Size Uploaded
swapi-0.1.3.tar.gz 15.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for swapi 0.1.3
File Interpreter ABI Platform
swapi-0.1.3-py2.py3-none-any.whl Python 3, Python 2 none any Details

Total release size: 22.8 kB

Release files / swapi-0.1.3.tar.gz

Download URL swapi-0.1.3.tar.gz
Size 15.7 kB
Tags Source
SHA-256 checksum
How to use checksums
e65b7d1a61cb074487c0760363b6796449286c9b3d5cbe47e8ecf467b20dd3fc
BLAKE2b-256 checksum
How to use checksums
4204f6083222f3e5807595b92b6f6889a56ea1e7cab7bf1a10f10aa72d4697ae
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / swapi-0.1.3-py2.py3-none-any.whl

Download URL swapi-0.1.3-py2.py3-none-any.whl
Size 7.2 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
97fe63f53a71cdb2b9ec66392051d8633f5bd596613bc463e2ce890cf22de129
BLAKE2b-256 checksum
How to use checksums
81bef8522ef8c7145309dfddb19376f486d3afc2ad1f09b65b22d5bf14d091ce
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.1.3 This release

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page