StarPy – A Python Library for the SWAPI (Star Wars API)
Would you like to know who is the fastest pilot in the galaxy? Or which vehicles or starships perform better? This is the universe you can do the search!
StarPy is a python library and also a command line interface (CLI) for the swapi.co
If you still don’t know what I am talking about
According to the swapi.co website:
The Star Wars API, or “swapi” (Swah-pee) is the world’s first quantified and programmatically-accessible data source for all the data from the Star Wars canon universe! We’ve taken all the rich contextual stuff from the universe and formatted into something easier to consume with software. Then we went and stuck an API on the front so you can access it all!

You can visit their page if you want more details at https://swapi.co/
Alright! To get started is pretty easy tho! First you have to clone this repository from my github page create a virtual environment and then install the requirements.
Installation
Beautiful is better than ugly so first create a virtual environment to avoid future version problems.
[console style="vs"] $ python3 -m venv venv $ source venv/bin/activate $ pip3 install -r requirements.txt [/console]
Basic Usage
StarPy Command Line Interface (CLI)
From the command line, you can run:
[bash style="vs"] $ python start.py command arg [/bash]
Examples:
[bash style="vs"] $ python start.py fastest-person-with-s # Returns the fastest person driving a starship $ python start.py vehicles-speed-by-person 1 # Returns Luke's vehicles and its max. speed start.py fastest-person-with-s start.py fastest-person-with-v start.py find-fastest-s start.py find-fastest-v start.py find-pilots-from-s start.py find-pilots-from-v start.py get-person-by-id ID_WANTED start.py get-starships-by-id ID_WANTED start.py get-vehicles-by-id ID_WANTED start.py id-fastest-pilot-s start.py id-fastest-pilot-v start.py id-fastest-pilots-s start.py id-fastest-pilots-v start.py name-and-max-speed-s start.py name-and-max-speed-v start.py pilot-names-s start.py pilot-names-v start.py starships-speed-by-person ID_WANTED start.py vehicles-speed-by-person ID_WANTED [/bash]
Simple is better than complex
To access resources it is better to instantiate the main class GetStars as:
[python style="vim"] s = starpy.GetStars() [/python]
If the implementation is easy to explain, it may be a good idea, so just use s.some_function():
Errors should never pass silently
So it is always good to be sure by running some tests:
[bash style="vs"] $ python3 -m unittest tests/test_api.py [/bash]
Explicit is better than implicit
All functions are available in documentation – https://dev.douglaspetrin.com/starpy/
Want to contribute to this project?
You are more than welcome! Just hit me up at https://github.com/douglaspetrin/starpy