Back to APIs
NASA
Access NASA's open data: Astronomy Picture of the Day, Mars rover photos, near-Earth objects, and EPIC Earth imagery.
Base URL
https://api.nasa.govspaceastronomyMarsasteroidsfree
Endpoints
GET
/planetary/apodGet the Astronomy Picture of the Day.
const response = await fetch("https://api.nasa.gov/planetary/apod?api_key=YOUR_API_KEY", {
method: "GET",
headers: {
"Content-Type": "application/json",
"X-API-Key": "YOUR_API_KEY"
}
});
const data = await response.json();
console.log(data);Response Preview
{
"date": "2024-05-01",
"title": "A Sky Full of Galaxies",
"explanation": "Thousands of galaxies appear...",
"url": "https://apod.nasa.gov/apod/image/...",
"media_type": "image",
"copyright": "NASA/ESA"
}GET
/neo/rest/v1/feedList near-Earth asteroids for a date range.
const response = await fetch("https://api.nasa.gov/neo/rest/v1/feed?start_date=2024-05-01&end_date=2024-05-07&api_key=YOUR_API_KEY", {
method: "GET",
headers: {
"Content-Type": "application/json",
"X-API-Key": "YOUR_API_KEY"
}
});
const data = await response.json();
console.log(data);Response Preview
{
"element_count": 42,
"near_earth_objects": {
"2024-05-01": [{
"name": "2024 JL1",
"estimated_diameter": { "kilometers": { "max": 0.214 } },
"is_potentially_hazardous_asteroid": false
}]
}
}