# Roller Chain Drive API
> Roller-chain power-transmission maths as an API, computed locally and deterministically. The ratio endpoint computes a chain drive's speed ratio (driven ÷ driver teeth), the output rpm and torque multiplier, the chain (line) velocity v = N·p·rpm/60 and the pitch diameter of each sprocket, PD = p/sin(π/N), from the driver and driven tooth counts, the input speed and the chain pitch. The length endpoint computes the chain length in pitches and then rounds it up to an even number of links — links must come in pairs — using L = 2C/p + (N1+N2)/2 + ((N2−N1)/2π)²·p/C from the tooth counts, the centre distance and the pitch. The center-distance endpoint inverts that relation to give the exact centre distance for a chosen even link count, C = (p/8)·[(2L−N1−N2) + √((2L−N1−N2)² − 8·((N2−N1)/2π)²)]. Tooth counts are integers, pitch and centre distance in metres (the default pitch 0.0127 m is ANSI 40, ½ inch) and speeds in rpm. Everything is computed locally and deterministically, so it is instant and private. Ideal for mechanical, machine-design, conveyor, motorcycle and industrial-equipment app developers, sprocket-sizing and chain-selection tools, and engineering education. Pure local computation — no key, no third-party service, instant. Live, nothing stored. 3 endpoints. This is industrial roller-chain drives; for bicycle gearing use a bike-gear API and for belt or gear ratios a gear-ratio 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/chain-api/..."
```

## Pricing
- **Free** (Free) — 2,620 calls/Mo, 2 req/s
- **Starter** ($9/Mo) — 38,800 calls/Mo, 6 req/s
- **Pro** ($23/Mo) — 251,000 calls/Mo, 15 req/s
- **Mega** ($71/Mo) — 1,670,000 calls/Mo, 40 req/s

## Endpoints

### Chain

#### `GET /v1/center-distance` — Centre distance

**Parameters:**
- `driver_teeth` (query, required, string) — Driver teeth Example: `17`
- `driven_teeth` (query, required, string) — Driven teeth Example: `42`
- `links` (query, required, string) — Chain length (even links) Example: `110`
- `pitch` (query, optional, string) — Chain pitch (m) Example: `0.0127`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/chain-api/v1/center-distance?driver_teeth=17&driven_teeth=42&links=110&pitch=0.0127"
```

**Response:**
```json
{
    "data": {
        "note": "Centre distance C = (p/8)·[(2L−N1−N2) + √((2L−N1−N2)² − 8·((N2−N1)/2π)²)] for a given even link count L.",
        "inputs": {
            "links": 110,
            "pitch_m": 0.0127,
            "driven_teeth": 42,
            "driver_teeth": 17
        },
        "center_distance_m": 0.51055,
        "center_distance_mm": 510.5498
    },
    "meta": {
        "timestamp": "2026-06-05T11:30:25.740Z",
        "request_id": "9ecefe3e-4c51-4f27-bf96-0c2e91d95ea0"
    },
    "status": "ok",
    "message": "Center distance",
    "success": true
}
```

#### `GET /v1/length` — Chain length

**Parameters:**
- `driver_teeth` (query, required, string) — Driver teeth Example: `17`
- `driven_teeth` (query, required, string) — Driven teeth Example: `42`
- `center_distance` (query, required, string) — Centre distance (m) Example: `0.5`
- `pitch` (query, optional, string) — Chain pitch (m) Example: `0.0127`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/chain-api/v1/length?driver_teeth=17&driven_teeth=42&center_distance=0.5&pitch=0.0127"
```

**Response:**
```json
{
    "data": {
        "note": "Chain length in pitches L = 2C/p + (N1+N2)/2 + ((N2−N1)/2π)²·p/C, rounded up to an even number of links (links must be even). The actual centre distance is slightly less than requested.",
        "inputs": {
            "pitch_m": 0.0127,
            "driven_teeth": 42,
            "driver_teeth": 17,
            "center_distance_m": 0.5
        },
        "length_m": 1.397,
        "length_links": 110,
        "length_pitches": 108.6423
    },
    "meta": {
        "timestamp": "2026-06-05T11:30:25.852Z",
        "request_id": "e957aed6-f019-46f7-9b4a-ca7dfc5c206e"
    },
    "status": "ok",
    "message": "Chain length",
    "success": true
}
```

#### `GET /v1/ratio` — Chain ratio & velocity

**Parameters:**
- `driver_teeth` (query, required, string) — Driver sprocket teeth Example: `17`
- `driven_teeth` (query, required, string) — Driven sprocket teeth Example: `42`
- `input_rpm` (query, optional, string) — Input speed (rpm) Example: `1000`
- `pitch` (query, optional, string) — Chain pitch (m) Example: `0.0127`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/chain-api/v1/ratio?driver_teeth=17&driven_teeth=42&input_rpm=1000&pitch=0.0127"
```

**Response:**
```json
{
    "data": {
        "note": "Speed ratio = driven/driver teeth. Output torque is multiplied by the ratio; output speed is divided by it. Pitch diameter PD = p/sin(π/N).",
        "inputs": {
            "pitch_m": 0.0127,
            "driven_teeth": 42,
            "driver_teeth": 17
        },
        "output_rpm": 404.761905,
        "speed_ratio": 2.470588,
        "chain_velocity_ms": 3.598333,
        "torque_multiplier": 2.470588,
        "driven_pitch_diameter_m": 0.169945,
        "driver_pitch_diameter_m": 0.069116
    },
    "meta": {
        "timestamp": "2026-06-05T11:30:25.925Z",
        "request_id": "a25998b3-5e59-4160-bc4f-56a4a22bbe35"
    },
    "status": "ok",
    "message": "Chain ratio",
    "success": true
}
```

### Meta

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

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

**Response:**
```json
{
    "data": {
        "notes": "Teeth counts are integers, pitch and centre distance in m (default pitch 0.0127 m = ANSI 40, ½\"). Link counts must be even.",
        "service": "chain-api",
        "formulae": {
            "ratio": "ratio = N2/N1 ; v = N·p·rpm/60",
            "length": "L = 2C/p + (N1+N2)/2 + ((N2−N1)/2π)²·p/C",
            "pitch_diameter": "PD = p/sin(π/N)"
        },
        "endpoints": {
            "GET /v1/meta": "This document.",
            "GET /v1/ratio": "Speed ratio, output rpm, chain velocity and pitch diameters from sprocket teeth.",
            "GET /v1/length": "Chain length in pitches and even links from the centre distance.",
            "GET /v1/center-distance": "Centre distance for a given even number of links."
        },
        "description": "Roller-chain drive calculator: speed ratio, chain velocity and pitch diameters; chain length in links from the centre distance; and the centre distance for a chosen link count."
    },
    "meta": {
        "timestamp": "2026-06-05T11:30:26.013Z",
        "request_id": "b4e9de70-0139-4af4-be6e-563da488a2b5"
    },
    "status": "ok",
    "message": "Meta",
    "success": true
}
```


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