# NASA Data Scraper — APOD, Asteroids & Image Search (`thriftykiwi/nasa-data-scraper`) Actor

Fetch data from free NASA public APIs: Astronomy Picture of the Day, Near Earth Objects (asteroids), and Image/Video Library search. No API key required.

- **URL**: https://apify.com/thriftykiwi/nasa-data-scraper.md
- **Developed by:** [Thrifty Kiwi](https://apify.com/thriftykiwi) (community)
- **Categories:** Developer tools, Other
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

$5.00 / 1,000 result items

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/platform/actors/running/actors-in-store#pay-per-event

## What's an Apify Actor?

Actors are a software tools running on the Apify platform, for all kinds of web data extraction and automation use cases.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.
Actors are written with capital "A".

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.
The best way to integrate Actors is as follows.

In JavaScript/TypeScript projects, use official [JavaScript/TypeScript client](https://docs.apify.com/api/client/js/docs.md):

```bash
npm install apify-client
```

In Python projects, use official [Python client library](https://docs.apify.com/api/client/python/docs.md):

```bash
pip install apify-client
```

In shell scripts, use [Apify CLI](https://docs.apify.com/cli/docs.md):

````bash
# MacOS / Linux
curl -fsSL https://apify.com/install-cli.sh | bash
# Windows
irm https://apify.com/install-cli.ps1 | iex
```bash

In AI frameworks, you might use the [Apify MCP server](https://docs.apify.com/integrations/mcp.md).

If your project is in a different language, use the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).


# README

## NASA Data Scraper 🚀

Fetch data from free NASA public APIs — no API key required.

### What it does

This Actor queries three different NASA APIs and outputs structured JSON with images, descriptions, dates, and more.

#### Modes

| Mode | API | What you get |
|------|-----|-------------|
| **APOD** | Astronomy Picture of the Day | Daily astronomy image, title, explanation, HD URL |
| **NEO** | Near Earth Objects | Asteroids/comets approaching Earth — diameter, velocity, miss distance, hazard status |
| **Image Search** | NASA Image/Video Library | Search across NASA's entire media library |

### Input

| Field | Type | Default | Description |
|-------|------|---------|-------------|
| `mode` | enum | `apod` | One of: `apod`, `neo`, `image_search` |
| `api_key` | string | `DEMO_KEY` | NASA API key. DEMO_KEY works but rate-limited (30 req/hr). Get free key at https://api.nasa.gov for 1000 req/hr. |
| `date` | string | *(today)* | Date for APOD in YYYY-MM-DD (apod mode only) |
| `neoMode` | enum | `feed` | `feed` (date-range approach data) or `browse` (full catalog) |
| `startDate` | string | *(today)* | Start date for NEO feed YYYY-MM-DD (neo mode, feed) |
| `endDate` | string | *(+7 days)* | End date for NEO feed (max 7 days, neo mode, feed) |
| `query` | string | `mars` | Search term for NASA Image/Video Library |
| `media_type` | enum | `image` | Media type: image, video, audio |
| `maxPages` | integer | `1` | Max pages to fetch (neo browse / image_search) |

### Output examples

#### APOD
```json
{
  "source": "apod",
  "title": "NGC 1232: A Grand Design Spiral Galaxy",
  "date": "2024-01-01",
  "explanation": "Galaxies are fascinating...",
  "url": "https://apod.nasa.gov/apod/image/2401/ngc1232b_vlt_960.jpg",
  "hdurl": "https://apod.nasa.gov/apod/image/2401/ngc1232b_vlt_3969.jpg",
  "media_type": "image",
  "copyright": ""
}
````

#### NEO (Near Earth Objects)

```json
{
  "source": "neo",
  "id": "2001620",
  "name": "1620 Geographos (1951 RA)",
  "is_potentially_hazardous": true,
  "estimated_diameter_km_min": 2.35,
  "estimated_diameter_km_max": 5.25,
  "close_approach_date": "2026-08-12",
  "orbiting_body": "Earth",
  "relative_velocity_kph": "30101.53",
  "miss_distance_km": "25497054.40",
  "miss_distance_lunar": "66.30",
  "nasa_jpl_url": "https://ssd.jpl.nasa.gov/tools/sbdb_lookup.html#/?sstr=2001620"
}
```

#### Image/Video Library

```json
{
  "source": "image_search",
  "nasa_id": "PIA12235",
  "title": "Mars Panorama",
  "description": "A panoramic view of...",
  "date_created": "2009-01-01T00:00:00Z",
  "media_type": "image",
  "keywords": ["Mars", "Panorama"],
  "center": "JPL",
  "links": ["https://images-assets.nasa.gov/image/PIA12235/PIA12235~orig.jpg"]
}
```

### Rate Limits

- **DEMO\_KEY**: 30 requests per hour, ~50 per day. Good for testing.
- **Free API key** (register at https://api.nasa.gov): 1000 requests per hour. Recommended for production.

### Use cases

- Build a space image gallery or screensaver app
- Feed astronomy content to social media bots
- Enrich educational apps with real NASA imagery
- Track near-Earth asteroids for science projects
- Search and catalog NASA's media archive

### Pricing

This Actor uses Pay-Per-Event pricing. You only pay for results you get.

# Actor input Schema

## `mode` (type: `string`):

Which NASA API to query.

## `api_key` (type: `string`):

NASA API key. Use 'DEMO\_KEY' for testing (rate-limited to 30 req/hour). Register for a free key at https://api.nasa.gov for higher limits (1000 req/hour).

## `date` (type: `string`):

Date for APOD in YYYY-MM-DD format. Leave empty for latest. Only used in 'apod' mode.

## `neoMode` (type: `string`):

How to query NEO data. 'feed' returns asteroids approaching Earth in a date range. 'browse' browses the full NEO catalog. Only used in 'neo' mode.

## `startDate` (type: `string`):

Start date for NEO approach feed in YYYY-MM-DD format. Defaults to today. Only used in 'neo' mode with neoMode='feed'.

## `endDate` (type: `string`):

End date for NEO approach feed in YYYY-MM-DD format. Max 7 days from start\_date. Defaults to start\_date + 7. Only used in 'neo' mode with neoMode='feed'.

## `query` (type: `string`):

Search term for NASA Image/Video Library (e.g., 'mars', 'jupiter', 'apollo 11', 'hubble'). Only used in 'image\_search' mode.

## `media_type` (type: `string`):

Filter by media type. Only used in 'image\_search' mode.

## `maxPages` (type: `integer`):

Maximum number of pages to fetch (for neo browse and image\_search modes). Each page returns up to 20 NEOs (browse) or 100 items (library).

## Actor input object example

```json
{
  "mode": "apod",
  "api_key": "DEMO_KEY",
  "date": "2024-01-01",
  "neoMode": "feed",
  "startDate": "2026-07-10",
  "endDate": "2026-07-17",
  "query": "mars",
  "media_type": "image",
  "maxPages": 1
}
```

# Actor output Schema

## `results` (type: `string`):

No description

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "mode": "apod",
    "api_key": "DEMO_KEY",
    "date": "2024-01-01",
    "neoMode": "feed",
    "startDate": "2026-07-10",
    "endDate": "2026-07-17",
    "query": "mars",
    "media_type": "image",
    "maxPages": 1
};

// Run the Actor and wait for it to finish
const run = await client.actor("thriftykiwi/nasa-data-scraper").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {
    "mode": "apod",
    "api_key": "DEMO_KEY",
    "date": "2024-01-01",
    "neoMode": "feed",
    "startDate": "2026-07-10",
    "endDate": "2026-07-17",
    "query": "mars",
    "media_type": "image",
    "maxPages": 1,
}

# Run the Actor and wait for it to finish
run = client.actor("thriftykiwi/nasa-data-scraper").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print("💾 Check your data here: https://console.apify.com/storage/datasets/" + run["defaultDatasetId"])
for item in client.dataset(run["defaultDatasetId"]).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "mode": "apod",
  "api_key": "DEMO_KEY",
  "date": "2024-01-01",
  "neoMode": "feed",
  "startDate": "2026-07-10",
  "endDate": "2026-07-17",
  "query": "mars",
  "media_type": "image",
  "maxPages": 1
}' |
apify call thriftykiwi/nasa-data-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "command": "npx",
            "args": [
                "mcp-remote",
                "https://mcp.apify.com/?tools=thriftykiwi/nasa-data-scraper",
                "--header",
                "Authorization: Bearer <YOUR_API_TOKEN>"
            ]
        }
    }
}

```

## OpenAPI specification

```json
{
    "openapi": "3.0.1",
    "info": {
        "title": "NASA Data Scraper — APOD, Asteroids & Image Search",
        "description": "Fetch data from free NASA public APIs: Astronomy Picture of the Day, Near Earth Objects (asteroids), and Image/Video Library search. No API key required.",
        "version": "1.0",
        "x-build-id": "4elXDSv1ofaDcdf1D"
    },
    "servers": [
        {
            "url": "https://api.apify.com/v2"
        }
    ],
    "paths": {
        "/acts/thriftykiwi~nasa-data-scraper/run-sync-get-dataset-items": {
            "post": {
                "operationId": "run-sync-get-dataset-items-thriftykiwi-nasa-data-scraper",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for its completion, and returns Actor's dataset items in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        },
        "/acts/thriftykiwi~nasa-data-scraper/runs": {
            "post": {
                "operationId": "runs-sync-thriftykiwi-nasa-data-scraper",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor and returns information about the initiated run in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK",
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/runsResponseSchema"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/acts/thriftykiwi~nasa-data-scraper/run-sync": {
            "post": {
                "operationId": "run-sync-thriftykiwi-nasa-data-scraper",
                "x-openai-isConsequential": false,
                "summary": "Executes an Actor, waits for completion, and returns the OUTPUT from Key-value store in response.",
                "tags": [
                    "Run Actor"
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/json": {
                            "schema": {
                                "$ref": "#/components/schemas/inputSchema"
                            }
                        }
                    }
                },
                "parameters": [
                    {
                        "name": "token",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Enter your Apify token here"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "OK"
                    }
                }
            }
        }
    },
    "components": {
        "schemas": {
            "inputSchema": {
                "type": "object",
                "required": [
                    "mode"
                ],
                "properties": {
                    "mode": {
                        "title": "Scraper Mode",
                        "enum": [
                            "apod",
                            "neo",
                            "image_search"
                        ],
                        "type": "string",
                        "description": "Which NASA API to query.",
                        "default": "apod"
                    },
                    "api_key": {
                        "title": "NASA API Key",
                        "type": "string",
                        "description": "NASA API key. Use 'DEMO_KEY' for testing (rate-limited to 30 req/hour). Register for a free key at https://api.nasa.gov for higher limits (1000 req/hour).",
                        "default": "DEMO_KEY"
                    },
                    "date": {
                        "title": "Date (APOD)",
                        "type": "string",
                        "description": "Date for APOD in YYYY-MM-DD format. Leave empty for latest. Only used in 'apod' mode.",
                        "default": ""
                    },
                    "neoMode": {
                        "title": "NEO Query Mode",
                        "enum": [
                            "feed",
                            "browse"
                        ],
                        "type": "string",
                        "description": "How to query NEO data. 'feed' returns asteroids approaching Earth in a date range. 'browse' browses the full NEO catalog. Only used in 'neo' mode.",
                        "default": "feed"
                    },
                    "startDate": {
                        "title": "Start Date (NEO Feed)",
                        "type": "string",
                        "description": "Start date for NEO approach feed in YYYY-MM-DD format. Defaults to today. Only used in 'neo' mode with neoMode='feed'.",
                        "default": ""
                    },
                    "endDate": {
                        "title": "End Date (NEO Feed)",
                        "type": "string",
                        "description": "End date for NEO approach feed in YYYY-MM-DD format. Max 7 days from start_date. Defaults to start_date + 7. Only used in 'neo' mode with neoMode='feed'.",
                        "default": ""
                    },
                    "query": {
                        "title": "Search Query",
                        "type": "string",
                        "description": "Search term for NASA Image/Video Library (e.g., 'mars', 'jupiter', 'apollo 11', 'hubble'). Only used in 'image_search' mode.",
                        "default": "mars"
                    },
                    "media_type": {
                        "title": "Media Type",
                        "enum": [
                            "image",
                            "video",
                            "audio"
                        ],
                        "type": "string",
                        "description": "Filter by media type. Only used in 'image_search' mode.",
                        "default": "image"
                    },
                    "maxPages": {
                        "title": "Max Pages",
                        "minimum": 1,
                        "maximum": 100,
                        "type": "integer",
                        "description": "Maximum number of pages to fetch (for neo browse and image_search modes). Each page returns up to 20 NEOs (browse) or 100 items (library).",
                        "default": 1
                    }
                }
            },
            "runsResponseSchema": {
                "type": "object",
                "properties": {
                    "data": {
                        "type": "object",
                        "properties": {
                            "id": {
                                "type": "string"
                            },
                            "actId": {
                                "type": "string"
                            },
                            "userId": {
                                "type": "string"
                            },
                            "startedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "finishedAt": {
                                "type": "string",
                                "format": "date-time",
                                "example": "2025-01-08T00:00:00.000Z"
                            },
                            "status": {
                                "type": "string",
                                "example": "READY"
                            },
                            "meta": {
                                "type": "object",
                                "properties": {
                                    "origin": {
                                        "type": "string",
                                        "example": "API"
                                    },
                                    "userAgent": {
                                        "type": "string"
                                    }
                                }
                            },
                            "stats": {
                                "type": "object",
                                "properties": {
                                    "inputBodyLen": {
                                        "type": "integer",
                                        "example": 2000
                                    },
                                    "rebootCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "restartCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "resurrectCount": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "computeUnits": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "options": {
                                "type": "object",
                                "properties": {
                                    "build": {
                                        "type": "string",
                                        "example": "latest"
                                    },
                                    "timeoutSecs": {
                                        "type": "integer",
                                        "example": 300
                                    },
                                    "memoryMbytes": {
                                        "type": "integer",
                                        "example": 1024
                                    },
                                    "diskMbytes": {
                                        "type": "integer",
                                        "example": 2048
                                    }
                                }
                            },
                            "buildId": {
                                "type": "string"
                            },
                            "defaultKeyValueStoreId": {
                                "type": "string"
                            },
                            "defaultDatasetId": {
                                "type": "string"
                            },
                            "defaultRequestQueueId": {
                                "type": "string"
                            },
                            "buildNumber": {
                                "type": "string",
                                "example": "1.0.0"
                            },
                            "containerUrl": {
                                "type": "string"
                            },
                            "usage": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "integer",
                                        "example": 1
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            },
                            "usageTotalUsd": {
                                "type": "number",
                                "example": 0.00005
                            },
                            "usageUsd": {
                                "type": "object",
                                "properties": {
                                    "ACTOR_COMPUTE_UNITS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATASET_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "KEY_VALUE_STORE_WRITES": {
                                        "type": "number",
                                        "example": 0.00005
                                    },
                                    "KEY_VALUE_STORE_LISTS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_READS": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "REQUEST_QUEUE_WRITES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_INTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "DATA_TRANSFER_EXTERNAL_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_RESIDENTIAL_TRANSFER_GBYTES": {
                                        "type": "integer",
                                        "example": 0
                                    },
                                    "PROXY_SERPS": {
                                        "type": "integer",
                                        "example": 0
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
```
