# Chainmaille API
> Chainmaille maths as an API, computed locally and deterministically — the aspect-ratio and ring numbers a maille artist weaves to. The aspect endpoint computes the all-important Aspect Ratio = inner diameter ÷ wire diameter, and solves for whichever of the three you are missing, then lists the weaves that ring will make: AR, not absolute size, decides everything — too low and the rings won’t close through each other, too high and the weave goes floppy, so a 6.4 mm ID on 1.6 mm wire is AR 4.0, good for European 4-in-1, Byzantine, box chain and more. The ring endpoint does the material maths: wire per ring ≈ π × (inner diameter + wire diameter) — the mean-diameter circumference — so those AR-4 rings take about 25 mm of wire each and weigh roughly 0.4 g in steel; pass a wire length to get how many rings it yields, or a ring count to get the total wire and weight, in any of nine metals from aluminium to silver. Everything is computed locally and deterministically, so it is instant and private. Ideal for chainmaille, jewelry, cosplay-armour and maker app developers, ring-buying and project-estimator tools, and craft software. Pure local computation — no key, no third-party service, instant. Dimensions in mm. Live, nothing stored. 2 compute endpoints. For wire-gauge ↔ mm use a wire-gauge 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/chainmaille-api/..."
```

## Pricing
- **Free** (Free) — 6,720 calls/Mo, 2 req/s
- **Starter** ($4/Mo) — 57,400 calls/Mo, 6 req/s
- **Pro** ($12/Mo) — 232,500 calls/Mo, 15 req/s
- **Mega** ($36/Mo) — 1,356,000 calls/Mo, 40 req/s

## Endpoints

### Chainmaille

#### `GET /v1/aspect` — Aspect ratio + weaves

**Parameters:**
- `inner_diameter` (query, optional, string) — Inner diameter (mm) Example: `6.4`
- `wire_diameter` (query, optional, string) — Wire diameter (mm) Example: `1.6`
- `aspect_ratio` (query, optional, string) — Aspect ratio (provide any two)

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/chainmaille-api/v1/aspect?inner_diameter=6.4&wire_diameter=1.6"
```

**Response:**
```json
{
    "data": {
        "note": "Aspect Ratio = inner diameter ÷ wire diameter. It, not absolute size, decides which weaves work: too low and rings won't close through each other, too high and the weave is floppy. European 4-in-1 likes ~3.8–5.5; Byzantine ~3–4; dragonscale ~3–3.6.",
        "inputs": {
            "aspect_ratio": 4,
            "wire_diameter": 1.6,
            "inner_diameter": 6.4
        },
        "aspect_ratio": 4,
        "wire_diameter": 1.6,
        "inner_diameter": 6.4,
        "suitable_weaves": [
            "european-4-in-1",
            "byzantine",
            "box-chain",
            "half-persian-3-1",
            "full-persian-6-1",
            "japanese-6-in-1",
            "helm-chain"
        ]
    },
    "meta": {
        "timestamp": "2026-06-06T07:13:57.916Z",
        "request_id": "29ac2e80-b645-4740-b825-2cfb1958fe94"
    },
    "status": "ok",
    "message": "Aspect ratio",
    "success": true
}
```

#### `GET /v1/ring` — Wire length + weight per ring

**Parameters:**
- `inner_diameter` (query, required, string) — Inner diameter (mm) Example: `6.4`
- `wire_diameter` (query, required, string) — Wire diameter (mm) Example: `1.6`
- `material` (query, optional, string) — steel, stainless, aluminum, copper, brass, silver, … Example: `steel`
- `density_g_cm3` (query, optional, string) — Custom density (g/cm³)
- `wire_length_m` (query, optional, string) — Wire length (m) → rings yield
- `ring_count` (query, optional, string) — Ring count → total wire & weight

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/chainmaille-api/v1/ring?inner_diameter=6.4&wire_diameter=1.6&material=steel"
```

**Response:**
```json
{
    "data": {
        "note": "Wire per ring ≈ π × (inner diameter + wire diameter) — the mean-diameter circumference. Weight = wire volume × density. Add a little for cut loss and the kerf of the saw or cutter.",
        "inputs": {
            "material": "steel",
            "density_g_cm3": 7.85,
            "wire_diameter": 1.6,
            "inner_diameter": 6.4
        },
        "wire_per_ring_in": 0.9895,
        "wire_per_ring_mm": 25.133,
        "weight_per_ring_g": 0.3967
    },
    "meta": {
        "timestamp": "2026-06-06T07:13:58.013Z",
        "request_id": "97f74abd-d763-487a-98c8-c7515e7c0f50"
    },
    "status": "ok",
    "message": "Ring math",
    "success": true
}
```

### Meta

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

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

**Response:**
```json
{
    "data": {
        "notes": "Aspect Ratio = ID ÷ WD; dimensions in mm. Wire per ring = π × (ID + WD); weight = volume × material density (steel 7.85 g/cm³). For wire-gauge ↔ mm conversion use a wire-gauge API.",
        "service": "chainmaille-api",
        "endpoints": {
            "GET /v1/meta": "This document.",
            "GET /v1/ring": "Wire length and weight per ring, plus rings from a wire length or totals for a ring count.",
            "GET /v1/aspect": "Aspect ratio (and the missing dimension) from inner diameter, wire diameter or AR, with suitable weaves."
        },
        "description": "Chainmaille maths: ring aspect ratio, per-ring wire length & weight, and rings from a length of wire."
    },
    "meta": {
        "timestamp": "2026-06-06T07:13:58.094Z",
        "request_id": "4553c4e8-1b41-455f-b6d8-0e7991403712"
    },
    "status": "ok",
    "message": "Meta",
    "success": true
}
```


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