# Hooke's Law & Spring API
> Hooke's law and elastic potential energy as an API, computed locally and deterministically. The hooke endpoint applies F = k·x — the restoring force of a spring equals its spring constant times the extension — and solves for whichever of the force, the spring constant or the displacement you leave out, also returning the elastic potential energy ½·k·x². The energy endpoint computes the elastic potential energy E = ½·k·x² stored in a stretched or compressed spring, solves the extension from a stored energy, and finds the work done in stretching a spring from one extension to another, W = ½·k·(x2² − x1²). The combine endpoint combines springs: in series the assembly is softer, 1/k = Σ 1/kᵢ, and in parallel it is stiffer, k = Σ kᵢ — the spring equivalent of resistors in a circuit. Everything is computed locally and deterministically, so it is instant and private. Ideal for physics and mechanics-education tools, spring and suspension design, mechanism and gadget engineering, and simulation software. Pure local computation — no key, no third-party service, instant. Live, nothing stored. 3 endpoints. This is the force-extension law and elastic energy; for the spring rate of a helical coil from its geometry use a spring-coil API and for spring-mass natural frequency use a vibration 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/hooke-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, 20 req/s
- **Mega** ($49/Mo) — 1,509,000 calls/Mo, 60 req/s

## Endpoints

### Spring

#### `GET /v1/combine` — Springs in series/parallel

**Parameters:**
- `spring_constants` (query, required, string) — Spring constants, e.g. 200,300 Example: `200,300`
- `arrangement` (query, optional, string) — series | parallel (default series) Example: `series`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/hooke-api/v1/combine?spring_constants=200%2C300&arrangement=series"
```

**Response:**
```json
{
    "data": {
        "count": 2,
        "formula": "series: 1/k = Σ 1/kᵢ (softer than the softest spring).",
        "arrangement": "series",
        "spring_constants_n_m": [
            200,
            300
        ],
        "combined_spring_constant_n_m": 120
    },
    "meta": {
        "timestamp": "2026-06-04T10:18:43.577Z",
        "request_id": "53ab19b5-5b81-43bc-aea6-c47299200778"
    },
    "status": "ok",
    "message": "Springs in series/parallel",
    "success": true
}
```

#### `GET /v1/energy` — Elastic potential energy

**Parameters:**
- `spring_constant` (query, required, string) — Spring constant k (N/m) Example: `200`
- `displacement` (query, optional, string) — Displacement x (m) Example: `0.05`
- `energy` (query, optional, string) — Or energy (J) to solve displacement
- `initial_displacement` (query, optional, string) — Initial x for work done
- `final_displacement` (query, optional, string) — Final x for work done

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/hooke-api/v1/energy?spring_constant=200&displacement=0.05"
```

**Response:**
```json
{
    "data": {
        "force_n": 10,
        "formula": "E = ½·k·x².",
        "displacement_m": 0.05,
        "spring_constant_n_m": 200,
        "elastic_potential_energy_j": 0.25
    },
    "meta": {
        "timestamp": "2026-06-04T10:18:43.677Z",
        "request_id": "dde23396-623a-4f0f-880f-9aebb3170ea8"
    },
    "status": "ok",
    "message": "Elastic potential energy",
    "success": true
}
```

#### `GET /v1/hooke` — Hooke's law F = k·x

**Parameters:**
- `force` (query, optional, string) — Force (N)
- `spring_constant` (query, optional, string) — Spring constant k (N/m) Example: `200`
- `displacement` (query, optional, string) — Displacement x (m) Example: `0.05`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/hooke-api/v1/hooke?spring_constant=200&displacement=0.05"
```

**Response:**
```json
{
    "data": {
        "force_n": 10,
        "formula": "F = k·x; elastic PE = ½·k·x².",
        "displacement_m": 0.05,
        "spring_constant_n_m": 200,
        "elastic_potential_energy_j": 0.25
    },
    "meta": {
        "timestamp": "2026-06-04T10:18:43.787Z",
        "request_id": "9737269e-c107-486a-89dd-df59be54b277"
    },
    "status": "ok",
    "message": "Hooke's law F = k·x",
    "success": true
}
```

### Meta

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

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

**Response:**
```json
{
    "data": {
        "api": "hooke",
        "note": "Hooke's law & elastic potential energy — computed locally and deterministically, no key, no third-party service.",
        "endpoints": [
            "/v1/hooke",
            "/v1/energy",
            "/v1/combine",
            "/v1/meta"
        ]
    },
    "meta": {
        "timestamp": "2026-06-04T10:18:43.882Z",
        "request_id": "5073e7ae-e2f1-4cb1-9a91-b807d016565d"
    },
    "status": "ok",
    "message": "Meta",
    "success": true
}
```


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