# Spring Coil API
> Helical compression-spring maths as an API, computed locally and deterministically. The rate endpoint computes the spring rate from the wire diameter, the mean coil diameter and the number of active coils using k = G·d⁴/(8·D³·n), where the shear modulus G is taken from the material (music wire and spring steel, stainless, phosphor bronze, beryllium copper, titanium and more) or supplied directly — and it reports the rate in newtons per millimetre, newtons per metre and pounds per inch, along with the spring index C = D/d. The force endpoint relates force and deflection through F = k·x in both directions, taking the rate directly or deriving it from the geometry. The stress endpoint computes the shear stress in the wire, τ = 8·F·D·Kw/(π·d³), applying the Wahl correction factor Kw = (4C−1)/(4C−4) + 0.615/C for curvature and direct shear, and also reports the uncorrected stress. Lengths are in millimetres, force in newtons and stress in megapascals. Everything is computed locally and deterministically, so it is instant and private. A design aid — keep the spring index between about 4 and 12 and confirm against the material's allowable stress. Ideal for mechanical-design and CAD tools, spring-selection and prototyping apps, maker and robotics projects, and engineering calculators. Pure local computation — no key, no third-party service, instant. Live, nothing stored. 3 endpoints. This is helical-spring design; for beam deflection use a beam 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/springcoil-api/..."
```

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

## Endpoints

### Spring

#### `GET /v1/force` — Force ↔ deflection

**Parameters:**
- `spring_rate` (query, optional, string) — Spring rate k (N/mm) Example: `2`
- `wire_diameter` (query, optional, string) — Or geometry: wire d
- `mean_diameter` (query, optional, string) — mean D
- `active_coils` (query, optional, string) — active coils n
- `deflection` (query, optional, string) — Deflection x mm (to get force) Example: `10`
- `force` (query, optional, string) — Or force N (to get deflection)
- `material` (query, optional, string) — Material (with geometry)

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/springcoil-api/v1/force?spring_rate=2&deflection=10"
```

**Response:**
```json
{
    "data": {
        "mode": "deflection_to_force",
        "note": "F = k · x. Provide a spring_rate, or the geometry (wire_diameter, mean_diameter, active_coils) to derive it.",
        "force_N": 20,
        "deflection_mm": 10,
        "spring_rate_N_per_mm": 2
    },
    "meta": {
        "timestamp": "2026-06-04T01:59:05.354Z",
        "request_id": "bd679c73-f764-4a82-bae9-8cd73b8f26cc"
    },
    "status": "ok",
    "message": "Force <-> deflection",
    "success": true
}
```

#### `GET /v1/rate` — Spring rate from geometry

**Parameters:**
- `wire_diameter` (query, required, string) — Wire diameter d (mm) Example: `2`
- `mean_diameter` (query, required, string) — Mean coil diameter D (mm) Example: `20`
- `active_coils` (query, required, string) — Active coils n Example: `10`
- `material` (query, optional, string) — music_wire|stainless_steel|… (default music_wire) Example: `music_wire`
- `shear_modulus` (query, optional, string) — Or explicit G (MPa)

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/springcoil-api/v1/rate?wire_diameter=2&mean_diameter=20&active_coils=10&material=music_wire"
```

**Response:**
```json
{
    "data": {
        "note": "Spring index C = D/d; aim for 4–12. Rate in newtons per millimetre of deflection.",
        "formula": "k = G·d⁴ / (8·D³·n).",
        "material": "music_wire",
        "spring_rate": {
            "N_per_m": 1982.5,
            "N_per_mm": 1.9825,
            "lb_per_in": 11.32037
        },
        "active_coils": 10,
        "spring_index": 10,
        "mean_diameter_mm": 20,
        "wire_diameter_mm": 2,
        "shear_modulus_mpa": 79300
    },
    "meta": {
        "timestamp": "2026-06-04T01:59:05.441Z",
        "request_id": "df41c044-e46a-4035-ab0f-3eeddd50f5c0"
    },
    "status": "ok",
    "message": "Spring rate from geometry",
    "success": true
}
```

#### `GET /v1/stress` — Wire shear stress (Wahl)

**Parameters:**
- `wire_diameter` (query, required, string) — Wire diameter d (mm) Example: `2`
- `mean_diameter` (query, required, string) — Mean diameter D (mm) Example: `20`
- `force` (query, optional, string) — Force N Example: `19.825`
- `deflection` (query, optional, string) — Or deflection x (with rate/coils)
- `active_coils` (query, optional, string) — Active coils (to derive force)
- `material` (query, optional, string) — Material

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/springcoil-api/v1/stress?wire_diameter=2&mean_diameter=20&force=19.825"
```

**Response:**
```json
{
    "data": {
        "note": "τ = 8·F·D·Kw / (π·d³). Wahl factor Kw = (4C−1)/(4C−4) + 0.615/C accounts for curvature and direct shear.",
        "force_N": 19.825,
        "wahl_factor": 1.14483,
        "spring_index": 10,
        "shear_factor_Ks": 1.05,
        "mean_diameter_mm": 20,
        "shear_stress_mpa": 144.489,
        "wire_diameter_mm": 2,
        "shear_stress_uncorrected_mpa": 126.21
    },
    "meta": {
        "timestamp": "2026-06-04T01:59:05.536Z",
        "request_id": "9786b128-4675-4262-9fb6-82160d8b0bf6"
    },
    "status": "ok",
    "message": "Wire shear stress (Wahl)",
    "success": true
}
```

### Meta

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

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

**Response:**
```json
{
    "data": {
        "api": "springcoil",
        "note": "Helical compression-spring maths — computed locally and deterministically, no key, no third-party service. mm / N / MPa.",
        "endpoints": [
            "/v1/rate",
            "/v1/force",
            "/v1/stress",
            "/v1/meta"
        ],
        "materials": [
            "music_wire",
            "steel",
            "spring_steel",
            "stainless_steel",
            "phosphor_bronze",
            "beryllium_copper",
            "brass",
            "titanium",
            "inconel",
            "monel"
        ]
    },
    "meta": {
        "timestamp": "2026-06-04T01:59:05.613Z",
        "request_id": "ca08f244-6b80-4f21-939a-56b43f36d2da"
    },
    "status": "ok",
    "message": "Meta",
    "success": true
}
```


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