NASA Astronomy Picture of the Day

NASA Astronomy Picture of the Day

This sample application displays data from the NASA Astronomy Picture of the Day API. The sample application runs under PHP 8.1.

Details of this API and other open API’s provided by NASA can be found here: https://api.nasa.gov/

The API returns the following fields:

Field NameDescription
resourceA dictionary describing the image_set or planet that the response illustrates, completely determined by the structured endpoint.
concept_tagsA boolean reflection of the supplied option. Included in response because of default values.
titleThe title of the image.
dateDate of image. Included in response because of default values.
urlThe URL of the APOD image or video of the day.
hdurlThe URL for any high-resolution image for that day. Returned regardless of ‘hd’ param setting but will be omitted in the response IF it does not exist originally at APOD.
media_typeThe type of media (data) returned. May either be ‘image’ or ‘video’ depending on content.
explanationThe supplied text explanation of the image.
conceptsThe most relevant concepts within the text explanation. Only supplied if concept_tags is set to True.
thumbnail_urlThe URL of thumbnail of the video.
copyrightThe name of the copyright holder.
service_versionThe service version used.

To fetch the data from the API the application uses a PHP cURL function call, the code for which can be seen below.

Run Code

Click the Run Example button to try out this code example.

Documentation

Click the Webhelp button to view the application help documentation.