The Mars Nexus Wrapper is a Python library that interfaces with multiple NASA APIs to fetch data related to Mars. The library provides functions for retrieving Mars weather data, orbital data, images from Mars rovers, and other Mars-related information.
This wrapper is designed to interact with the following NASA endpoints:
- Mars rover photos
- Mars weather data (InSight)
- Mars orbital data (Astronomical data)
-
Clone this repository:
git clone https://github.com/yourusername/mars-nexus-wrapper.git cd mars-nexus-wrapper
-
Create and activate a virtual environment:
python3 -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
-
Install the required dependencies:
pip install -r requirements.txt
-
Set up the
.env
file with your NASA API key. Create a.env
file in the root of the project and add:NASA_API_KEY=your_nasa_api_key
You can obtain the API key from NASA's official website.
Once you have installed the package and set up your API key, you can use the wrapper to fetch Mars-related data. Below is an example of how to use the functions from the wrapper:
from Mars_Wrapper.weather import get_latest_weather
from Mars_Wrapper.orbital import get_orbital_data
from Mars_Wrapper.imaging import get_latest_images
# Fetch latest Mars weather data
weather = get_latest_weather()
print(weather)
# Fetch Mars orbital data
orbital_data = get_orbital_data()
print(orbital_data)
# Fetch latest Mars rover images
images = get_latest_images(sol=1000, camera="FHAZ")
print(images)
mars-nexus-wrapper/
│
├── .env # Contains environment variables (e.g., API keys)
├── Mars_Wrapper/ # Contains the main wrapper code
│ ├── imaging.py # Handles Mars rover images
│ ├── orbital.py # Handles Mars orbital data
│ ├── utils.py # Utility functions and API response handling
│ ├── weather.py # Handles Mars weather data
│
├── Tests/ # Contains unit tests
│ ├── tests_utils.py # Tests for utils.py
│ ├── tests_weather.py # Tests for weather.py
│ ├── tests_imaging.py # Tests for imaging.py
│ ├── tests_orbital.py # Tests for orbital.py
│
├── main.py # Example entry point for fetching Mars data
├── requirements.txt # List of dependencies
└── README.md # This file
This project uses pytest
for testing.
To run the tests:
-
Install test dependencies:
pip install -r requirements.txt
-
Run the tests using
pytest
:pytest
- tests_utils.py: Tests for utility functions (
handle_api_response
) - tests_weather.py: Tests for weather data functions
- tests_imaging.py: Tests for Mars rover imaging functions
- tests_orbital.py: Tests for Mars orbital data functions
- NASA for providing public APIs for Mars-related data.