# Momentum & Collision API
> Linear momentum, impulse and one-dimensional collisions as an API, computed locally and deterministically. The momentum endpoint computes the linear momentum p = m·v of a moving body, with its kinetic energy, and solves for whichever of the mass, velocity or momentum you leave out. The impulse endpoint applies the impulse-momentum theorem, J = F·Δt = m·Δv = Δp: from a force and a time it gives the impulse and, with a mass, the change in velocity; or from a mass and a velocity change it gives the impulse and the average force over a contact time — the physics of a bat hitting a ball or an airbag softening a crash. The collision endpoint solves a head-on collision between two bodies using conservation of momentum and a coefficient of restitution: e = 1 for a perfectly elastic collision (kinetic energy conserved), e = 0 for a perfectly inelastic one (the bodies stick together), or any value between for a partially inelastic collision — returning both final velocities, the conserved total momentum, the kinetic energy before and after, and the energy lost. Everything is computed locally and deterministically, so it is instant and private. Ideal for physics-education and simulation tools, game and ballistics engines, vehicle-crash and sports apps, and engineering-dynamics software. Pure local computation — no key, no third-party service, instant. Live, nothing stored. 3 endpoints. This is linear momentum and collisions; for rotational angular momentum and flywheel energy use a flywheel 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/momentum-api/..."
```

## Pricing
- **Free** (Free) — 3,000 calls/Mo, 2 req/s
- **Starter** ($5/Mo) — 40,000 calls/Mo, 5 req/s
- **Pro** ($15/Mo) — 250,000 calls/Mo, 15 req/s
- **Mega** ($49/Mo) — 1,595,000 calls/Mo, 50 req/s

## Endpoints

### Momentum

#### `GET /v1/collision` — 1D two-body collision

**Parameters:**
- `mass1` (query, required, string) — Mass 1 (kg) Example: `2`
- `velocity1` (query, required, string) — Initial velocity 1 (m/s) Example: `3`
- `mass2` (query, required, string) — Mass 2 (kg) Example: `1`
- `velocity2` (query, required, string) — Initial velocity 2 (m/s) Example: `-1`
- `type` (query, optional, string) — elastic | inelastic Example: `elastic`
- `restitution` (query, optional, string) — Or coefficient of restitution e (0–1)

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/momentum-api/v1/collision?mass1=2&velocity1=3&mass2=1&velocity2=-1&type=elastic"
```

**Response:**
```json
{
    "data": {
        "formula": "momentum is conserved; v' from restitution e (1 elastic, 0 inelastic).",
        "mass1_kg": 2,
        "mass2_kg": 1,
        "restitution": 1,
        "collision_type": "perfectly elastic",
        "velocity1_final_ms": 0.333333,
        "velocity2_final_ms": 4.333333,
        "total_momentum_kg_ms": 5,
        "velocity1_initial_ms": 3,
        "velocity2_initial_ms": -1,
        "kinetic_energy_lost_j": 0,
        "kinetic_energy_after_j": 9.5,
        "kinetic_energy_before_j": 9.5
    },
    "meta": {
        "timestamp": "2026-06-04T10:18:44.907Z",
        "request_id": "2a2c600b-a66d-4cc6-960e-664797f615d7"
    },
    "status": "ok",
    "message": "1D two-body collision",
    "success": true
}
```

#### `GET /v1/impulse` — Impulse-momentum theorem

**Parameters:**
- `force` (query, optional, string) — Force (N) Example: `10`
- `time` (query, optional, string) — Contact time Δt (s) Example: `2`
- `impulse` (query, optional, string) — Or impulse J (N·s)
- `mass` (query, optional, string) — Mass (kg) for velocity change Example: `4`
- `delta_v` (query, optional, string) — Or velocity change Δv (m/s)
- `initial_velocity` (query, optional, string) — Initial velocity for final velocity

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/momentum-api/v1/impulse?force=10&time=2&mass=4"
```

**Response:**
```json
{
    "data": {
        "time_s": 2,
        "force_n": 10,
        "formula": "J = F·Δt = m·Δv = Δp.",
        "mass_kg": 4,
        "impulse_ns": 20,
        "velocity_change_ms": 5
    },
    "meta": {
        "timestamp": "2026-06-04T10:18:45.006Z",
        "request_id": "ba9860c8-f37a-4148-9b74-04dec7f5ceee"
    },
    "status": "ok",
    "message": "Impulse-momentum theorem",
    "success": true
}
```

#### `GET /v1/momentum` — Linear momentum

**Parameters:**
- `mass` (query, optional, string) — Mass (kg) Example: `2`
- `velocity` (query, optional, string) — Velocity (m/s) Example: `5`
- `momentum` (query, optional, string) — Or momentum (kg·m/s) to solve another

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/momentum-api/v1/momentum?mass=2&velocity=5"
```

**Response:**
```json
{
    "data": {
        "formula": "p = m·v.",
        "mass_kg": 2,
        "velocity_ms": 5,
        "momentum_kg_ms": 10,
        "kinetic_energy_j": 25
    },
    "meta": {
        "timestamp": "2026-06-04T10:18:45.104Z",
        "request_id": "14e2ecd9-585e-4ada-9004-6c645bca4244"
    },
    "status": "ok",
    "message": "Linear momentum",
    "success": true
}
```

### Meta

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

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

**Response:**
```json
{
    "data": {
        "api": "momentum",
        "note": "Linear momentum, impulse & 1D collisions — computed locally and deterministically, no key, no third-party service.",
        "endpoints": [
            "/v1/momentum",
            "/v1/impulse",
            "/v1/collision",
            "/v1/meta"
        ]
    },
    "meta": {
        "timestamp": "2026-06-04T10:18:45.217Z",
        "request_id": "d88022d8-3d70-4acb-934a-94cc0be8db30"
    },
    "status": "ok",
    "message": "Meta",
    "success": true
}
```


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