A dead simple API that scrap, cache and serve APOD (Astronomy Picture of the Day) info from nasa / star.ucl!
Inspired from the activitypub bot, @apod@reentry.codl.fr
- NASA previously hosted the Astronomy Picture of the Day (APOD) page along with an API service that provided metadata. (The API required keys and the demo-one had usage limits.)
- As of October 1st, 2025, the official service is down due to federal funding issues.
- I found an alternative mirror hosted by The UCL Astrophysics Group: http://www.star.ucl.ac.uk/~apod/apod/. However, this mirror does not provide an API endpoint.
- To work around this, created this service that scrapes, caches, and serves the same data via an API-like interface, including source attributions.
- BTW, this service is built with OpenResty.
- GET
/api/v1/apod.json
curl http://localhost:8000/api/v1/apod.json -s | jq
{
"credits": "www.star.ucl.ac.uk",
"img": "http://localhost:8000/api/v1/apod-img.jpg",
"description": "Put on your red/blue glasses and float next to asteroid 101955 Bennu. Shaped like a spinning toy top with boulders littering its rough surface, the tiny Solar System world is about one Empire State Building (less than 500 metres) across. Frames used to construct this 3D anaglyph were taken by PolyCam on the OSIRIS_REx spacecraft on December 3, 2018 from a distance of about 80 kilometres. With a sample from the asteroid's rocky surface on board, OSIRIS_REx departed Bennu's vicinity in May of 2021. The robotic spacecraft successfully returned the sample to its home world in September of 2023.",
"title": "3D Bennu",
"source": "http://www.star.ucl.ac.uk/~apod/apod/",
"date": "2025-10-19"
}
APOD_PAGE_URL
(defaults tohttp://www.star.ucl.ac.uk/~apod/apod/
, compatable withhttps://apod.nasa.gov/apod/
(but the site is dead today))SERVICE_BASE_URL
(defaults to empty string, eg:http://localhost:8000
)APOD_PAGE_MAX_SIZE
(defaults to 50kb) -- to save your serverAPOD_IMG_MAX_SIZE
(defaults to 10Mb) -- to save your serverREFRESH_AFTER_HR
(defaults to 2) -- period to refresh the cache
bruttazz/apod-api