How to hit the NASA API

NASA publishes free APIs at https://api.nasa.gov. They take an api_key query parameter, and DEMO_KEY works for trying things out — so every example below runs as-is.

Authentication

DEMO_KEY has a low per-IP rate limit. A free personal key from api.nasa.gov raises it a lot — swap it in for DEMO_KEY. The image library (images-api.nasa.gov) needs no key at all.

Full reference: https://api.nasa.gov/

Astronomy Picture of the Day

The picture (or video) and write-up for a date. Leave out date for today's. explanation is omitted from the sample below.

curl "https://api.nasa.gov/planetary/apod?api_key=DEMO_KEY&date=2025-07-04"
Run in PostTaco
Example response (trimmed)
{
  "date": "2025-07-04",
  "title": "NGC 6946 and NGC 6939",
  "media_type": "image",
  "url": "https://apod.nasa.gov/apod/image/2507/N6946N6939pisabarro1024.jpg",
  "hdurl": "https://apod.nasa.gov/apod/image/2507/N6946N6939pisabarro.jpg",
  "copyright": "Alberto Pisabarro"
}

Asteroids passing Earth

Near-Earth objects by closest-approach date — size, speed, miss distance, and whether it's classed as hazardous. Up to 7 days per request.

curl "https://api.nasa.gov/neo/rest/v1/feed?start_date=2025-07-04&end_date=2025-07-04&api_key=DEMO_KEY"
Run in PostTaco
Example response (trimmed)
{
  "element_count": 4,
  "near_earth_objects": {
    "2025-07-04": [
      {
        "id": "3655548",
        "name": "(2013 YA38)",
        "absolute_magnitude_h": 21.02,
        "is_potentially_hazardous_asteroid": false,
        "estimated_diameter": {
          "meters": {
            "estimated_diameter_min": 166.1709017398,
            "estimated_diameter_max": 371.5694321726
          }
        },
        "close_approach_data": [
          {
            "close_approach_date": "2025-07-04",
            "miss_distance": {
              "astronomical": "0.1473069831",
              "lunar": "57.3024164259",
              "kilometers": "22036810.907885997",
              "miles": "13693039.3434888786"
            },
            "relative_velocity": {
              "kilometers_per_second": "21.3260597538",
              "kilometers_per_hour": "76773.8151138535",
              "miles_per_hour": "47704.263063383"
            }
          }
        ]
      }
    ]
  }
}

Full-disc Earth images (EPIC)

Every photo the DSCOVR spacecraft took of the whole Earth on a date — 22 on this one. Build the image URL from image and the date.

curl "https://api.nasa.gov/EPIC/api/natural/date/2025-07-04?api_key=DEMO_KEY"
Run in PostTaco
Example response (trimmed)
[
  {
    "identifier": "20250704002713",
    "caption": "This image was taken by NASA's EPIC camera onboard the NOAA DSCOVR spacecraft",
    "image": "epic_1b_20250704002713",
    "date": "2025-07-04 00:22:24",
    "centroid_coordinates": {
      "lat": 15.974121,
      "lon": 174.814453
    }
  }
]

Search the NASA image library

Photos, video, and audio from NASA's archive. No key. Each item links to its asset files.

curl "https://images-api.nasa.gov/search?q=apollo%2011&media_type=image&page_size=2"
Run in PostTaco
Example response (trimmed)
{
  "collection": {
    "items": [
      {
        "href": "https://images-assets.nasa.gov/image/jsc2007e034221/collection.json",
        "data": [
          {
            "nasa_id": "jsc2007e034221",
            "title": "Apollo 11 spacecraft pre-launch",
            "date_created": "1969-07-11T00:00:00Z",
            "center": "JSC",
            "media_type": "image"
          }
        ],
        "links": [
          {
            "href": "https://images-assets.nasa.gov/image/jsc2007e034221/jsc2007e034221~medium.jpg",
            "rel": "alternate",
            "render": "image"
          }
        ]
      }
    ],
    "metadata": {
      "total_hits": 1522
    }
  }
}