> ## Documentation Index
> Fetch the complete documentation index at: https://docs.corsair.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# NASA plugin

> Astronomy Picture of the Day, near-Earth asteroid data from NeoWs, space weather from DONKI, DSCOVR EPIC imagery, EONET natural events and the NASA Image and Video Library.

Use **NASA** through Corsair: one client, typed API calls.

Get a key at [https://api.nasa.gov](https://api.nasa.gov). The form asks for a name, an email and a description of your use, and the key appears on the page immediately; there is no account to create. `DEMO_KEY` works without signing up, at 30 requests an hour and 50 a day per IP.

Only two of the five hosts read a key. `api.nasa.gov` (Near Earth Objects, DONKI, EPIC metadata) needs one for every request. `science.nasa.gov` (APOD) accepts one and serves the same data without it. EONET, `images-api.nasa.gov` and `epic.gsfc.nasa.gov` ignore the parameter entirely, so a key is only spent where it is required.

Things worth knowing before you call:

* **APOD takes a six-digit date code**, not `YYYY-MM-DD`. `apod.get` wants `240115` for 2024-01-15. `apod.list` filters with `date_from`/`date_to` in the same form, as strings so `'050101'` keeps its leading zero, and NASA ignores either one on its own: sending only `date_from` returns today's entries rather than failing. This plugin rejects a one-sided range before sending.
* **APOD caps a page at 25 entries.** NASA serves 25 for any larger `per_page`, so the plugin accepts 1 to 25 and rejects a larger value rather than return fewer than asked. A page-count based walk needs 25 as its page size.
* **The NEO feed takes at most seven days per request.** A wider window answers 400. Distances and speeds arrive as decimal strings, so `miss_distance.kilometers` is a string like `"45865643.869616206"`, not a number.
* **DONKI dates are inclusive on both ends.** Omitted dates default to the last 30 days, except `donki.enlilSimulation` and `donki.notification`, which default to the last seven. `donki.cme` answers 400 without both dates, so the plugin requires them. `donki.notification` silently shifts a window wider than 30 days to the last 30, so a long range does not fail, it returns less than you asked for.
* **`donki.solarFlare` is down at NASA's gateway.** On 2026-11-17 every `/DONKI/FLR` request, with or without dates, answered 404 from api.nasa.gov while the other DONKI routes worked. The request matches NASA's docs; the populated body has not been seen live.
* **EONET sends JSON labelled `application/rss+xml`.** The plugin parses it; a caller never sees a string. `status` omitted means only open events, and an unknown event ID answers a 500 with an HTML body rather than a 404.
* **EPIC timestamps are not ISO 8601.** `date` is `"2019-05-30 01:09:10"` with a space. A malformed date answers an HTML 500, and a valid date without imagery answers `[]`.
* **Rate limits apply across all api.nasa.gov routes**: 1,000 requests an hour per key; `DEMO_KEY` gets 30 an hour and 50 a day per IP. Waiting out the hour does not restore an exhausted daily `DEMO_KEY` allowance. Corsair's HTTP layer retries a 429 three times with backoff and then reports it.

**What you get:**

* 24 typed API operations

## Setup

**1. Install**

```bash npm theme={null}
npm install corsair @corsair-dev/nasa better-sqlite3
npm install --save-dev @types/better-sqlite3
```

```bash yarn theme={null}
yarn add corsair @corsair-dev/nasa better-sqlite3
yarn add --dev @types/better-sqlite3
```

```bash pnpm theme={null}
pnpm install corsair @corsair-dev/nasa better-sqlite3
pnpm install --save-dev @types/better-sqlite3
```

```bash bun theme={null}
bun add corsair @corsair-dev/nasa better-sqlite3
bun add --dev @types/better-sqlite3
```

**2. Add the plugin**

```ts corsair.ts theme={null}
import Database from 'better-sqlite3';
import { createCorsair } from 'corsair';
import { nasa } from '@corsair-dev/nasa';

export const corsair = createCorsair({
	plugins: [
		nasa(),
	],
	database: new Database('corsair.db'),
	kek: process.env.CORSAIR_KEK!,
	multiTenancy: true,
	hub: {
		projectApiKey: process.env.CORSAIR_API_KEY!,
		signingSecret: process.env.CORSAIR_SIGNING_SECRET!,
	},
});
```

With `multiTenancy: true`, scope calls with `corsair.withTenant(id)`. See [Quick start](https://docs.corsair.dev/quick-start.md) for KEK + Hub keys, and [Multi-tenancy](https://docs.corsair.dev/concepts/multi-tenancy.md) for account isolation.

**3. Choose authentication**

> [tab] API Key (Recommended)
>
> Store the NASA API key before the first call: `pnpm corsair setup --plugin=nasa --tenant=acme api_key=<your-key>` (leave out `--tenant` without `multiTenancy`), or pass it as `key` in the plugin options. With Hub, each tenant enters their own key on the connect page. See [API key auth](https://docs.corsair.dev/concepts/api-key).
>
> ```ts theme={null}
> nasa()
> ```
>
> More: [API Key](https://docs.corsair.dev/concepts/api-key)

**4. Connect a tenant**

Mint a connect link and send the tenant to it. Hub hosts the page and delivers the result to your app — see [Connect / OAuth](https://docs.corsair.dev/management/connect).

```ts theme={null}
const { connectUrl } = await corsair.manage.connect.createLink({
	plugin: 'nasa',
	tenantId: 'acme',
});
// redirect the user's browser to connectUrl
```

## Example API calls

**Read the latest pictures**

```ts theme={null}
const tenant = corsair.withTenant('acme');
await tenant.nasa.api.apod.list({ per_page: 3 });
```

**Write**

*No write-style endpoint inferred; pick any operation from the [API](https://docs.corsair.dev/plugins/nasa/api.md) reference.*

See the full list on the [API](https://docs.corsair.dev/plugins/nasa/api.md) page.

## What's next

> [card] [API reference](https://docs.corsair.dev/plugins/nasa/api.md)
>
> Every `nasa.api.*` operation with input and output types.

> [card] [Connect / OAuth](https://docs.corsair.dev/management/connect)
>
> createLink, Hub delivery, and tenant connect flows.

> [card] [Use with agents](https://docs.corsair.dev/mcp-adapters/mcp-adapters)
>
> Expose this plugin's operations as MCP tools.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.