# Shaft Torsion API
> Shaft torsion as an API, computed locally and deterministically. The stress endpoint computes the maximum torsional shear stress in a circular shaft, τ = T·r/J — torque times the outer radius divided by the polar moment of inertia — for a solid shaft (J = π·d⁴/32) or a hollow tube (J = π·(D⁴−d⁴)/32), and solves the torque a shaft can carry for an allowable stress. The twist endpoint computes the angle of twist along the shaft, θ = T·L/(G·J), in radians and degrees, from the torque, length and the shear modulus (given directly or from a built-in material table — steel, aluminium, copper, titanium and more), plus the torsional stiffness G·J/L. The power endpoint relates the power a rotating shaft transmits to its torque and speed, P = T·ω = T·2πN/60, and solves any of the three, reporting power in watts, kilowatts and horsepower. Everything is computed locally and deterministically, so it is instant and private. Ideal for mechanical and drivetrain engineering tools, shaft, axle and coupling design, motor and gearbox apps, and machine-design education. Pure local computation — no key, no third-party service, instant. Live, nothing stored. 3 endpoints. This is circular-shaft torsion; for axial stress-strain use a Young's-modulus API and for the 2D stress state use a Mohr-circle 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/torsion-api/..."
```

## Pricing
- **Free** (Free) — 2,000 calls/Mo, 2 req/s
- **Starter** ($9/Mo) — 18,000 calls/Mo, 5 req/s
- **Pro** ($24/Mo) — 120,000 calls/Mo, 15 req/s
- **Mega** ($74/Mo) — 600,000 calls/Mo, 40 req/s

## Endpoints

### Torsion

#### `GET /v1/power` — Shaft power P = T·ω

**Parameters:**
- `torque` (query, optional, string) — Torque T (N·m) Example: `1000`
- `rpm` (query, optional, string) — Rotational speed (rpm) Example: `1500`
- `omega` (query, optional, string) — Or angular velocity (rad/s)
- `power` (query, optional, string) — Or power (W) to solve torque/speed

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/torsion-api/v1/power?torque=1000&rpm=1500"
```

**Response:**
```json
{
    "data": {
        "rpm": 1500,
        "formula": "P = T·ω = T·2πN/60.",
        "power_w": 157079.632679,
        "power_hp": 210.64725713,
        "power_kw": 157.07963268,
        "torque_nm": 1000,
        "angular_velocity_rad_s": 157.079633
    },
    "meta": {
        "timestamp": "2026-06-04T10:18:41.506Z",
        "request_id": "f9f61cdf-225c-4478-b369-15e90ed7fb23"
    },
    "status": "ok",
    "message": "Shaft power P = T·ω",
    "success": true
}
```

#### `GET /v1/stress` — Torsional shear stress

**Parameters:**
- `torque` (query, optional, string) — Torque T (N·m) Example: `1000`
- `diameter` (query, optional, string) — Solid shaft diameter (m) Example: `0.05`
- `outer_diameter` (query, optional, string) — Hollow outer diameter (m)
- `inner_diameter` (query, optional, string) — Hollow inner diameter (m)
- `shear_stress` (query, optional, string) — Or allowable shear stress (Pa) to solve torque

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/torsion-api/v1/stress?torque=1000&diameter=0.05"
```

**Response:**
```json
{
    "data": {
        "formula": "τ = T·r/J; J = π·d⁴/32 (solid) or π·(D⁴−d⁴)/32 (hollow).",
        "torque_nm": 1000,
        "shaft_type": "solid",
        "outer_radius_m": 0.025,
        "max_shear_stress": {
            "mpa": 40.74366543,
            "pascal": 40743665.4315
        },
        "polar_moment_of_inertia_m4": 6.135923151542566e-7
    },
    "meta": {
        "timestamp": "2026-06-04T10:18:41.613Z",
        "request_id": "9615c1c2-85d3-4bfd-a4a1-a2ec76801d57"
    },
    "status": "ok",
    "message": "Torsional shear stress",
    "success": true
}
```

#### `GET /v1/twist` — Angle of twist

**Parameters:**
- `torque` (query, required, string) — Torque T (N·m) Example: `1000`
- `length` (query, required, string) — Shaft length L (m) Example: `2`
- `diameter` (query, optional, string) — Solid shaft diameter (m) Example: `0.05`
- `outer_diameter` (query, optional, string) — Hollow outer diameter (m)
- `inner_diameter` (query, optional, string) — Hollow inner diameter (m)
- `material` (query, optional, string) — Material for shear modulus G Example: `steel`
- `shear_modulus_gpa` (query, optional, string) — Or shear modulus (GPa)

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/torsion-api/v1/twist?torque=1000&length=2&diameter=0.05&material=steel"
```

**Response:**
```json
{
    "data": {
        "formula": "θ = T·L/(G·J); stiffness k = G·J/L.",
        "length_m": 2,
        "torque_nm": 1000,
        "shaft_type": "solid",
        "shear_modulus_gpa": 79.3,
        "angle_of_twist_deg": 2.35504673,
        "angle_of_twist_rad": 0.0411033195,
        "polar_moment_of_inertia_m4": 6.135923151542566e-7,
        "torsional_stiffness_nm_rad": 24328.9353
    },
    "meta": {
        "timestamp": "2026-06-04T10:18:41.716Z",
        "request_id": "b6475eb3-a301-498e-9da1-237952e80f0b"
    },
    "status": "ok",
    "message": "Angle of twist",
    "success": true
}
```

### Meta

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

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

**Response:**
```json
{
    "data": {
        "api": "torsion",
        "note": "Shaft torsion (shear stress, angle of twist, transmitted power) — computed locally and deterministically, no key, no third-party service.",
        "endpoints": [
            "/v1/stress",
            "/v1/twist",
            "/v1/power",
            "/v1/meta"
        ],
        "materials": [
            "steel",
            "stainless_steel",
            "aluminium",
            "aluminum",
            "copper",
            "brass",
            "bronze",
            "titanium",
            "cast_iron",
            "magnesium",
            "glass",
            "nylon"
        ]
    },
    "meta": {
        "timestamp": "2026-06-04T10:18:41.820Z",
        "request_id": "ecb30eb0-c42c-4df9-8bcd-98079956d9cd"
    },
    "status": "ok",
    "message": "Meta",
    "success": true
}
```


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