Astronomy Picture of the Day (APOD) microservice
A microservice written in Python with the Flask micro framework.
NOTES:
Final update 9-10-2026!
The backend has been rewired to point to the new Wordpress Endpoint
This API will pass your call to the new endpoint and return the result.
This readme has been updated with the new return values and their meaning.
This repo will be archived and will be pointed to the new end point on December 1, 2026.
You should not need to update your code or projects at this time.
Full documentation can be found here.
Code “refresh” has occured 1-21-2026!
Code was refreshed to use uv for dependency management. Dockerfile and docker-compose.yml were updated to support containerized deployment. All open issues and PRs will closed to start fresh. Please open new issues or PRs as needed. We are still in the process of updating the hosting of this API so there may be some downtime till we can get the API moved into the new system. An update will be posted here when that is complete.
API Reliability
A very large number of people use the instance of this API that NASA has set up. If you need a extremely reliable version of this API, you likely want to stand up your own version of the API. You can do that with this code! All information that this API returns is actually just grabbed from the Astronomy Photo of the Day Website (APOD).
Content Related Issues
No one watching this repository has anything to do with Astronomy Photo of the Day website, so we’re unable to deal with issues directly related to their content. Please contact them directly.
Table of contents
- Getting Started
- Standard environment
- Docker environment
- Running Tests
- Docs
- APOD parser
- Deployed
- Feedback
- Author
Getting started
Standard environment
- Clone the repo
git clone https://github.com/nasa/apod-api
cd into the new directory
cd apod-api
- Install dependencies
uv sync
- Run the application
uv run python application.py
Run it in Docker
- Clone the repo
git clone https://github.com/nasa/apod-api.git
cd into the new directory
cd apod-api
- Build and run the image
docker compose up --build
Running Tests
- Make sure you have followed the steps in the Standard environment section above.
- Run the tests with
pytest
uv run pytest
Docs
Endpoint: /<version>/apod
There is only one endpoint in this service which takes 2 optional fields
as parameters to a http GET request. A JSON dictionary is returned nominally.
URL Search Params | query string parameters
api_key | demo: DEMO_KEY | https://api.nasa.gov/#signUp
date A string in YYYY-MM-DD format indicating the date of the APOD image (example: 2014-11-03). Defaults to today’s date. Must be after 1995-06-16, the first day an APOD picture was posted. There are no images for tomorrow available through this API.
count A positive integer, no greater than 25. If this is specified then count randomly chosen images will be returned in a JSON array. Cannot be used in conjunction with date or start_date and end_date.
start_date A string in YYYY-MM-DD format indicating the start of a date range. All images in the range from start_date to end_date will be returned in a JSON array. Cannot be used with date.
end_date A string in YYYY-MM-DD format indicating that end of a date range. If start_date is specified without an end_date then end_date defaults to the current date.
Returned fields
date APOD date in YYYY-MM-DD format.
post_id WordPress post ID.
title APOD post title.
permalink URL of the APOD post on the site.
media_type Normalized APOD media type, such as image, video, or iframe.
explanation APOD explanation text.
url APOD post URL. This matches the permalink.
hdurl Full-size featured image URL when available.
basic_html APOD Basic HTML document as a JSON string.
basic_html_url Plain-text HTML source URL for easier copy/paste workflows.
Example
localhost:5000/v1/apod?date=2014-10-01
See Return Object
{
"alt": "See Explanation. Clicking on the picture will download the highest resolution version available.",
"basic_html": "\u003C!doctype html\u003E\n\u003Chtml\u003E\n\u003Chead\u003E\n\u003Cmeta charset=\"UTF-8\"\u003E\n\u003Cmeta name=\"viewport\" content=\"width=device-width, initial-scale=1\"\u003E\n\u003Ctitle\u003E APOD: 2014 October 1 - The Butterfly Nebula from Hubble\u003C/title\u003E\n\u003Clink rel=\"canonical\" href=\"https://science.nasa.gov/image-article/apod-2014-october-1-the-butterfly-nebula-from-hubble/\"\u003E\n\u003C!-- gsfc meta tags --\u003E\n\u003Cmeta name=\"orgcode\" content=\"661\"\u003E\n\u003Cmeta name=\"rno\" content=\"Diana Logreira\"\u003E\n\u003Cmeta name=\"content-owner\" content=\"Robert Nemiroff, Jerry Bonnell\"\u003E\n\u003Cmeta name=\"webmaster\" content=\"Stephen.F.Fantasia.1\"\u003E\n\u003Cmeta name=\"description\" content=\"Explanation: The bright clusters and nebulae of planet Earth's night sky are often named for flowers or insects . Though its wingspan covers over 3 light-years, NGC 6302 is no exception. With an estimated surface temperature of about 250,000 degrees C, the dying central star of this particular planetary nebula has become exceptionally hot, shining brightly in ultraviolet light but hidden from direct view by a dense torus of dust. This sharp close-up of the dying star's nebula was recorded in 2009 by the Hubble Space Telescope's Wide Field Camera 3, and is presented here in reprocessed colors. Cutting across a bright cavity of ionized gas, the dust torus surrounding the central star is near the center of this view, almost edge-on to the line-of-sight. Molecular hydrogen has been detected in the hot star's dusty cosmic shroud. NGC 6302 lies about 4,000 light-years away in the arachnologically correct constellation of the Scorpion ( Scorpius ). APOD Wall Calendar: Nebulas and Star Clusters\"\u003E\n\u003C!-- --\u003E\n\u003Cmeta name=\"keywords\" content=\"the butterfly nebula from hubble\"\u003E\n\u003Cmeta property=\"og:type\" content=\"article\"\u003E\n\u003Cmeta property=\"og:title\" content=\"The Butterfly Nebula from Hubble\"\u003E\n\u003Cmeta property=\"og:url\" content=\"https://science.nasa.gov/image-article/apod-2014-october-1-the-butterfly-nebula-from-hubble/\"\u003E\n\u003Cmeta property=\"og:site_name\" content=\"NASA Science\"\u003E\n\u003Cmeta property=\"og:image\" content=\"https://assets.science.nasa.gov/content/dam/science/cds/apod/apod/2014/october/butterflyblue_hst_3919.jpg?w=3919&h=3745&fit=clip&crop=faces%2Cfocalpoint\"\u003E\n\u003Cmeta property=\"og:image:secure_url\" content=\"https://assets.science.nasa.gov/content/dam/science/cds/apod/apod/2014/october/butterflyblue_hst_3919.jpg?w=3919&h=3745&fit=clip&crop=faces%2Cfocalpoint\"\u003E\n\u003Cmeta property=\"og:image:alt\" content=\"See Explanation. Clicking on the picture will download the highest resolution version available.\"\u003E\n\u003Cmeta property=\"article:published_time\" content=\"2014-10-01T00:00:00-04:00\"\u003E\n\u003Cmeta property=\"article:modified_time\" content=\"2026-07-29T13:42:51-04:00\"\u003E\n\u003Cmeta name=\"twitter:card\" content=\"summary_large_image\"\u003E\n\u003Cmeta name=\"twitter:title\" content=\"The Butterfly Nebula from Hubble\"\u003E\n\u003Cmeta name=\"twitter:site\" content=\"@NASA\"\u003E\n\u003Cmeta name=\"twitter:creator\" content=\"@NASA\"\u003E\n\u003Cmeta name=\"twitter:image\" content=\"https://assets.science.nasa.gov/content/dam/science/cds/apod/apod/2014/october/butterflyblue_hst_3919.jpg?w=3919&h=3745&fit=clip&crop=faces%2Cfocalpoint\"\u003E\n\u003C/head\u003E\n\u003Cbody BGCOLOR=\"#F4F4FF\" text=\"#000000\" link=\"#0000FF\" vlink=\"#7F0F9F\"\nalink=\"#FF0000\"\u003E\n\n\u003Ccenter\u003E\n\u003Ch1\u003E Astronomy Picture of the Day \u003C/h1\u003E\n\u003Cp\u003E\n\n\u003Ca href=\"https://science.nasa.gov/apod/archive/\"\u003EDiscover the cosmos!\u003C/a\u003E\nEach day a different image or photograph of our fascinating universe is\nfeatured, along with a brief explanation written by a professional astronomer.\n\u003Cp\u003E\n\n2014 October 1\u003Cbr\u003E\n\n\u003Ca href=\"https://assets.science.nasa.gov/content/dam/science/cds/apod/apod/2014/october/butterflyblue_hst_3919.jpg\"\u003E\n\u003CIMG SRC=\"https://assets.science.nasa.gov/content/dam/science/cds/apod/apod/2014/october/butterflyblue_hst_3919.jpg\" alt=\"See Explanation. Clicking on the picture will download the highest resolution version available.\"\u003E\u003C/a\u003E\n\u003C/center\u003E\n\n\u003Ccenter\u003E\n\u003Cb\u003E The Butterfly Nebula from Hubble \u003C/b\u003E \u003Cbr\u003E\n\n\u003Cb\u003EImage Credit &\n\u003Ca href=\"https://science.nasa.gov/apod/about-apod/\"\u003ECopyright\u003C/a\u003E:\u003C/b\u003E\n\n\u003Cb\u003E Image Credit: \u003C/b\u003E \u003Ca href=\"http://www.nasa.gov/\" target=\"_blank\"\u003ENASA\u003C/a\u003E , \u003Ca href=\"http://www.spacetelescope.org/\" target
提示:代码过长已自动截断
https://api.nasa.gov/planetary/apod?api_key=DEMO_KEY&count=2
See Return Object
[
{
"alt": "See Explanation. Clicking on the picture will download the highest resolution version available.",
"basic_html": "\u003C!doctype html\u003E\n\u003Chtml\u003E\n\u003Chead\u003E\n\u003Cmeta charset=\"UTF-8\"\u003E\n\u003Cmeta name=\"viewport\" content=\"width=device-width, initial-scale=1\"\u003E\n\u003Ctitle\u003E APOD: 2014 March 4 - Sun and Prominence\u003C/title\u003E\n\u003Clink rel=\"canonical\" href=\"https://science.nasa.gov/image-article/apod-2014-march-4-sun-and-prominence/\"\u003E\n\u003C!-- gsfc meta tags --\u003E\n\u003Cmeta name=\"orgcode\" content=\"661\"\u003E\n\u003Cmeta name=\"rno\" content=\"Diana Logreira\"\u003E\n\u003Cmeta name=\"content-owner\" content=\"Robert Nemiroff, Jerry Bonnell\"\u003E\n\u003Cmeta name=\"webmaster\" content=\"Stephen.F.Fantasia.1\"\u003E\n\u003Cmeta name=\"description\" content=\"Explanation: Dramatic prominences can sometimes be seen looming just beyond the edge of the sun. Such was the case last week as a large prominence, visible above , highlighted a highly active recent Sun. A waving sea of hot gas is visible in the foreground chromosphere in great detail as it was imaged in one specific color of light emitted by hydrogen. A solar prominence is a cloud of solar gas held just above the surface by the Sun's magnetic field . The Earth , illustrated in the inset, is smaller than the prominence . Although very hot, prominences typically appear dark when viewed against the Sun , since they are slightly cooler than the photosphere below them. A quiescent prominence typically lasts about a month, and may erupt in a Coronal Mass Ejection (CME) expelling hot gas into the Solar System , some of which may strike the Earth and trigger auroras .\"\u003E\n\u003C!-- --\u003E\n\u003Cmeta name=\"keywords\" content=\"sun and prominence\"\u003E\n\u003Cmeta property=\"og:type\" content=\"article\"\u003E\n\u003Cmeta property=\"og:title\" content=\"Sun and Prominence\"\u003E\n\u003Cmeta property=\"og:url\" content=\"https://science.nasa.gov/image-article/apod-2014-march-4-sun-and-prominence/\"\u003E\n\u003Cmeta property=\"og:site_name\" content=\"NASA Science\"\u003E\n\u003Cmeta property=\"og:image\" content=\"https://assets.science.nasa.gov/content/dam/science/cds/apod/apod/2014/march/SunWave_brahic_1311.jpg?w=1311&h=1037&fit=clip&crop=faces%2Cfocalpoint\"\u003E\n\u003Cmeta property=\"og:image:secure_url\" content=\"https://assets.science.nasa.gov/content/dam/science/cds/apod/apod/2014/march/SunWave_brahic_1311.jpg?w=1311&h=1037&fit=clip&crop=faces%2Cfocalpoint\"\u003E\n\u003Cmeta property=\"og:image:alt\" content=\"See Explanation. Clicking on the picture will download the highest resolution version available.\"\u003E\n\u003Cmeta property=\"article:published_time\" content=\"2014-03-04T00:00:00-05:00\"\u003E\n\u003Cmeta property=\"article:modified_time\" content=\"2026-07-29T14:03:44-04:00\"\u003E\n\u003Cmeta name=\"twitter:card\" content=\"summary_large_image\"\u003E\n\u003Cmeta name=\"twitter:title\" content=\"Sun and Prominence\"\u003E\n\u003Cmeta name=\"twitter:site\" content=\"@NASA\"\u003E\n\u003Cmeta name=\"twitter:creator\" content=\"@NASA\"\u003E\n\u003Cmeta name=\"twitter:image\" content=\"https://assets.science.nasa.gov/content/dam/science/cds/apod/apod/2014/march/SunWave_brahic_1311.jpg?w=1311&h=1037&fit=clip&crop=faces%2Cfocalpoint\"\u003E\n\u003C/head\u003E\n\u003Cbody BGCOLOR=\"#F4F4FF\" text=\"#000000\" link=\"#0000FF\" vlink=\"#7F0F9F\"\nalink=\"#FF0000\"\u003E\n\n\u003Ccenter\u003E\n\u003Ch1\u003E Astronomy Picture of the Day \u003C/h1\u003E\n\u003Cp\u003E\n\n\u003Ca href=\"https://science.nasa.gov/apod/archive/\"\u003EDiscover the cosmos!\u003C/a\u003E\nEach day a different image or photograph of our fascinating universe is\nfeatured, along with a brief explanation written by a professional astronomer.\n\u003Cp\u003E\n\n2014 March 4\u003Cbr\u003E\n\n\u003Ca href=\"https://assets.science.nasa.gov/content/dam/science/cds/apod/apod/2014/march/SunWave_brahic_1311.jpg\"\u003E\n\u003CIMG SRC=\"https://assets.science.nasa.gov/content/dam/science/cds/apod/apod/2014/march/SunWave_brahic_1311.jpg\" alt=\"See Explanation. Clicking on the picture will download the highest resolution version available.\"\u003E\u003C/a\u003E\n\u003C/center\u003E\n\n\u003Ccenter\u003E\n\u003Cb\u003E Sun and Prominence \u003C/b\u003E \u003Cbr\u003E\n\n\u003Cb\u003EImage Credit &\n\u003Ca href=\"https://science.nasa.gov/apod/about-apod/\"\u003ECopyright\u003C/a\u003E:\u003C/b\u003E\n\n\u003Cb\u003E Image Credit & Copyright: \u003C/b\u003E \u003Ca href=\"mailto:jp-brahic at infonie.fr\"\u003Ejp-Brahic\u003C/a\u003E\n\u003C/center\u003E\n\n\u003Cp\u003E\n\n\u003Cb\u003E Explanation: \u003C/b\u003E\n\n\u003Cstrong\u003EExplanation:\u003C/strong\u003E Dramatic \u003Ca href=\"http://csep10.phys.utk.edu/astr162/lect/sun/prominences.html\" target=\"_blank\"\u003Eprominences\u003C/a\u003E can sometimes be seen looming just bey
提示:代码过长已自动截断
https://api.nasa.gov/planetary/apod?api_key=DEMO_KEY&start_date=2017-07-08&end_date=2017-07-10
See Return Object
[
{
"alt": "See Explanation. Clicking on the picture will download the highest resolution version available.",
"basic_html": "\u003C!doctype html\u003E\n\u003Chtml\u003E\n\u003Chead\u003E\n\u003Cmeta charset=\"UTF-8\"\u003E\n\u003Cmeta name=\"viewport\" content=\"width=device-width, initial-scale=1\"\u003E\n\u003Ctitle\u003E APOD: 2017 July 10 - Spiral Galaxy NGC 1512: The Nuclear Ring\u003C/title\u003E\n\u003Clink rel=\"canonical\" href=\"https://science.nasa.gov/image-article/apod-2017-july-10-spiral-galaxy-ngc-1512-the-nuclear-ring/\"\u003E\n\u003C!-- gsfc meta tags --\u003E\n\u003Cmeta name=\"orgcode\" content=\"661\"\u003E\n\u003Cmeta name=\"rno\" content=\"Diana Logreira\"\u003E\n\u003Cmeta name=\"content-owner\" content=\"Robert Nemiroff, Jerry Bonnell\"\u003E\n\u003Cmeta name=\"webmaster\" content=\"Stephen.F.Fantasia.1\"\u003E\n\u003Cmeta name=\"description\" content=\"Explanation: What's happening around the center of this spiral galaxy? Seen in total, NGC 1512 appears to be a barred spiral galaxy -- a type of spiral that has a straight bar of stars across its center. This bar crosses an inner ring , though, a ring not seen as it surrounds the pictured region . Featured in this Hubble Space Telescope image is a “nuclear ring” -- one that surrounds the nucleus of the spiral. The two rings are connected not only by a bar of bright stars but by dark lanes of dust. Inside of this nuclearring , dust continues to spiral right into the very center -- possibly the location of a large black hole . The rings are bright with newly formed stars .\"\u003E\n\u003C!-- --\u003E\n\u003Cmeta name=\"keywords\" content=\"spiral galaxy ngc 1512: the nuclear ring\"\u003E\n\u003Cmeta property=\"og:type\" content=\"article\"\u003E\n\u003Cmeta property=\"og:title\" content=\"Spiral Galaxy NGC 1512: The Nuclear Ring\"\u003E\n\u003Cmeta property=\"og:url\" content=\"https://science.nasa.gov/image-article/apod-2017-july-10-spiral-galaxy-ngc-1512-the-nuclear-ring/\"\u003E\n\u003Cmeta property=\"og:site_name\" content=\"NASA Science\"\u003E\n\u003Cmeta property=\"og:image\" content=\"https://assets.science.nasa.gov/content/dam/science/cds/apod/apod/2017/july/NGC1512_Schmidt_1342.jpg?w=1342&h=1005&fit=clip&crop=faces%2Cfocalpoint\"\u003E\n\u003Cmeta property=\"og:image:secure_url\" content=\"https://assets.science.nasa.gov/content/dam/science/cds/apod/apod/2017/july/NGC1512_Schmidt_1342.jpg?w=1342&h=1005&fit=clip&crop=faces%2Cfocalpoint\"\u003E\n\u003Cmeta property=\"og:image:alt\" content=\"See Explanation. Clicking on the picture will download the highest resolution version available.\"\u003E\n\u003Cmeta property=\"article:published_time\" content=\"2017-07-10T00:00:00-04:00\"\u003E\n\u003Cmeta property=\"article:modified_time\" content=\"2026-07-29T13:41:04-04:00\"\u003E\n\u003Cmeta name=\"twitter:card\" content=\"summary_large_image\"\u003E\n\u003Cmeta name=\"twitter:title\" content=\"Spiral Galaxy NGC 1512: The Nuclear Ring\"\u003E\n\u003Cmeta name=\"twitter:site\" content=\"@NASA\"\u003E\n\u003Cmeta name=\"twitter:creator\" content=\"@NASA\"\u003E\n\u003Cmeta name=\"twitter:image\" content=\"https://assets.science.nasa.gov/content/dam/science/cds/apod/apod/2017/july/NGC1512_Schmidt_1342.jpg?w=1342&h=1005&fit=clip&crop=faces%2Cfocalpoint\"\u003E\n\u003C/head\u003E\n\u003Cbody BGCOLOR=\"#F4F4FF\" text=\"#000000\" link=\"#0000FF\" vlink=\"#7F0F9F\"\nalink=\"#FF0000\"\u003E\n\n\u003Ccenter\u003E\n\u003Ch1\u003E Astronomy Picture of the Day \u003C/h1\u003E\n\u003Cp\u003E\n\n\u003Ca href=\"https://science.nasa.gov/apod/archive/\"\u003EDiscover the cosmos!\u003C/a\u003E\nEach day a different image or photograph of our fascinating universe is\nfeatured, along with a brief explanation written by a professional astronomer.\n\u003Cp\u003E\n\n2017 July 10\u003Cbr\u003E\n\n\u003Ca href=\"https://assets.science.nasa.gov/content/dam/science/cds/apod/apod/2017/july/NGC1512_Schmidt_1342.jpg\"\u003E\n\u003CIMG SRC=\"https://assets.science.nasa.gov/content/dam/science/cds/apod/apod/2017/july/NGC1512_Schmidt_1342.jpg\" alt=\"See Explanation. Clicking on the picture will download the highest resolution version available.\"\u003E\u003C/a\u003E\n\u003C/center\u003E\n\n\u003Ccenter\u003E\n\u003Cb\u003E Spiral Galaxy NGC 1512: The Nuclear Ring \u003C/b\u003E \u003Cbr\u003E\n\n\u003Cb\u003EImage Credit &\n\u003Ca href=\"https://science.nasa.gov/apod/about-apod/\"\u003ECopyright\u003C/a\u003E:\u003C/b\u003E\n\n\u003Cb\u003E Image Credit: \u003C/b\u003E \u003Ca href=\"http://www.nasa.gov/\" target=\"_blank\"\u003ENASA\u003C/a\u003E , \u003Ca href=\"http://www.esa.int/\" target=\"_blank\"\u003EESA\u003C/a\u003E , \u003Ca href=\"https://www.nasa.gov/mission_pages/hubble/story/index.html\" target=\"_blank\"\u003EHubble\u003C/a\u003E , \u003Ca href=\"http://archive.stsci.edu/proposal_search.php?mission=hst&id=13364\" target=\"_blank\"\u003ELEGUS\u003C/a\u003E ; \u003Ci\u003E Acknowledgement
提示:代码过长已自动截断
评论