# Asteroids API
> The NASA/JPL Small-Body Database (SBDB) as an API — 30,000+ named asteroids and comets with their physical and orbital properties. Look up any minor body by number (e.g. 1 → Ceres), name (Vesta) or SPK-ID; search by name with filters for orbit class, near-Earth (NEO) and potentially-hazardous (PHA) status; or list every near-Earth object. Each record carries the diameter, albedo, absolute magnitude, rotation period and the osculating orbit (semi-major axis, eccentricity, inclination, period) plus the orbit class (main-belt, Apollo, Trojan, …). Ideal for astronomy apps, planetarium software, education and space dashboards.

## Authentication
All requests require your oanor API key in the `x-oanor-key` header. Get one at https://www.oanor.com/developer/keys.

```bash
curl -H "x-oanor-key: oanor_live_…" "https://api.oanor.com/asteroids-api/..."
```

## Pricing
- **Free** (Free) — 4,000 calls/Mo, 2 req/s
- **Starter** ($6/Mo) — 55,000 calls/Mo, 8 req/s
- **Pro** ($18/Mo) — 280,000 calls/Mo, 20 req/s
- **Mega** ($46/Mo) — 1,300,000 calls/Mo, 50 req/s

## Endpoints

### Asteroids

#### `GET /v1/asteroid` — A single minor body by number, name or SPK-ID

**Parameters:**
- `number` (query, optional, string) — Asteroid number, e.g. 1 (Ceres) Example: `1`
- `name` (query, optional, string) — Name, e.g. Vesta
- `spkid` (query, optional, string) — JPL SPK-ID

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/asteroids-api/v1/asteroid?number=1"
```

**Response:**
```json
{
    "data": {
        "neo": false,
        "pha": false,
        "name": "Ceres",
        "orbit": {
            "eccentricity": 0.0796,
            "period_years": 4.6,
            "inclination_deg": 10.59,
            "semi_major_axis_au": 2.766
        },
        "spkid": 20000001,
        "albedo": 0.09,
        "number": 1,
        "designation": "1 Ceres (A801 AA)",
        "diameter_km": 939.4,
        "orbit_class": "MBA",
        "rotation_hours": 9.0742,
        "abs_magnitude_h": 3.35,
        "orbit_class_name": "Main-belt Asteroid"
    },
    "meta": {
        "timestamp": "2026-05-31T04:30:16.099Z",
        "request_id": "7d1d241d-62e9-410b-9566-feb8b50dce9c"
    },
    "status": "ok",
    "message": "Minor body retrieved",
    "success": true
}
```

#### `GET /v1/neo` — Near-Earth objects (optionally hazardous only)

**Parameters:**
- `pha` (query, optional, string) — true = potentially-hazardous only
- `limit` (query, optional, string) — Max results (1-100, default 25) Example: `25`
- `offset` (query, optional, string) — Pagination offset Example: `0`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/asteroids-api/v1/neo?limit=25&offset=0"
```

**Response:**
```json
{
    "data": {
        "count": 25,
        "limit": 25,
        "total": 389,
        "offset": 0,
        "results": [
            {
                "neo": true,
                "pha": false,
                "name": "Eros",
                "number": 433,
                "designation": "433 Eros (A898 PA)",
                "diameter_km": 16.84,
                "orbit_class": "AMO",
                "abs_magnitude_h": 10.39
            },
            {
                "neo": true,
                "pha": false,
                "name": "Albert",
                "number": 719,
                "designation": "719 Albert (A911 TB)",
                "diameter_km": null,
                "orbit_class": "AMO",
                "abs_magnitude_h": 15.59
            },
            {
                "neo": true,
                "pha": false,
                "name": "Alinda",
                "number": 887,
                "designation": "887 Alinda (A918 AA)",
                "diameter_km": 4.2,
                "orbit_class": "AMO",
                "abs_magnitude_h": 13.82
            },
            {
                "neo": true,
                "pha": false,
                "name": "Ganymed",
                "number": 1036,
                "designation": "1036 Ganymed (A924 UB)",
                "diameter_km": 37.675,
                "orbit_class": "AMO",
                "abs_magnitude_h": 9.17
            },
            {
                "neo": true,
                "pha": false,
        
…(truncated, see openapi.json for full schema)
```

#### `GET /v1/search` — Search by name with class / NEO / PHA filters

**Parameters:**
- `q` (query, optional, string) — Name search, e.g. apollo
- `class` (query, optional, string) — Orbit class, e.g. MBA, APO, ATE, TJN, TNO Example: `MBA`
- `neo` (query, optional, string) — true = near-Earth objects only
- `pha` (query, optional, string) — true = potentially-hazardous only
- `limit` (query, optional, string) — Results per page (1-100, default 20) Example: `20`
- `offset` (query, optional, string) — Pagination offset Example: `0`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/asteroids-api/v1/search?class=MBA&limit=20&offset=0"
```

**Response:**
```json
{
    "data": {
        "count": 20,
        "limit": 20,
        "query": null,
        "total": 24029,
        "offset": 0,
        "filters": {
            "neo": null,
            "pha": null,
            "class": "MBA"
        },
        "results": [
            {
                "neo": false,
                "pha": false,
                "name": "Ceres",
                "number": 1,
                "designation": "1 Ceres (A801 AA)",
                "diameter_km": 939.4,
                "orbit_class": "MBA",
                "abs_magnitude_h": 3.35
            },
            {
                "neo": false,
                "pha": false,
                "name": "Pallas",
                "number": 2,
                "designation": "2 Pallas (A802 FA)",
                "diameter_km": 513,
                "orbit_class": "MBA",
                "abs_magnitude_h": 4.11
            },
            {
                "neo": false,
                "pha": false,
                "name": "Juno",
                "number": 3,
                "designation": "3 Juno (A804 RA)",
                "diameter_km": 246.596,
                "orbit_class": "MBA",
                "abs_magnitude_h": 5.19
            },
            {
                "neo": false,
                "pha": false,
                "name": "Vesta",
                "number": 4,
                "designation": "4 Vesta (A807 FA)",
                "diameter_km": 522.77,
                "orbit_class": "MBA",
                "abs_m
…(truncated, see openapi.json for full schema)
```

### Meta

#### `GET /v1/meta` — Totals, NEO/PHA counts & orbit-class breakdown

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/asteroids-api/v1/meta"
```

**Response:**
```json
{
    "data": {
        "neo": 389,
        "pha": 51,
        "note": "Named asteroids and comets. neo = near-Earth object, pha = potentially hazardous asteroid. Orbit values are osculating elements.",
        "total": 30021,
        "fields": [
            "spkid",
            "number",
            "name",
            "designation",
            "neo",
            "pha",
            "diameter_km",
            "albedo",
            "orbit_class",
            "abs_magnitude_h",
            "rotation_hours",
            "orbit"
        ],
        "source": "NASA/JPL Small-Body Database (SBDB)",
        "orbit_classes": [
            {
                "code": "MBA",
                "count": 24029
            },
            {
                "code": "PAR",
                "count": 1655
            },
            {
                "code": "OMB",
                "count": 857
            },
            {
                "code": "JFc",
                "count": 829
            },
            {
                "code": "COM",
                "count": 724
            },
            {
                "code": "HYP",
                "count": 518
            },
            {
                "code": "TJN",
                "count": 345
            },
            {
                "code": "IMB",
                "count": 291
            },
            {
                "code": "MCA",
                "count": 286
            },
            {
                "code": "HTC",
                "count":
…(truncated, see openapi.json for full schema)
```


---
Marketplace page: https://www.oanor.com/api/asteroids-api
OpenAPI spec: https://www.oanor.com/api/asteroids-api/openapi.json
