Package: rocket-space-stuff
Rocket Space StuffRocket Space Stuff is a Python library that allows you to interact with various space-related API endpoints. With this library, you can retrieve information about astronauts, launches, and launchers.Links and Creators:Creator: Miro RavaLinkedin profileTester: Oleg LastocichinLinkedin profileGithub page for the entire projectInstallationpython-mpipinstallrocket-space-stuffUsage and methods for Astronaut ObjectsInitialize Astronaut ObjectFrom Database:# Initialize the SpaceAPI clientapi=SpaceApi()# Find astronaut by nameastro=api.find_astro_by('name','John Smith')Manuallyfromspace_pyimportAstronautastro=Astronaut({"name":name,"date_of_birth":birth,"date_of_death":death,"nationality":nationality,"bio":description,"twitter":twitter,"instagram":insta,"wiki":wiki,"profile_image":profile_img,"profile_image_thumbnail":profile_img_thmb,"flights_count":flights,"landings_count":landings,"last_flight":last_fl,"first_flight":first_fl,"status_name":status,"type_name":enroll,"agency_name":agency,"agency_type":agency_type,"agency_country_code":agency_countries,"agency_abbrev":agency_acr,"agency_logo_url":agency_logo})Getters and SettersageRetrieves the astronaut's age.# Get astronaut's ageage=astro.ageage_of_deathRetrieves the astronaut's age of death.# Get astronaut's age_of_deathage_of_death=astro.age_of_deathagency_abbrevRetrieves and Set the astronaut's agency abbreviation.# Get astronaut's agency abbreviationagency_abbrev=astro.agency_abbrev# Set astronaut's agency abbreviationastro.agency_abbrev="NASA"agency_country_codeRetrieves and Set the astronaut's agency country code.# Get astronaut's agency country codeagency_country_code=astro.agency_country_code# Set astronaut's agency country codeastro.agency_country_code="US"agency_logo_urlRetrieves and Set the astronaut's agency logo url.# Get astronaut's agency logo urlagency_logo_url=astro.agency_logo_url# Set astronaut's agency logo urlastro.agency_logo_url="https://www.nasa.gov/sites/default/files/images/nasa-logo.png"agency_nameRetrieves and Set the astronaut's agency name.# Get astronaut's agency nameagency_name=astro.agency_name# Set astronaut's agency nameastro.agency_name="National Aeronautics and Space Administration"agency_typeRetrieves and Set the astronaut's agency type.# Get astronaut's agency typeagency_type=astro.agency_type# Set astronaut's agency typeastro.agency_type="Governmental"bioRetrieves and Set the astronaut's bio.# Get astronaut's biobio=astro.bio# Set astronaut's bioastro.bio="John Smith is an astronaut with NASA. He has flown on 3 space missions."birth_dateRetrieves and Set the astronaut's birth date.# Get astronaut's birth datebirth_date=astro.birth_date# Set astronaut's birth dateastro.birth_date="1970-01-01"death_dateRetrieves and Set the astronaut's death date.# Get astronaut's death datedeath_date=astro.death_date# Set astronaut's death dateastro.death_date="2050-01-01"first_flightRetrieves and Set the astronaut's first flight.# Get astronaut's first flightfirst_flight=astro.first_flight# Set astronaut's first flightastro.first_flight="2000-01-01"flights_countRetrieves and Set the astronaut's flights count.# Get astronaut's flights countflights_count=astro.flights_count# Set astronaut's flights countastro.flights_count="3"instagramRetrieves and Set the astronaut's Instagram page url.# Get astronaut's Instagram page urlinstagram=astro.instagram# Set astronaut's Instagram handleastro.instagram="https://www.instagram.com/j_smith_astro"jsonifyRetrieves the astronaut's information in JSON format.# Get astronaut's information in JSON formatjson_data=astro.jsonifylandings_countRetrieves and Set the astronaut's landings count.# Get astronaut's landings countlandings_count=astro.landings_count# Set astronaut's landings countastro.landings_count="2"last_flightRetrieves and Set the astronaut's last flight.# Get astronaut's last flightlast_flight=astro.last_flight# Set astronaut's last flightastro.last_flight="2022-01-01"nameRetrieves and Set the astronaut's name.# Get astronaut's namename=astro.name# Set astronaut's nameastro.name="John Smith"nationalityRetrieves and Set the astronaut's nationality.# Get astronaut's nationalitynationality=astro.nationality# Set astronaut's nationalityastro.nationality="USA"profile_imageRetrieves and Set the astronaut's profile image url.# Get astronaut's profile image urlprofile_image=astro.profile_image# Set astronaut's profile image urlastro.profile_image="https://www.example.com/images/j_smith_astro.jpg"profile_image_thumbnailRetrieves and Set the astronaut's profile image thumbnail url.# Get astronaut's profile image thumbnail urlprofile_image_thumbnail=astro.profile_image_thumbnail# Set astronaut's profile image thumbnail urlastro.profile_image_thumbnail="https://www.example.com/images/j_smith_astro_thumbnail.jpg"show_basic_infoRetrieves the astronaut's basic information.# Get astronaut's basic informationbasic_info=astro.show_basic_infostatus_nameRetrieves and Set the astronaut's status name.# Get astronaut's status namestatus_name=astro.status_name# Set astronaut's status nameastro.status_name="Active"twitterRetrieves and Set the astronaut's twitter url.# Get astronaut's twitter urltwitter=astro.twitter# Set astronaut's twitter handleastro.twitter="https://twitter.com/j_smith_astro"type_nameRetrieves and Set the astronaut's type name.# Get astronaut's type nametype_name=astro.type_name# Set astronaut's type nameastro.type_name="Government"wikiRetrieves and Set the astronaut's wiki page url.# Get astronaut's wiki page urlwiki=astro.wiki# Set astronaut's wiki page urlastro.wiki="https://en.wikipedia.org/wiki/John_Smith_(astronaut)"Usage and methods for Launcher ObjectsInitialize Launcher ObjectFrom Database:# Initialize the SpaceAPI clientapi=SpaceApi()# Find astronaut by namelauncher=api.find_launcher_by('full_name','Atlas V')Manuallyfromspace_pyimportLauncherlauncher=Launcher({"flight_proven":flight_proven,"serial_number":serial_number,"status":status,"details":details,"image_url":image_url,"flights":flights,"last_launch_date":last_launch_date,"first_launch_date":first_launch_date,"launcher_config_full_name":launcher_config_full_name})The methodsjsonifyandshow_basic_infoare similar to the Astronaut's ones.All these following methods are both Getters and Setters similarly to the Astronaut's ones:[launcher.description,launcher.first_launch,launcher.flights_count,launcher.full_name,launcher.is_flight_proven,launcher.last_launch,launcher.launcher_image,launcher.serial_n,launcher.status]Usage and methods for Launch ObjectsInitialize Launch ObjectFrom Database:# Initialize the SpaceAPI clientapi=SpaceApi()# Find astronaut by namelaunch=api.find_launch_by('name','Atlas V')Manuallyfromspace_pyimportLaunchlaunch=Launch({"name":name,"net":net,"window_start":window_start,"window_end":window_end,"failreason":fail_reason,"image":image,"infographic":infographic,"orbital_launch_attempt_count":orbital_launch_attempt_count,"orbital_launch_attempt_count_year":orbital_launch_attempt_count_year,"location_launch_attempt_count":location_launch_attempt_count,"location_launch_attempt_count_year":location_launch_attempt_count_year,"pad_launch_attempt_count":pad_launch_attempt_count,"pad_launch_attempt_count_year":pad_launch_attempt_count_year,"agency_launch_attempt_count":agency_launch_attempt_count,"agency_launch_attempt_count_year":agency_launch_attempt_count_year,"status_name":status_name,"launch_service_provider_name":launch_service_provider_name,"launch_service_provider_type":launch_service_provider_type,"rocket_id":rocket_id,"rocket_configuration_full_name":rocket_config_full_name,"mission_name":mission_name,"mission_description":mission_description,"mission_type":mission_type,"mission_orbit_name":mission_orbit_name,"pad_wiki_url":pad_wiki_url,"pad_longitude":pad_longitude,"pad_latitude":pad_latitude,"pad_location_name":pad_location_name,"pad_location_country_code":pad_location_country_code})The methodsjsonifyandshow_basic_infoare similar to the Astronaut's ones.All these methods are both Getters and Setters similarly to the Astronaut's ones:[launch.agency_launch_attempt_count,launch.agency_launch_attempt_count_year,launch.fail_reason,launch.image,launch.infographic,launch.jsonify,launch.launch_service_provider_name,launch.launch_service_provider_type,launch.location_launch_attempt_count,launch.location_launch_attempt_count_year,launch.mission_description,launch.mission_name,launch.mission_orbit_name,launch.mission_type,launch.name,launch.net,launch.orbital_launch_attempt_count,launch.orbital_launch_attempt_count_year,launch.pad_latitude,launch.pad_launch_attempt_count,launch.pad_launch_attempt_count_year,launch.pad_location_country_code,launch.pad_location_name,launch.pad_longitude,launch.pad_wiki_url,launch.rocket_config_full_name,launch.rocket_id,launch.show_basic_info,launch.status_name,launch.window_end,launch.window_start]Usage and methods for SpaceApi Objects###Populate Astronaut Launch and Launcher with SpaceApiInstead of Initializing manually Astronaut, Launch or Launcher Objects, we can use SpaceApipopulatemethods.fromspace_pyimportSpaceApiapi=SpaceApi()astro=api.populate_astro(name:str,birth:str,death:str,nationality:str,description:str,flights:str,landings:str,last_fl:str,agency_acr:str,twitter:str="None",insta:str="None",wiki:str="None",profile_img:str="None",profile_img_thmb:str="None",first_fl:str="None",status:str="None",enroll:str="None",agency:str="None",agency_type:str="None",agency_countries:str="None",agency_logo:str="None")launch=api.populate_launch(name:str,net:str,status_name:str,launch_service_provider_name:str,rocket_config_full_name:str,mission_description:str,pad_location_name:str,window_start:str="None",window_end:str="None",fail_reason:str="None",image:str="None",infographic:str="None",orbital_launch_attempt_count:str="None",orbital_launch_attempt_count_year:str="None",location_launch_attempt_count:str="None",location_launch_attempt_count_year:str="None",pad_launch_attempt_count:str="None",pad_launch_attempt_count_year:str="None",agency_launch_attempt_count:str="None",agency_launch_attempt_count_year:str="None",launch_service_provider_type:str="None",rocket_id:str="None",mission_name:str="None",mission_type:str="None",mission_orbit_name:str="None",pad_wiki_url:str="None",pad_longitude:str="None",pad_latitude:str="None",pad_location_country_code:str="None")launcher=api.populate_launcher(launcher_config_full_name:str,serial_number:str,status:str,details:str,flights:str,image_url:str="None",last_launch_date:str="None",first_launch_date:str="None",flight_proven:str="False")Url methodsdefault_url: Returns the default API URL.fromspace_pyimportSpaceApiapi=SpaceApi()default_url=api.default_urlurl: Returns the current API URL and can permit you to change it.fromspace_pyimportSpaceApiapi=SpaceApi()print(api.url)# https://current-api-url.comnew_url='https://new-api-url.com'api.url=new_urlprint(api.url)# https://new-api-url.comAdd methodsadd_astro(astro: Astronaut): Adds a new astronaut to the API. Theastroparameter should be an Astronaut object containing the astronaut's information.fromspace_pyimportSpaceApi,Astronautapi=SpaceApi()new_astro=Astronaut({"name":name,"date_of_birth":birth,"date_of_death":death,"nationality":nationality,"bio":description,"twitter":twitter,"instagram":insta,"wiki":wiki,"profile_image":profile_img,"profile_image_thumbnail":profile_img_thmb,"flights_count":flights,"landings_count":landings,"last_flight":last_fl,"first_flight":first_fl,"status_name":status,"type_name":enroll,"agency_name":agency,"agency_type":agency_type,"agency_country_code":agency_countries,"agency_abbrev":agency_acr,"agency_logo_url":agency_logo})api.add_astro(new_astro)add_launch(launch: Launch): Adds a new launch to the API. Thelaunchparameter should be a Launch Object containing the launch's information.fromspace_pyimportSpaceApi,Launchapi=SpaceApi()new_astro=Launch({"name":name,"net":net,"window_start":window_start,"window_end":window_end,"failreason":fail_reason,"image":image,"infographic":infographic,"orbital_launch_attempt_count":orbital_launch_attempt_count,"orbital_launch_attempt_count_year":orbital_launch_attempt_count_year,"location_launch_attempt_count":location_launch_attempt_count,"location_launch_attempt_count_year":location_launch_attempt_count_year,"pad_launch_attempt_count":pad_launch_attempt_count,"pad_launch_attempt_count_year":pad_launch_attempt_count_year,"agency_launch_attempt_count":agency_launch_attempt_count,"agency_launch_attempt_count_year":agency_launch_attempt_count_year,"status_name":status_name,"launch_service_provider_name":launch_service_provider_name,"launch_service_provider_type":launch_service_provider_type,"rocket_id":rocket_id,"rocket_configuration_full_name":rocket_config_full_name,"mission_name":mission_name,"mission_description":mission_description,"mission_type":mission_type,"mission_orbit_name":mission_orbit_name,"pad_wiki_url":pad_wiki_url,"pad_longitude":pad_longitude,"pad_latitude":pad_latitude,"pad_location_name":pad_location_name,"pad_location_country_code":pad_location_country_code})api.add_launch(new_astro)add_launcher(launcher: Launcher): Adds a new launcher to the API. Thelauncherparameter should be a Launch Object containing the launcher's information.fromspace_pyimportSpaceApi,Launcherapi=SpaceApi()new_astro=Launcher({"flight_proven":flight_proven,"serial_number":serial_number,"status":status,"details":details,"image_url":image_url,"flights":flights,"last_launch_date":last_launch_date,"first_launch_date":first_launch_date,"launcher_config_full_name":launcher_config_full_name})api.add_launcher(new_astro)Delete methodsdelete_astro_by(field: str, value: str): Deletes an astronaut from the API based on the specified field and value.fromspace_pyimportSpaceApiapi=SpaceApi()api.delete_astro_by('name','John Smith')delete_launch_by(field: str, value: str): Deletes a launch from the API based on the specified field and value.fromspace_pyimportSpaceApiapi=SpaceApi()api.delete_launch_by('name','Falcon 9')delete_launcher_by(field: str, value: str): Deletes a launcher from the API based on the specified field and value.fromspace_pyimportSpaceApiapi=SpaceApi()api.delete_launcher_by('full_name','Atlas V')Find methodsUsed to find an entry with exact matchfind_astro_by(field: str, value: str): Retrieves an astronaut from the API based on the specified field and value. If astronaut is found,astrois an Astronaut Object, otherwise it is a string like:'entry non found'fromspace_pyimportSpaceApiapi=SpaceApi()astro=api.find_astro_by('name','John Smith')find_launch_by(field: str, value: str): Retrieves a launch from the API based on the specified field and value. If launch is found,launchis a Launch Object, otherwise it is a string like:'entry non found'fromspace_pyimportSpaceApiapi=SpaceApi()launch=api.find_launch_by('name','Falcon 9')find_launcher_by(field: str, value: str): Retrieves a launcher from the API based on the specified field and value. If launcher is found,launcheris a Launcher Object, otherwise it is a string like:'entry non found'fromspace_pyimportSpaceApiapi=SpaceApi()launcher=api.find_launcher_by('full_name','Atlas V')Search methodsUsed to search for and entry that containsvaluein thefieldsearch_astro_by(field: str, value: str): Retrieves an astronaut from the API based on the specified field and value. If astronaut is found,astrois a dictionary containing Astronaut Objects, otherwise it is a dictionary like:{'error':'entry non found'}fromspace_pyimportSpaceApiapi=SpaceApi()astro=api.search_astro_by('name','John Smith')search_launch_by(field: str, value: str): Retrieves a launch from the API based on the specified field and value. If launch is found,launchis a dictionary containing Launch Objects, otherwise it is a dictionary like:{'error':'entry non found'}fromspace_pyimportSpaceApiapi=SpaceApi()launch=api.search_launch_by('name','Falcon 9')search_launcher_by(field: str, value: str): Retrieves a launcher from the API based on the specified field and value. If launcher is found,launcheris a dictionary containing Launcher Objects, otherwise it is a dictionary like:{'error':'entry non found'}fromspace_pyimportSpaceApiapi=SpaceApi()launcher=api.search_launcher_by('full_name','Atlas V')Update methodsUsed to overwrite an entry that exactly machvalueinfieldupdate_astro_by(field: str, value: str, update: Astronaut): Updates an astronaut record in the API based on the specified field and value. Theastroparameter should be an Astronaut object containing the astronaut's information.fromspace_pyimportSpaceApi,Astronautapi=SpaceApi()updated_astro=Astronaut({"name":name,"date_of_birth":birth,"date_of_death":death,"nationality":nationality,"bio":description,"twitter":twitter,"instagram":insta,"wiki":wiki,"profile_image":profile_img,"profile_image_thumbnail":profile_img_thmb,"flights_count":flights,"landings_count":landings,"last_flight":last_fl,"first_flight":first_fl,"status_name":status,"type_name":enroll,"agency_name":agency,"agency_type":agency_type,"agency_country_code":agency_countries,"agency_abbrev":agency_acr,"agency_logo_url":agency_logo})api.update_astro_by('name','John Smith',updated_astro)update_launch_by(field: str, value: str, update: Launch): Updates a launch record in the API based on the specified field and value. Thelaunchparameter should be a Launch Object containing the launch's information.fromspace_pyimportSpaceApi,Launchapi=SpaceApi()updated_astro=Launch({"name":name,"net":net,"window_start":window_start,"window_end":window_end,"failreason":fail_reason,"image":image,"infographic":infographic,"orbital_launch_attempt_count":orbital_launch_attempt_count,"orbital_launch_attempt_count_year":orbital_launch_attempt_count_year,"location_launch_attempt_count":location_launch_attempt_count,"location_launch_attempt_count_year":location_launch_attempt_count_year,"pad_launch_attempt_count":pad_launch_attempt_count,"pad_launch_attempt_count_year":pad_launch_attempt_count_year,"agency_launch_attempt_count":agency_launch_attempt_count,"agency_launch_attempt_count_year":agency_launch_attempt_count_year,"status_name":status_name,"launch_service_provider_name":launch_service_provider_name,"launch_service_provider_type":launch_service_provider_type,"rocket_id":rocket_id,"rocket_configuration_full_name":rocket_config_full_name,"mission_name":mission_name,"mission_description":mission_description,"mission_type":mission_type,"mission_orbit_name":mission_orbit_name,"pad_wiki_url":pad_wiki_url,"pad_longitude":pad_longitude,"pad_latitude":pad_latitude,"pad_location_name":pad_location_name,"pad_location_country_code":pad_location_country_code})api.update_launch_by('name','Falcon 9',updated_astro)update_launcher_by(field: str, value: str, update: Launcher): Updates a launcher record in the API based on the specified field and value. Thelauncherparameter should be a Launch Object containing the launcher's information.fromspace_pyimportSpaceApi,Launcherapi=SpaceApi()updated_astro=Launcher({"flight_proven":flight_proven,"serial_number":serial_number,"status":status,"details":details,"image_url":image_url,"flights":flights,"last_launch_date":last_launch_date,"first_launch_date":first_launch_date,"launcher_config_full_name":launcher_config_full_name})api.update_launcher_by('full_name','Atlas V',updated_astro)ContributingIf you would like to contribute to the development of SpaceApi, please feel free to submit a pull request.