Troubleshooting
Solutions to common issues when using the Mars Vista API.
Empty or Missing Data
Problem: relationships object is empty
"relationships": {}Cause: Missing include parameter.
Solution: Add include=rover,camera to your request:
curl "...?include=rover,camera"Problem: img_src is empty
"img_src": ""Cause: The img_src field is deprecated.
Solution: Use the images object instead:
// Old (deprecated)
photo.img_src
// New (correct)
photo.attributes.images.medium // or small, large, fullProblem: Query returns no photos
Possible causes:
- Filters are too restrictive
- Invalid rover or camera name
- Date range has no photos
- Sol doesn't exist for that rover
Solution: Start with a broad query and add filters one at a time:
# Start broad
curl "...?rovers=curiosity&per_page=5"
# Add filters one by one
curl "...?rovers=curiosity&sol_min=1000&sol_max=1000&per_page=5"
curl "...?rovers=curiosity&sol_min=1000&sol_max=1000&cameras=NAVCAM&per_page=5"Authentication Issues
Problem: 401 Unauthorized
Possible causes:
- API key is missing from request
- API key is in the wrong header
- API key has been regenerated (old key is invalid)
- API key is malformed or truncated
Checklist:
- Header name is exactly
X-API-Key(case-sensitive) - Key starts with
mv_live_ - Key is 47 characters total
- No extra spaces or quotes around the key
Problem: 429 Too Many Requests
Solutions:
- Check the
retryAfterfield and wait that many seconds - Implement exponential backoff
- Use larger page sizes (per_page=100) to reduce total requests
- Cache responses locally
- Use ETags to avoid counting 304 responses
See Rate Limits Guide for optimization tips.
Data Issues
Issue: Photos seem out of order
Cause: Default sort is most recent first: date_taken_utc descending (single-rover queries apply it as sol descending, then date_taken_utc descending). Photos with identical capture times may appear in any order.
Solution: Add an explicit sort ending in a unique field:
# Newest first, deterministic even for identical capture times
curl "...?sort=-date_taken_utc,-id"Issue: Can't find recent photos
Cause:There's typically a 1-2 day delay between when NASA receives photos and when they appear in the API.
Note: Photos are scraped daily at 2 AM UTC. The most recent photos will be from 1-2 days ago.
Issue: Different rovers have different cameras
Cause: Each rover has unique instruments. Camera names differ between rovers.
Solution: Check the Cameras Referencefor each rover's available cameras.
Integration Issues
Problem: CORS errors in browser
Cause: API keys should never be exposed in client-side JavaScript.
Solution: Make API calls from your backend server, not the browser:
// DON'T: Client-side JavaScript
// This exposes your API key!
fetch('https://api.marsvista.dev/...', {
headers: { 'X-API-Key': 'mv_live_xxx' }
});
// DO: Server-side (Next.js API route, Express, etc.)
// app/api/photos/route.ts
export async function GET(request) {
const response = await fetch('https://api.marsvista.dev/...', {
headers: { 'X-API-Key': process.env.MARS_VISTA_API_KEY }
});
return Response.json(await response.json());
}Issue: Slow response times
Possible causes:
- Query is too broad (scanning many records)
- Requesting all fields when you only need a few
- Not using caching
Solutions:
- Add specific filters (rover, date range, camera)
- Use
field_set=minimalfor faster responses - Cache rover/camera data (they rarely change)
- Use ETags for conditional requests
Still Need Help?
- Check the Error Reference for detailed error explanations
- Browse the Swagger UI to test requests interactively
- Report issues on GitHub Issues