This documentation provides developers with a comprehensive guide to retrieving Mars Rover images using NASA's public API. The guide covers essential endpoints, parameters, and examples to help developers access and utilize the API efficiently.
- Markdown
- JSON
- GitHub
- Obtain an API key from NASA's API portal by signing up here.
- Place the API key in the
Authorizationheader of your requests.
-
Method: GET
-
Endpoint URL:
/rovers/{rover}/photos -
Description: Fetches photos taken by a specific rover on Mars on a given Martian solar day (sol).
-
Parameters:
rover(string): Name of the rover (e.g.,Curiosity,Opportunity,Spirit).sol(integer): The Martian solar day on which the photos were taken.camera(optional, string): Specific camera used (e.g.,FHAZfor Front Hazard Avoidance Camera).
-
Example Request:
GET https://api.nasa.gov/mars-photos/api/v1/rovers/curiosity/photos?sol=1000&api_key=DEMO_KEY
To retrieve photos taken by the Curiosity rover on Martian sol 1000, make a GET request to the /rovers/curiosity/photos endpoint with your API key. The response will include image URLs, camera details, and additional metadata about the photos taken on that day.

Diagram illustrating the interaction between the User Application and NASA API Server.
Below is an example JSON response you can expect from the API:
{
"photos": [
{
"id": 102693,
"sol": 1000,
"camera": {
"name": "FHAZ",
"full_name": "Front Hazard Avoidance Camera"
},
"img_src": "http://mars.nasa.gov/msl-raw-images/proj/msl/redops/ods/surface/sol/01000/opgs/edr/fcam/FLB_486456045EDR_F0481570FHAZ00323M_.JPG",
"earth_date": "2015-05-30",
"rover": {
"name": "Curiosity",
"landing_date": "2012-08-06",
"status": "active"
}
}
]
}-
Q: How can I get an API key?
A: Sign up for a free API key on NASA's API portal. -
Q: What is a Martian sol?
A: A sol is a Martian solar day, approximately 24 hours and 39 minutes, used as a time unit for operations on Mars.
-
Authentication Errors: If you encounter authentication issues, verify that your API key is correctly included in the
Authorizationheader of your requests. -
Empty Responses: If no photos are returned, check that you’ve used the correct
rovername and a validsolparameter. Note that not all Martian days have photos available, so try different sol values if needed.
