StarPy | Introduction¶
This is a python library and CLI for the Star Wars API (swapi.co).
This project is running on Python 3.6.7 but you can try in other versions as well.
Below you can find how to install it, the basic usage, CLI examples, how to test the project and the classes and its methods.
Installation¶
$ python3 -m venv venv
$ source venv/bin/activate
$ pip3 install -r requirements.txt
Basic Usage¶
import starpy
# Instance of the object
s = starpy.GetStars()
s.starships_speed_by_person(11)
# Returns: [[{'transport_id': '59', 'Max. Speed': '1050'}],
# [{'transport_id': '65', 'Max. Speed': '1500'}],
# [{'transport_id': '39', 'Max. Speed': '1100'}]]
s.fastest_person_with_v()
# Returns: [{'Name': 'Zam Wesell', 'Max. Speed': 800, 'Vehicle name': 'Koro-2 Exodrive airspeeder'}]
s.name_and_max_speed_v()
# Returns: [[{'Name': 'Zam Wesell', 'Max. Speed': 800, 'Vehicle name': 'Koro-2 Exodrive airspeeder'}],
# [{'Name': 'Anakin Skywalker', 'Max. Speed': 720, 'Vehicle name': 'XJ-6 airspeeder'}],
# [{'Name': 'Luke Skywalker', 'Max. Speed': 650, 'Vehicle name': 'Snowspeeder'}]]
s.name_and_max_speed_s()
# Returns: [[{'Name': 'Padmé Amidala', 'Max. Speed': 8000, 'Starship name': 'H-type Nubian yacht'}],
# [{'Name': 'Obi-Wan Kenobi', 'Max. Speed': 1500, 'Starship name': 'Jedi Interceptor'}],
# [{'Name': 'Arvel Crynyd', 'Max. Speed': 1300, 'Starship name': 'A-wing'}]]
s.find_fastest_s()
# Returns: {10: 8000, 14: 1500, 5: 1300}
s.id_fastest_pilots_s()
# Returns: ['35', '10', '29']
s.id_fastest_pilots_v()
# Returns: ['70', '11', '1']
s.pilot_names_s()
# Returns: ['Padmé Amidala', 'Obi-Wan Kenobi', 'Arvel Crynyd']
s.pilot_names_v()
# Returns: ['Zam Wesell', 'Anakin Skywalker', 'Luke Skywalker']
s.vehicles_speed_by_person(1)
# Returns: [[{'transport_id': '14', 'Max. Speed': '650'}],
# [{'transport_id': '30', 'Max. Speed': '360'}]]
Command Line Interface (CLI)¶
From the command line, you can run:
$ python start.py command arg
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 find-slowest-s
start.py find-slowest-v
start.py get-person-by-id <id>
start.py get-starships-by-id <id>
start.py get-vehicles-by-id <id>
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>
start.py vehicles-speed-by-person <id>
Classes¶
GetStars class inherits methods and variables from StarPyMae Class
-
class
starpy.api.
GetStars
[source]¶ Inherits methods and variables from StarPyMae Class
-
fastest_person_with_s
()[source]¶ Returns fastest person’s name, its transport’s name and its max.
speed reached driving StarShips
-
fastest_person_with_v
()[source]¶ Returns fastest person’s name, its transport’s name and its max.
speed reached driving Vehicles
-
get_starships_by_id
(rid)[source]¶ Gets star ship from id passed as argument to the rid parameter
:param rid :type: int :return:
-
get_vehicles_by_id
(rid)[source]¶ Gets vehicles data from its id passed as argument to rid parameter
:param rid :type int
-