A basic space api
Project description
Rocket Space Stuff
Rocket 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 Rava Linkedin profile
-
Tester: Oleg Lastocichin Linkedin profile
Installation
python -m pip install rocket-space-stuff
Usage and methods for Astronaut Objects
Initialize Astronaut Object
- From Database:
# Initialize the SpaceAPI client
api = SpaceApi()
# Find astronaut by name
astro = api.find_astro_by('name', 'John Smith')
- Manually
from space_py import Astronaut
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})
Getters and Setters
age
Retrieves the astronaut's age.
# Get astronaut's age
age = astro.age
age_of_death
Retrieves the astronaut's age of death.
# Get astronaut's age_of_death
age_of_death = astro.age_of_death
agency_abbrev
Retrieves and Set the astronaut's agency abbreviation.
# Get astronaut's agency abbreviation
agency_abbrev = astro.agency_abbrev
# Set astronaut's agency abbreviation
astro.agency_abbrev = "NASA"
agency_country_code
Retrieves and Set the astronaut's agency country code.
# Get astronaut's agency country code
agency_country_code = astro.agency_country_code
# Set astronaut's agency country code
astro.agency_country_code = "US"
agency_logo_url
Retrieves and Set the astronaut's agency logo url.
# Get astronaut's agency logo url
agency_logo_url = astro.agency_logo_url
# Set astronaut's agency logo url
astro.agency_logo_url = "https://www.nasa.gov/sites/default/files/images/nasa-logo.png"
agency_name
Retrieves and Set the astronaut's agency name.
# Get astronaut's agency name
agency_name = astro.agency_name
# Set astronaut's agency name
astro.agency_name = "National Aeronautics and Space Administration"
agency_type
Retrieves and Set the astronaut's agency type.
# Get astronaut's agency type
agency_type = astro.agency_type
# Set astronaut's agency type
astro.agency_type = "Governmental"
bio
Retrieves and Set the astronaut's bio.
# Get astronaut's bio
bio = astro.bio
# Set astronaut's bio
astro.bio = "John Smith is an astronaut with NASA. He has flown on 3 space missions."
birth_date
Retrieves and Set the astronaut's birth date.
# Get astronaut's birth date
birth_date = astro.birth_date
# Set astronaut's birth date
astro.birth_date = "1970-01-01"
death_date
Retrieves and Set the astronaut's death date.
# Get astronaut's death date
death_date = astro.death_date
# Set astronaut's death date
astro.death_date = "2050-01-01"
first_flight
Retrieves and Set the astronaut's first flight.
# Get astronaut's first flight
first_flight = astro.first_flight
# Set astronaut's first flight
astro.first_flight = "2000-01-01"
flights_count
Retrieves and Set the astronaut's flights count.
# Get astronaut's flights count
flights_count = astro.flights_count
# Set astronaut's flights count
astro.flights_count = "3"
instagram
Retrieves and Set the astronaut's Instagram page url.
# Get astronaut's Instagram page url
instagram = astro.instagram
# Set astronaut's Instagram handle
astro.instagram = "https://www.instagram.com/j_smith_astro"
jsonify
Retrieves the astronaut's information in JSON format.
# Get astronaut's information in JSON format
json_data = astro.jsonify
landings_count
Retrieves and Set the astronaut's landings count.
# Get astronaut's landings count
landings_count = astro.landings_count
# Set astronaut's landings count
astro.landings_count = "2"
last_flight
Retrieves and Set the astronaut's last flight.
# Get astronaut's last flight
last_flight = astro.last_flight
# Set astronaut's last flight
astro.last_flight = "2022-01-01"
name
Retrieves and Set the astronaut's name.
# Get astronaut's name
name = astro.name
# Set astronaut's name
astro.name = "John Smith"
nationality
Retrieves and Set the astronaut's nationality.
# Get astronaut's nationality
nationality = astro.nationality
# Set astronaut's nationality
astro.nationality = "USA"
profile_image
Retrieves and Set the astronaut's profile image url.
# Get astronaut's profile image url
profile_image = astro.profile_image
# Set astronaut's profile image url
astro.profile_image = "https://www.example.com/images/j_smith_astro.jpg"
profile_image_thumbnail
Retrieves and Set the astronaut's profile image thumbnail url.
# Get astronaut's profile image thumbnail url
profile_image_thumbnail = astro.profile_image_thumbnail
# Set astronaut's profile image thumbnail url
astro.profile_image_thumbnail = "https://www.example.com/images/j_smith_astro_thumbnail.jpg"
show_basic_info
Retrieves the astronaut's basic information.
# Get astronaut's basic information
basic_info = astro.show_basic_info
status_name
Retrieves and Set the astronaut's status name.
# Get astronaut's status name
status_name = astro.status_name
# Set astronaut's status name
astro.status_name = "Active"
twitter
Retrieves and Set the astronaut's twitter url.
# Get astronaut's twitter url
twitter = astro.twitter
# Set astronaut's twitter handle
astro.twitter = "https://twitter.com/j_smith_astro"
type_name
Retrieves and Set the astronaut's type name.
# Get astronaut's type name
type_name = astro.type_name
# Set astronaut's type name
astro.type_name = "Government"
wiki
Retrieves and Set the astronaut's wiki page url.
# Get astronaut's wiki page url
wiki = astro.wiki
# Set astronaut's wiki page url
astro.wiki = "https://en.wikipedia.org/wiki/John_Smith_(astronaut)"
Usage and methods for Launcher Objects
Initialize Launcher Object
- From Database:
# Initialize the SpaceAPI client
api = SpaceApi()
# Find astronaut by name
launcher = api.find_launcher_by('full_name', 'Atlas V')
- Manually
from space_py import Launcher
launcher = 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 methods
jsonifyandshow_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 Objects
Initialize Launch Object
- From Database:
# Initialize the SpaceAPI client
api = SpaceApi()
# Find astronaut by name
launch = api.find_launch_by('name', 'Atlas V')
- Manually
from space_py import Launch
launch = 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 methods
jsonifyandshow_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 SpaceApi
- Instead of Initializing manually Astronaut, Launch or Launcher Objects, we can use SpaceApi
populatemethods.
from space_py import SpaceApi
api = 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 methods
default_url: Returns the default API URL.
from space_py import SpaceApi
api = SpaceApi()
default_url = api.default_url
url: Returns the current API URL and can permit you to change it.
from space_py import SpaceApi
api = SpaceApi()
print(api.url)
# https://current-api-url.com
new_url = 'https://new-api-url.com'
api.url = new_url
print(api.url)
# https://new-api-url.com
Add methods
add_astro(astro: Astronaut): Adds a new astronaut to the API. Theastroparameter should be an Astronaut object containing the astronaut's information.
from space_py import SpaceApi, Astronaut
api = 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.
from space_py import SpaceApi, Launch
api = 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.
from space_py import SpaceApi, Launcher
api = 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 methods
delete_astro_by(field: str, value: str): Deletes an astronaut from the API based on the specified field and value.
from space_py import SpaceApi
api = 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.
from space_py import SpaceApi
api = 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.
from space_py import SpaceApi
api = SpaceApi()
api.delete_launcher_by('full_name', 'Atlas V')
Find methods
Used to find an entry with exact match
find_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'
from space_py import SpaceApi
api = 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'
from space_py import SpaceApi
api = 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'
from space_py import SpaceApi
api = SpaceApi()
launcher = api.find_launcher_by('full_name', 'Atlas V')
Search methods
Used to search for and entry that contains value in the field
search_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'}
from space_py import SpaceApi
api = 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'}
from space_py import SpaceApi
api = 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'}
from space_py import SpaceApi
api = SpaceApi()
launcher = api.search_launcher_by('full_name', 'Atlas V')
Update methods
Used to overwrite an entry that exactly mach value in field
update_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.
from space_py import SpaceApi, Astronaut
api = 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.
from space_py import SpaceApi, Launch
api = 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.
from space_py import SpaceApi, Launcher
api = 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)
Contributing
If you would like to contribute to the development of SpaceApi, please feel free to submit a pull request.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file rocket-space-stuff-0.0.9.tar.gz.
File metadata
- Download URL: rocket-space-stuff-0.0.9.tar.gz
- Upload date:
- Size: 11.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a33c2d7d3d779ef56f1e3c278274893f45a996c05a060680de74dc616656b2aa
|
|
| MD5 |
f802b7bd59196ee9f13bfb4a8e25fd3c
|
|
| BLAKE2b-256 |
745ded85fa718117f0b981364e58e180235ade97cd39528c9fe4030ee1351a2e
|
File details
Details for the file rocket_space_stuff-0.0.9-py3-none-any.whl.
File metadata
- Download URL: rocket_space_stuff-0.0.9-py3-none-any.whl
- Upload date:
- Size: 10.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
949612822ec326ed79c0de960be824b6007b8e614817c731edb2e0f7ff9ea486
|
|
| MD5 |
be888cdc081ddde0ffd2c52341fa564d
|
|
| BLAKE2b-256 |
0bc36f1a841a0b56d2a31f7570d1397ca5806f7a83d42007e95f3f4de5ef1638
|