Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

spacedata-0.1.0.tar.gz (22.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

spacedata-0.1.0-py3-none-any.whl (38.9 kB view details)

Uploaded Python 3

File details

Details for the file spacedata-0.1.0.tar.gz.

File metadata

  • Download URL: spacedata-0.1.0.tar.gz
  • Upload date:
  • Size: 22.7 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

Hashes for spacedata-0.1.0.tar.gz
Algorithm Hash digest
SHA256 ba8ec61757319f848a07e2ac8bc50e8a99bdbda68de5b493fddafebbd50fce73
MD5 135058554382272130d62dfd3fda4947
BLAKE2b-256 3d5ab423717e73f6216b76c36becdcf79ea5aaeeb4906e2c9081037c8fcc94f4

See more details on using hashes here.

File details

Details for the file spacedata-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: spacedata-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 38.9 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

Hashes for spacedata-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5d11d90873367f090600eb318951f1f007b95fb950e4b281f205a99e4e6f8b06
MD5 577a77cd8b5bb585098970719851d688
BLAKE2b-256 7be321b2ac29c10673c25f1dd5336c1be7abd99d39c5277881ae17c8f7e92324

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page