# Roller Chain Drive API
> Roller-chain drive maths as an API, computed locally and deterministically — the chain-length, sprocket and speed numbers a machine designer or millwright lays out a drive with. The chain-length endpoint gives the chain in pitches from the two sprocket tooth counts, the chain pitch and the centre distance: L = 2·C + (N1+N2)/2 + ((N2−N1)/2π)² ÷ C (C in pitches), rounded UP to an even number so the chain closes without an offset link — a 17- and 34-tooth pair at 15-inch centres on #40 (half-inch) chain comes to 86 pitches, 43 inches. The sprocket endpoint gives the pitch diameter, pitch ÷ sin(180°/teeth), and the outside diameter — a 17-tooth #40 sprocket has a 2.72-inch pitch circle. The speed endpoint gives the chain's linear speed, pitch × teeth × rpm ÷ 12, so a 17-tooth #40 sprocket at 100 rpm runs the chain at about 71 ft/min. Everything is computed locally and deterministically, so it is instant and private. Ideal for machine-design and drivetrain apps, conveyor and equipment-build tools, maker and CAD calculators, and engineering aids. Pure local computation — no key, no third-party service, instant. Live, nothing stored. 3 compute endpoints. For gear ratios use a gear-ratio API; for belts use a pulley 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/chaindrive-api/..."
```

## Pricing
- **Free** (Free) — 490 calls/Mo, 2 req/s
- **Starter** ($6/Mo) — 12,900 calls/Mo, 6 req/s
- **Pro** ($18/Mo) — 81,000 calls/Mo, 15 req/s
- **Mega** ($52/Mo) — 264,000 calls/Mo, 36 req/s

## Endpoints

### Chain

#### `GET /v1/chain-length` — Chain length from sprockets & centre

**Parameters:**
- `driver_teeth` (query, required, string) — Driver sprocket teeth Example: `17`
- `driven_teeth` (query, required, string) — Driven sprocket teeth Example: `34`
- `pitch_in` (query, required, string) — Chain pitch in inches (#40 = 0.5) Example: `0.5`
- `center_distance_in` (query, required, string) — Centre distance in inches Example: `15`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/chaindrive-api/v1/chain-length?driver_teeth=17&driven_teeth=34&pitch_in=0.5&center_distance_in=15"
```

**Response:**
```json
{
    "data": {
        "note": "Chain length in pitches = 2·C + (N1+N2)/2 + ((N2−N1)/2π)² ÷ C, with C the centre distance in pitches — then round UP to an even number so the chain closes without an offset link. The slack side should sag on the bottom; if you can't get an even count at the exact centre, nudge the centre distance or add a tensioner.",
        "inputs": {
            "pitch_in": 0.5,
            "driven_teeth": 34,
            "driver_teeth": 17,
            "center_distance_in": 15
        },
        "exact_pitches": 85.74,
        "chain_length_in": 43,
        "chain_length_pitches": 86
    },
    "meta": {
        "timestamp": "2026-06-06T23:53:58.407Z",
        "request_id": "b31b466d-b076-4dec-a898-9bcea2016ce1"
    },
    "status": "ok",
    "message": "Chain length",
    "success": true
}
```

#### `GET /v1/speed` — Chain linear speed

**Parameters:**
- `teeth` (query, required, string) — Sprocket teeth Example: `17`
- `pitch_in` (query, required, string) — Chain pitch in inches Example: `0.5`
- `rpm` (query, required, string) — Sprocket speed in rpm Example: `100`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/chaindrive-api/v1/speed?teeth=17&pitch_in=0.5&rpm=100"
```

**Response:**
```json
{
    "data": {
        "note": "Chain speed = pitch × teeth × rpm ÷ 12 (the sprocket's pitch circumference per turn). Standard roller chain is happy up to a few thousand ft/min; beyond that you need better lubrication and finer pitch to control wear and noise. Faster chain at the same power means lower tension and a longer life.",
        "inputs": {
            "rpm": 100,
            "teeth": 17,
            "pitch_in": 0.5
        },
        "chain_speed_ft_s": 1.18,
        "chain_speed_ft_min": 70.8
    },
    "meta": {
        "timestamp": "2026-06-06T23:53:58.513Z",
        "request_id": "07bef5ec-893b-45f7-b205-3869ec9a64e1"
    },
    "status": "ok",
    "message": "Chain speed",
    "success": true
}
```

#### `GET /v1/sprocket` — Sprocket pitch & outside diameter

**Parameters:**
- `teeth` (query, required, string) — Number of teeth Example: `17`
- `pitch_in` (query, required, string) — Chain pitch in inches Example: `0.5`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/chaindrive-api/v1/sprocket?teeth=17&pitch_in=0.5"
```

**Response:**
```json
{
    "data": {
        "note": "Pitch diameter = pitch ÷ sin(180°/teeth) — the circle the chain pins ride on. The outside (tip) diameter is a touch larger, ≈ pitch × (0.6 + cot(180°/teeth)). More teeth runs smoother and quieter with less 'chordal' speed variation; keep the small sprocket to 17+ teeth where you can.",
        "inputs": {
            "teeth": 17,
            "pitch_in": 0.5
        },
        "pitch_diameter_in": 2.721,
        "outside_diameter_in": 2.975
    },
    "meta": {
        "timestamp": "2026-06-06T23:53:58.596Z",
        "request_id": "6b4e2824-a9e8-4926-980e-15b4215e70f1"
    },
    "status": "ok",
    "message": "Sprocket diameter",
    "success": true
}
```

### Meta

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

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

**Response:**
```json
{
    "data": {
        "notes": "US units (inches, teeth, rpm). L = 2C + (N1+N2)/2 + ((N2−N1)/2π)²/C (round up to even); PCD = pitch/sin(180°/N); speed = pitch·teeth·rpm/12. ANSI #40 = 0.5\" pitch. For gear ratios use a gear-ratio API; for belts use a pulley API.",
        "service": "chaindrive-api",
        "endpoints": {
            "GET /v1/meta": "This document.",
            "GET /v1/speed": "Chain linear speed from teeth, pitch and rpm.",
            "GET /v1/sprocket": "Sprocket pitch and outside diameter from teeth and pitch.",
            "GET /v1/chain-length": "Chain length (pitches & inches) from sprocket teeth, pitch and centre distance."
        },
        "description": "Roller-chain drive maths: chain length from sprockets and centre distance, sprocket pitch/outside diameter, and chain linear speed."
    },
    "meta": {
        "timestamp": "2026-06-06T23:53:58.683Z",
        "request_id": "ca8c53ab-0388-4d6a-b452-c4c0b48cd93b"
    },
    "status": "ok",
    "message": "Meta",
    "success": true
}
```


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