corincerami / mars-photo-api

A Rails API for photo data from NASA's Mars Rovers
https://api.nasa.gov/#MarsPhotos
GNU General Public License v3.0
363 stars 50 forks source link

Allow sol to default to most recent sol with photos? #67

Closed alxmjo closed 6 years ago

alxmjo commented 7 years ago

I'd like to query the API and pull the most recent 10 or so photos from each rover. I've noticed that there's no default for sol or earth_date, so requests without this parameter return empty. It seems that photos aren't added often enough to just query with today's date.

Obviously I can keep querying the API until I get back a non-empty photos object, but this seems overly hacky.

Is there a better way? Or can I submit this as an idea?

corincerami commented 7 years ago

The API should be adding new photos within a day of when they are released by NASA. I think you may have raised to my attention that this isn't happening. That being said, you can also find the most recent sol and earth_date for each Rover by checking the Rover's endpoint. For example, /api/v1/rovers/curiosity right now contains the data:

"max_sol": 1849,
"max_date": "2017-10-18",

Hope that helps, and I'll try to figure out why the latest images aren't appearing when I have a chance.

alxmjo commented 7 years ago

That's very helpful, thank you.

I suppose the best way to move forward then would be to query the API for a sol at which I know photos exist (since the object you mention above doesn't appear to be appended when the sol parameter is not passed), get the max_sol from that query, and then query again based on that value.

It still makes sense to me that querying without sol would return the most recent photo(s), but I'm sure you've thought about this more than I have.

alxmjo commented 7 years ago

I wonder if I'm seeing some other unexpected behavior here. Based on the manifest (https://api.nasa.gov/mars-photos/api/v1/manifests/Curiosity?api_key=apikeygoeshere) there should be photos from the NAVCAM on Curiosity on sol 400. But querying https://api.nasa.gov/mars-photos/api/v1/rovers/curiosity/photos?api_key=apikeygoeshere&camera=NAVCAM&sol=400&page=1 returns an empty array.

Am I doing something wrong here?

corincerami commented 6 years ago

I'll take a look at the Manifest and see if either it or the photos endpoint is incorrect.

corincerami commented 6 years ago

Ah, I've found the bug. It's an issue with the database confusing Curiosity's NAVCAM with the NAVCAM on Opportunity and Spirit. I should be able to fix it relatively quickly.

corincerami commented 6 years ago

Ok, I think I've correct the issue. Let me know if you're still seeing any problems.