NASA API

Has any one worked with the NASA API website and/to develop a program to download information from the site, specifically pictures. I have been working to develop a program using the API for the Mars Rover for longer then I care to admit. I am able to get to the website and get a response/confirmation, but never able to receive any photo information.

If someone has been successful with this or any of the NASA APIs (other than APOD, the first one on the site) I would appreciate any assistance you might be willing to share. I would like to see some of your program if you would not mind sharing it to understand where I might be going wrong.

FYI this is all for my personal use and knowledge.

NASA has many web sites. You'll have to specify exactly which site you are talking about, ideally with the URL. Any individual mission can have many different data providers.

Unfortunately, without knowing more information about what you are trying to do, there isn't much more I can tell you. I think you may have touched on the problem with the reference to APOD.

Generally speaking, NASA (and any similar/connected organization) is going to have two sides. One side is dedicated to regular folks on the internet, schoolchildren, etc. That's the APOD the side. The other side is meant for professionals and researchers. This is the real data. It may be in some unusual and very difficult-to-use formats. There may be some unusual access practices. For example, when you download data, you might have to wait for some robot to go fetch the data from tape and load it on disk. Or you might have to just put in a request and wait, perhaps days.

Plus, because NASA et al. are such huge organizations, there is no commonality between data sources. Different access points can have wildly different practices. Some may be old-school tape systems. Some may have migrated to AWS or similar. No way to tell without a URL.

Thank you for the reply. I guess I have been working with this NASA site and it has become second nature to just say NASA API.
This is the URL https://api.nasa.gov/ in particular: Mars Rover Photos - There are multiple URLs attached to this sub site. Per site description: "This API is designed to collect image data gathered by NASA's Curiosity, Opportunity, and Spirit rovers on Mars and make it more easily available to other developers, educators, and citizen scientists. This API is maintained by Chris Cerami.

Each rover has its own set of photos stored in the database, which can be queried separately. There are several possible queries that can be made against the API. Photos are organized by the sol (Martian rotation or day) on which they were taken, counting up from the rover's landing date. A photo taken on Curiosity's 1000th Martian sol exploring Mars, for example, will have a sol attribute of 1000. If instead you prefer to search by the Earth date on which a photo was taken, you can do that, too.

https://api.nasa.gov/mars-photos/api/v1/rovers/curiosity/photos?sol=1000&api_key=DEMO_KEY:

https://api.nasa.gov/mars-photos/api/v1/rovers/curiosity/photos?sol=1000&camera=fhaz&api_key=DEMO_KEY

https://api.nasa.gov/mars-photos/api/v1/rovers/curiosity/photos?sol=1000&page=2&api_key=DEMO_KEY

As to what I am attempting: to build an app that will download some of the Photos from the various rovers that are on Mars and their different cameras.

I have done a similar app with the APOD site (on the same NASA API / URL location which displays the "Photo of the Day" and a brief description of the photo.

Hopefully, this provide some of the information I left out in my first post - what the Site, URL, and what I am attempting.

First of all, be careful with any code you download. This particular "API" looks a little suspicious. The GitHub project for the API says it is GPL licensed. That means NASA can run it on NASA's servers, but you better not even look at the source code. Use only those REST endpoint URLs and try to reverse-engineer them as best you can.

If you are doing this strictly for your own personal knowledge, then you can do whatever you want, as long as it is within the terms of whatever license or terms of use apply. Years ago, by law, any official, published US government products had to be public domain, giving everyone unrestricted use. I don't know if that is still true. The source for that API is GPL, and the NASA API web site itself has a Google Terms of Use. If you ever want to develop a real app, be very, very careful with licensing, both in terms of the content itself (the photos), and the API (terms of use).

All that being said, everything works as expected. I'm not familiar with the structure of the results. It concerns me a "page=2" query works because I can't find the total number of pages. And the query without pagination works, but returns different content. But I've only looked at it for a couple of minutes.

The direct imagery URLs seem to work. The one I tried returned a 301 result. You'll have to inspect the HTTP headers to find the target URL. When using a higher-level API on a device, or just somewhere on the client side, you'll want to handle this kind of result. A REST server like this, especially one from NASA, may employ more unusual HTTP response codes than you may have seen elsewhere.

Those direct URLs come from a different server. You don't need to add your API key and probably shouldn't try.

Does anyone else in the forum community have any other information on this topic that they would be willing to share.

Specially, how (code - that will only be used for my personal use) you were able to get Photos to download from the NASA website I reference in my post.

Thanks to anyone who might be will to assist me.

Does anyone else in the forum community have any other information on this topic that they would be willing to share.

I'm afraid the community is pretty small. If Apple support engineers don't take an interest in your question, which they probably wouldn't in this case, there are only a handful (as in 3 or 4) of other people who ever answer questions here.

Specially, how (code - that will only be used for my personal use) you were able to get Photos to download from the NASA website I reference in my post.

Photos is an end-user, consumer app. If you have questions about those kinds of apps, it would be better to ask on the Apple Support community, which is more focused on end users. This forum is intended for code-level developer support for developers on Apple platforms. That's why I'm guessing that Apple engineers wouldn't respond to a question about NASA APIs.

In my case, I just downloaded those images using the command-line "curl" app.

You haven't said anything about the actual code you are writing, so nobody knows what would be appropriate in your case.

Generally speaking, this isn't something that Photos would be support. You might be able to build an Automator script or a Shortcut to download images. I know nothing about those tools. That's definitely a question for the Apple Support community. If I wanted to script something like this, I would do it in Perl. That's what I used when I wrote these kinds of APIs for NASA. 😄

NASA API
 
 
Q