NASA APOD API
api.nasa.gov · Science
NASA Astronomy Picture of the Day — daily space images with explanations by professional astronomers. Also includes NeoWs (near-Earth asteroids), Mars Rover photos, and Earth satellite imagery. Free API key, 1,000 req/hour.
Authentication
Sample Requests
Get today's Astronomy Picture of the Day.
Hover any highlighted part to learn what it does
curl -X GET "https://api.nasa.gov/planetary/apod?api_key=DEMO_KEY"
import requests
params = {
"api_key": "DEMO_KEY"
}
response = requests.get(
"https://api.nasa.gov/planetary/apod",
params=params,
)
print(response.json())const url = new URL('https://api.nasa.gov/planetary/apod');
url.searchParams.set('api_key', 'DEMO_KEY');
const response = await fetch(url);
const data = await response.json();
console.log(data);package main
import (
"fmt"
"io"
"net/http"
"net/url"
)
func main() {
baseURL, _ := url.Parse("https://api.nasa.gov/planetary/apod")
q := baseURL.Query()
q.Set("api_key", "DEMO_KEY")
baseURL.RawQuery = q.Encode()
targetURL := baseURL.String()
req, _ := http.NewRequest("GET", targetURL, nil)
client := &http.Client{}
resp, _ := client.Do(req)
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
fmt.Println(string(body))
}require "net/http"
require "json"
uri = URI("https://api.nasa.gov/planetary/apod")
uri.query = URI.encode_www_form({
"api_key" => "DEMO_KEY"
})
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = uri.scheme == "https"
req = Net::HTTP::Get.new(uri)
res = http.request(req)
puts JSON.parse(res.body)<?php
$url = "https://api.nasa.gov/planetary/apod?" . http_build_query([
"api_key" => "DEMO_KEY"
]);
$opts = ["http" => [
"method" => "GET",
]];
$ctx = stream_context_create($opts);
$res = file_get_contents($url, false, $ctx);
print_r(json_decode($res, true));Get near-Earth asteroid data for a date range.
Hover any highlighted part to learn what it does
curl -X GET "https://api.nasa.gov/neo/rest/v1/feed?api_key=DEMO_KEY&end_date=2026-06-10&start_date=2026-06-08"
import requests
params = {
"api_key": "DEMO_KEY",
"end_date": "2026-06-10",
"start_date": "2026-06-08"
}
response = requests.get(
"https://api.nasa.gov/neo/rest/v1/feed",
params=params,
)
print(response.json())const url = new URL('https://api.nasa.gov/neo/rest/v1/feed');
url.searchParams.set('api_key', 'DEMO_KEY');
url.searchParams.set('end_date', '2026-06-10');
url.searchParams.set('start_date', '2026-06-08');
const response = await fetch(url);
const data = await response.json();
console.log(data);package main
import (
"fmt"
"io"
"net/http"
"net/url"
)
func main() {
baseURL, _ := url.Parse("https://api.nasa.gov/neo/rest/v1/feed")
q := baseURL.Query()
q.Set("api_key", "DEMO_KEY")
q.Set("end_date", "2026-06-10")
q.Set("start_date", "2026-06-08")
baseURL.RawQuery = q.Encode()
targetURL := baseURL.String()
req, _ := http.NewRequest("GET", targetURL, nil)
client := &http.Client{}
resp, _ := client.Do(req)
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
fmt.Println(string(body))
}require "net/http"
require "json"
uri = URI("https://api.nasa.gov/neo/rest/v1/feed")
uri.query = URI.encode_www_form({
"api_key" => "DEMO_KEY",
"end_date" => "2026-06-10",
"start_date" => "2026-06-08"
})
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = uri.scheme == "https"
req = Net::HTTP::Get.new(uri)
res = http.request(req)
puts JSON.parse(res.body)<?php
$url = "https://api.nasa.gov/neo/rest/v1/feed?" . http_build_query([
"api_key" => "DEMO_KEY",
"end_date" => "2026-06-10",
"start_date" => "2026-06-08"
]);
$opts = ["http" => [
"method" => "GET",
]];
$ctx = stream_context_create($opts);
$res = file_get_contents($url, false, $ctx);
print_r(json_decode($res, true));Get Curiosity rover photos from Mars sol 1000.
Hover any highlighted part to learn what it does
curl -X GET "https://api.nasa.gov/mars-photos/api/v1/rovers/curiosity/photos?sol=1000&page=1&api_key=DEMO_KEY"
import requests
params = {
"sol": "1000",
"page": "1",
"api_key": "DEMO_KEY"
}
response = requests.get(
"https://api.nasa.gov/mars-photos/api/v1/rovers/curiosity/photos",
params=params,
)
print(response.json())const url = new URL('https://api.nasa.gov/mars-photos/api/v1/rovers/curiosity/photos');
url.searchParams.set('sol', '1000');
url.searchParams.set('page', '1');
url.searchParams.set('api_key', 'DEMO_KEY');
const response = await fetch(url);
const data = await response.json();
console.log(data);package main
import (
"fmt"
"io"
"net/http"
"net/url"
)
func main() {
baseURL, _ := url.Parse("https://api.nasa.gov/mars-photos/api/v1/rovers/curiosity/photos")
q := baseURL.Query()
q.Set("sol", "1000")
q.Set("page", "1")
q.Set("api_key", "DEMO_KEY")
baseURL.RawQuery = q.Encode()
targetURL := baseURL.String()
req, _ := http.NewRequest("GET", targetURL, nil)
client := &http.Client{}
resp, _ := client.Do(req)
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
fmt.Println(string(body))
}require "net/http"
require "json"
uri = URI("https://api.nasa.gov/mars-photos/api/v1/rovers/curiosity/photos")
uri.query = URI.encode_www_form({
"sol" => "1000",
"page" => "1",
"api_key" => "DEMO_KEY"
})
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = uri.scheme == "https"
req = Net::HTTP::Get.new(uri)
res = http.request(req)
puts JSON.parse(res.body)<?php
$url = "https://api.nasa.gov/mars-photos/api/v1/rovers/curiosity/photos?" . http_build_query([
"sol" => "1000",
"page" => "1",
"api_key" => "DEMO_KEY"
]);
$opts = ["http" => [
"method" => "GET",
]];
$ctx = stream_context_create($opts);
$res = file_get_contents($url, false, $ctx);
print_r(json_decode($res, true));Postman Setup Guide
- Use DEMO_KEY for testing (30 req/hour)
- Get a free key at api.nasa.gov for 1,000 req/hour
- APOD: GET /planetary/apod?api_key=YOUR_KEY
- Historical APOD: add &date=2024-01-15
- Mars Rover: GET /mars-photos/api/v1/rovers/perseverance/photos?sol=100&api_key=YOUR_KEY
What can you build with NASA APOD API?
NASA APOD API is a Science API. Developers commonly use science APIs for:
- accessing research datasets and scientific literature
- powering academic and R&D applications
- running scientific calculations and simulations
- visualising experimental and observational data
- integrating with research and reference databases
API Key authentication. You'll receive a key after signing up. Send it with every request — in a header or query parameter. Keep it out of client-side code and never commit it to version control. NASA APOD API is free to use up to a usage limit, making it a low-risk choice to experiment with.
New to APIs? Read our beginner's guide · Learn about API keys · What is REST?