One of the most popular websites at NASA is the Astronomy Picture of the Day (APOD). In fact, this website is one of the most popular websites across all federal agencies! Each day, a different image or photograph of our fascinating universe is featured, along with a brief explanation written by a professional astronomer.
Given the popularity of APOD, many developers want to integrate its images and descriptions into their websites or mobile applications. In order to aid these efforts, the APOD API was developed. It provides an HTTP interface where developers specify a date, and then receive information for that date’s APOD as a JSON object.
Want to see it in action? Visit: https://api.nasa.gov/planetary/apod?api_key=DEMO_KEY&date=2017-07-12
It may not look so impressive compared to the actual APOD website, but that format is much easier for computer programs to use.
Two new updates to the API will allow for greater flexibility in the types of requests that developers can make. The API limits the number of requests that each developer can make--in order to prevent spam--which created a problem for developers who wanted to access more than one APOD, since the requests needed to be done individually.
To allow developers to retrieve multiple images in a single call, three new optional parameters have been created: start_date, end_date, and count. The start_date and end_date parameters are used in conjunction to make a request for a given date range that then returns all images between the start date and end date. If an end_date is not specified, then the API defaults to the date on which the request is made.
The count parameter must be a positive integer that is less than or equal to 100, and specifying it will return an array of count randomly selected images between the first day an APOD picture was posted--June 16, 1995--and today.
The APOD API source code has been made available under the Apache License, Version 2.0 and is located at the official NASA APOD GitHub Repository. You can report any issues there, and pull requests are always welcome!