# Knitting Gauge API
> Knitting and crochet gauge maths as an API, computed locally and deterministically. The stitches endpoint turns a gauge — the standard stitches and rows per 10 cm measured from a tension swatch — into the number of stitches to cast on for a target width and the number of rows for a target length; at 22 stitches and 30 rows per 10 cm, a 50 cm wide by 60 cm long piece needs 110 stitches and 180 rows. The gauge endpoint works backwards from a measured swatch, converting a count over a measured distance into stitches (or rows) per 10 cm, per centimetre and per inch — 33 stitches over 15 cm is a gauge of 22 per 10 cm. The convert-pattern endpoint re-scales a pattern written for one gauge to your own gauge so the finished garment keeps its intended size: your count = pattern count · (your gauge / pattern gauge), so a 100-stitch cast-on at a 20-per-10 cm pattern becomes 110 at your 22-per-10 cm tension. Dimensions are in centimetres. Everything is computed locally and deterministically, so it is instant and private. Ideal for knitting, crochet, pattern-design, craft-marketplace and maker app developers, gauge and tension calculators, and yarn-shop tools. Pure local computation — no key, no third-party service, instant. Live, nothing stored. 3 endpoints. This is gauge and stitch maths; works for crochet too by using your stitch gauge.

## 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/knitting-api/..."
```

## Pricing
- **Free** (Free) — 7,300 calls/Mo, 2 req/s
- **Starter** ($4/Mo) — 73,000 calls/Mo, 6 req/s
- **Pro** ($10/Mo) — 325,000 calls/Mo, 15 req/s
- **Mega** ($32/Mo) — 1,720,000 calls/Mo, 40 req/s

## Endpoints

### Knitting

#### `GET /v1/convert-pattern` — Convert pattern between gauges

**Parameters:**
- `pattern_count` (query, required, string) — Pattern stitch count Example: `100`
- `pattern_gauge` (query, required, string) — Pattern gauge (per 10 cm) Example: `20`
- `your_gauge` (query, required, string) — Your gauge (per 10 cm) Example: `22`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/knitting-api/v1/convert-pattern?pattern_count=100&pattern_gauge=20&your_gauge=22"
```

**Response:**
```json
{
    "data": {
        "note": "To keep the finished size, your count = pattern count · (your gauge / pattern gauge). 100 sts at a 20/10 cm pattern gauge becomes 110 at your 22/10 cm gauge.",
        "inputs": {
            "your_gauge": 22,
            "pattern_count": 100,
            "pattern_gauge": 20
        },
        "your_count": 110,
        "your_count_exact": 110,
        "finished_dimension_cm": 50
    },
    "meta": {
        "timestamp": "2026-06-05T19:50:19.655Z",
        "request_id": "c5506f6f-a930-40f6-8418-ba3cc73b443f"
    },
    "status": "ok",
    "message": "Convert pattern between gauges",
    "success": true
}
```

#### `GET /v1/gauge` — Gauge from a swatch

**Parameters:**
- `count` (query, required, string) — Stitches/rows counted Example: `33`
- `measured_cm` (query, required, string) — Distance measured (cm) Example: `15`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/knitting-api/v1/gauge?count=33&measured_cm=15"
```

**Response:**
```json
{
    "data": {
        "note": "Gauge per 10 cm = count/measured · 10. Counting 33 stitches over 15 cm gives 22 stitches per 10 cm.",
        "inputs": {
            "count": 33,
            "measured_cm": 15
        },
        "per_cm": 2.2,
        "per_10cm": 22,
        "per_inch": 5.588
    },
    "meta": {
        "timestamp": "2026-06-05T19:50:19.731Z",
        "request_id": "ee3a18dc-8296-4797-9917-97e94f76a84d"
    },
    "status": "ok",
    "message": "Gauge from swatch",
    "success": true
}
```

#### `GET /v1/stitches` — Stitches/rows for dimensions

**Parameters:**
- `stitches_per_10cm` (query, optional, string) — Stitch gauge per 10 cm Example: `22`
- `width_cm` (query, optional, string) — Target width (cm) Example: `50`
- `rows_per_10cm` (query, optional, string) — Row gauge per 10 cm Example: `30`
- `length_cm` (query, optional, string) — Target length (cm) Example: `60`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/knitting-api/v1/stitches?stitches_per_10cm=22&width_cm=50&rows_per_10cm=30&length_cm=60"
```

**Response:**
```json
{
    "data": {
        "note": "Stitches = (width/10)·gauge, rows = (length/10)·row-gauge, with gauge measured per 10 cm. Cast on the rounded stitch count.",
        "rows": 180,
        "inputs": {
            "width_cm": 50,
            "length_cm": 60,
            "rows_per_10cm": 30,
            "stitches_per_10cm": 22
        },
        "stitches": 110,
        "rows_exact": 180,
        "stitches_exact": 110
    },
    "meta": {
        "timestamp": "2026-06-05T19:50:19.840Z",
        "request_id": "0cfd9f42-4dfe-472e-84a1-85755aa766a0"
    },
    "status": "ok",
    "message": "Stitches for dimensions",
    "success": true
}
```

### Meta

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

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

**Response:**
```json
{
    "data": {
        "notes": "Gauge is stitches (or rows) per 10 cm — the knitting standard. Dimensions in centimetres. Works for crochet too (substitute your stitch gauge).",
        "service": "knitting-api",
        "endpoints": {
            "GET /v1/meta": "This document.",
            "GET /v1/gauge": "Gauge per 10 cm (and per inch) from a measured swatch.",
            "GET /v1/stitches": "Stitches/rows for a target width/length at a gauge.",
            "GET /v1/convert-pattern": "Re-scale a pattern's stitch count from its gauge to yours."
        },
        "description": "Knitting & crochet gauge maths: stitches and rows for target dimensions, gauge from a swatch, and converting a pattern between gauges."
    },
    "meta": {
        "timestamp": "2026-06-05T19:50:19.933Z",
        "request_id": "e89c61f3-6d12-4657-a3d0-6fa6fc0a0685"
    },
    "status": "ok",
    "message": "Meta",
    "success": true
}
```


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