Skip to content

jkapsalis/SwAPI-cli-search-tool

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Star Wars API cli search tool

This is a cli tool to search for Star Wars characters to find information about their height, mass and also about their homeworld details using the SWAPI (star wars API).


Features

  1. Character Search
  • Gets and print information about a Star Wars character the user searched.
  • It has attributes such as height, mass, and birth year of the character.
  1. Homeworld Details
  • Prints the character's homeworld name, population, and orbital - rotation.
  • Calculates the time on the homeworld's character relates to Earth years and days and prints an ratio.

Prerequisites

Install the requirements.txt at my git repository :)


How to Run

Clone the repository and follow the commands to run the script :)

###for the character search###
python main.py search 'luke sky'

###for the homeworld details search of that character###
python main.py search'luke sky' --world

Sample Outputs

image

image


Code Overview

  1. def get_all_chars():

    Gets all the characters from the SWAPI. Converts the data response into JSON and extract all the info.

  2. def get_char_details(char_url):

    Gets the properties of a character or a planet from the URL.

  3. def search_char_name(results, name):

    Searches for a specific character by name from the list of fetched characters.

  4. Main

    Uses argparse to handle CLI commands and flags. Prints character and homeworld information based on the user's input.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages