A Python package to interact with NASA's services
Project description
SpaceData
SpaceData is a high-performance, asynchronous Python SDK for NASA's open APIs. It provides a type-safe interface for retrieving astronomical data, near-Earth objects, and space weather information.
Purpose
To simplify access to NASA's complex data structures by providing a unified, developer-friendly client with built-in utilities for data analysis and media handling.
Installation
pip install spacedata
API Key: While the SDK works with the default DEMO_KEY, we recommend getting a free API key from NASA for higher rate limits and production use.
Features
- Async Support: Efficient non-blocking I/O using
httpx - Type Safety: Full Pydantic integration for validation and autocompletion
- Smart Automation:
- Automatic pagination handling
- Date-range splitting for large queries
- Media file downloading
- Data Science Ready:
- Convert results to Pandas, Polars, or PyArrow
- Export directly to DataFrames for analysis
- Performance:
- Built-in caching (in-memory or DuckDB)
- Automatic retry with exponential backoff
Examples
1. Astronomy Picture of the Day
import asyncio
from spacedata import SpaceDataClient
async def main():
async with SpaceDataClient() as client:
result = await client.planetary.apod(start_date="2025-01-01", end_date="2025-01-05")
async for item in result:
print(f"{item.date}: {item.title}")
if __name__ == "__main__":
asyncio.run(main())
2. Near-Earth Objects (NEO) Lookup
import asyncio
from spacedata import SpaceDataClient
async def main():
async with SpaceDataClient() as client:
result = await client.neo.lookup(asteroid_ids=[3542519])
async for asteroid in result:
print(f"Asteroid: {asteroid.name} (Hazardous: {asteroid.is_potentially_hazardous_asteroid})")
if __name__ == "__main__":
asyncio.run(main())
3. Convert to DataFrame for Analysis
import asyncio
from spacedata import SpaceDataClient
async def main():
async with SpaceDataClient() as client:
result = await client.neo.feed(start_date="2025-01-01", end_date="2025-01-31")
df = await result.to_pandas()
print(f"Found {len(df)} asteroids")
print(df[['name', 'is_potentially_hazardous_asteroid']].head())
if __name__ == "__main__":
asyncio.run(main())
Documentation
Core
Resources
Planetary
| Resource | Description | Docs |
|---|---|---|
| APOD | Astronomy Picture of the Day | View |
Near-Earth Objects (NEO)
| Resource | Description | Docs |
|---|---|---|
| NEO Feed | Near-Earth Objects by date range | View |
| NEO Lookup | Specific NEO details by ID | View |
| NEO Browse | Full Near-Earth Object database | View |
InSight
| Resource | Description | Docs |
|---|---|---|
| Mars Weather | Mars atmospheric data from InSight lander | View |
DONKI (Space Weather Events)
| Resource | Description | Docs |
|---|---|---|
| CME | Coronal Mass Ejections events | View |
| CME Analysis | CME analysis with ENLIL simulations | View |
| FLR | Solar Flare events | View |
| GST | Geomagnetic Storm events | View |
| HSS | High Speed Stream events | View |
| IPS | Interplanetary Shock events | View |
| MPC | Magnetopause Crossing events | View |
| RBE | Radiation Belt Enhancement events | View |
| SEP | Solar Energetic Particle events | View |
| WSA | WSA+ENLIL solar wind simulations | View |
| Notifications | Space weather notification messages | View |
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file spacedata-0.1.1.tar.gz.
File metadata
- Download URL: spacedata-0.1.1.tar.gz
- Upload date:
- Size: 22.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.21 {"installer":{"name":"uv","version":"0.9.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Arch Linux ARM","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
212c3c7c86c0e37ef828ac4dda0fb2a5dd61fbf1970d7ebc81865e2968d6b850
|
|
| MD5 |
10cab77964539f01402d9c8f94b1d66f
|
|
| BLAKE2b-256 |
ea050e008102c8d6de97475932d967682abeef9430b2bb772354104a395fba01
|
File details
Details for the file spacedata-0.1.1-py3-none-any.whl.
File metadata
- Download URL: spacedata-0.1.1-py3-none-any.whl
- Upload date:
- Size: 39.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.21 {"installer":{"name":"uv","version":"0.9.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Arch Linux ARM","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c12c82150610a0ccf09bade6dd8be89a01ea5acb7fe4e87f628bf66dd4d771a1
|
|
| MD5 |
39e854501967313a510451aa7cd6428a
|
|
| BLAKE2b-256 |
7b2023790670bf0c81ec61303b0bc729d37dc7057c5899996b9cd786fdfde69b
|