# Light Travel Time API
> Light-travel-time astronomy maths as an API, computed locally and deterministically. The travel-time endpoint computes how long light takes to cross a distance, t = d/c with c = 299,792,458 m/s exactly, accepting the distance in metres, kilometres, miles, astronomical units, light-years, parsecs or light-seconds/minutes and returning the time in seconds, minutes, hours, days and years — light from the Sun reaches Earth in about 8.3 minutes and the nearest star is about 4.2 light-years away. The distance endpoint inverts the relation, d = c·t, to give how far light travels in a time, returning the distance in metres, kilometres, astronomical units, light-years and parsecs — one light-year is about 9.461×10¹⁵ m. The round-trip endpoint computes the one-way and round-trip communication delay to a target, d/c and 2·d/c, the light-speed latency that makes distant spacecraft control so slow and Mars rovers largely autonomous. Distance units include light-second and light-minute and time units run from seconds to years. Everything is computed locally and deterministically, so it is instant and private. Ideal for astronomy, space-mission, education, science-communication and simulation app developers, communication-delay and cosmic-distance tools, and physics teaching. Pure local computation — no key, no third-party service, instant. Live, nothing stored. 3 endpoints. This is light travel time; for an object's angular size use an angular-size API and for sidereal time a sidereal API.

## 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/lighttime-api/..."
```

## Pricing
- **Free** (Free) — 4,800 calls/Mo, 2 req/s
- **Starter** ($4/Mo) — 47,500 calls/Mo, 6 req/s
- **Pro** ($11/Mo) — 222,000 calls/Mo, 15 req/s
- **Mega** ($37/Mo) — 1,310,000 calls/Mo, 40 req/s

## Endpoints

### LightTime

#### `GET /v1/distance` — Distance from time

**Parameters:**
- `time` (query, required, string) — Time Example: `1`
- `unit` (query, optional, string) — s, min, h, day, year Example: `year`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/lighttime-api/v1/distance?time=1&unit=year"
```

**Response:**
```json
{
    "data": {
        "note": "Distance light covers d = c·t. One light-year is the distance light travels in a Julian year ≈ 9.461×10¹⁵ m.",
        "inputs": {
            "time": 1,
            "unit": "year"
        },
        "distance": {
            "au": 63241.0770842663,
            "meters": 9460730472580800,
            "parsecs": 0.30660139378555,
            "kilometers": 9460730472580.8,
            "light_years": 1
        },
        "time_seconds": 31557600
    },
    "meta": {
        "timestamp": "2026-06-05T19:50:33.116Z",
        "request_id": "15d76aae-1f39-4414-8910-936da34c7f9b"
    },
    "status": "ok",
    "message": "Distance from time",
    "success": true
}
```

#### `GET /v1/round-trip` — Round-trip delay

**Parameters:**
- `distance` (query, required, string) — Distance Example: `150000000`
- `unit` (query, optional, string) — m, km, mi, au, ly, pc, ls, lm Example: `km`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/lighttime-api/v1/round-trip?distance=150000000&unit=km"
```

**Response:**
```json
{
    "data": {
        "note": "Communication delay: a signal travels at light speed, so the one-way latency is d/c and a command-and-acknowledge round trip is 2·d/c — the reason Mars rovers are largely autonomous.",
        "inputs": {
            "unit": "km",
            "distance": 150000000
        },
        "distance_m": 150000000000,
        "one_way_delay": {
            "days": 0.0057910433,
            "hours": 0.13898504,
            "years": 1.5855013e-5,
            "minutes": 8.33910238,
            "seconds": 500.346143
        },
        "round_trip_delay": {
            "days": 0.0115820866,
            "hours": 0.277970079,
            "years": 3.1710025e-5,
            "minutes": 16.67820476,
            "seconds": 1000.692286
        }
    },
    "meta": {
        "timestamp": "2026-06-05T19:50:33.213Z",
        "request_id": "c8acf156-39d5-4a29-b37f-200e69a8a2e1"
    },
    "status": "ok",
    "message": "Round-trip delay",
    "success": true
}
```

#### `GET /v1/travel-time` — Light travel time

**Parameters:**
- `distance` (query, required, string) — Distance Example: `1`
- `unit` (query, optional, string) — m, km, mi, au, ly, pc, ls, lm Example: `au`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/lighttime-api/v1/travel-time?distance=1&unit=au"
```

**Response:**
```json
{
    "data": {
        "note": "Light travel time t = d/c (c = 299,792,458 m/s). Light from the Sun reaches Earth in about 8.3 minutes; the nearest star is ~4.2 light-years away.",
        "inputs": {
            "unit": "au",
            "distance": 1
        },
        "distance_m": 149597870700,
        "travel_time": {
            "days": 0.0057755183,
            "hours": 0.13861244,
            "years": 1.5812507e-5,
            "minutes": 8.3167464,
            "seconds": 499.004784
        }
    },
    "meta": {
        "timestamp": "2026-06-05T19:50:33.316Z",
        "request_id": "9a63faa3-e7c6-466c-8c01-3363af508750"
    },
    "status": "ok",
    "message": "Light travel time",
    "success": true
}
```

### Meta

#### `GET /v1/meta` — Spec

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

**Response:**
```json
{
    "data": {
        "notes": "Distance units: m, km, mi, au, ly (light-year), pc (parsec), ls (light-second), lm (light-minute). Time units: s, min, h, day, year. c = 299,792,458 m/s exactly.",
        "service": "lighttime-api",
        "constants": {
            "speed_of_light_ms": 299792458
        },
        "endpoints": {
            "GET /v1/meta": "This document.",
            "GET /v1/distance": "Distance light covers in a time (s, min, h, day, year).",
            "GET /v1/round-trip": "One-way and round-trip light/communication delay to a target.",
            "GET /v1/travel-time": "Light travel time from a distance (m, km, mi, au, ly, pc, light-second/minute)."
        },
        "description": "Light-travel-time calculator: the time light takes to cross a distance, the distance light covers in a time, and the one-way and round-trip communication delay to a target."
    },
    "meta": {
        "timestamp": "2026-06-05T19:50:33.447Z",
        "request_id": "694f9a85-fc14-43f1-8ca3-852d0cd42eef"
    },
    "status": "ok",
    "message": "Meta",
    "success": true
}
```


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