# Sewing & Fabric API
> Sewing and fabric-estimating maths as an API, computed locally and deterministically — the yardage numbers a sewist, quilter or curtain-maker works a project out with. The yardage endpoint lays cut pieces onto a bolt: pieces per row = floor(fabric width ÷ piece width), rows = ceil(quantity ÷ per row), and the fabric length = rows × piece height plus a waste allowance — six 18×22-inch pieces from 44-inch quilting cotton need about 2 yards. The curtain endpoint sizes drapery for fullness: drops = ceil(window width × fullness ÷ fabric width), where 2× is a standard gather and 2.5–3× is luxe, and each drop is the finished length plus top and bottom hems (rounded up to the pattern repeat) — a 60-inch window at 2.5× fullness on 54-inch fabric takes three drops and about 8.3 yards. The binding endpoint sizes quilt binding: length = perimeter + overlap for corners and joins, strips = ceil(length ÷ fabric width) cut at the strip width. Everything is computed locally and deterministically, so it is instant and private. Ideal for sewing, quilting, home-decor, upholstery and craft app developers, fabric-calculator and project-planning tools, and sewing education. Pure local computation — no key, no third-party service, instant. Imperial inches in; yards and metres out. Live, nothing stored. 3 compute endpoints. Add pattern-repeat allowance for prints; a planning aid.

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

## Pricing
- **Free** (Free) — 5,550 calls/Mo, 2 req/s
- **Starter** ($5/Mo) — 52,500 calls/Mo, 6 req/s
- **Pro** ($15/Mo) — 229,000 calls/Mo, 15 req/s
- **Mega** ($46/Mo) — 1,265,000 calls/Mo, 40 req/s

## Endpoints

### Sewing

#### `GET /v1/binding` — Quilt binding

**Parameters:**
- `quilt_width` (query, required, string) — Quilt width (in) Example: `60`
- `quilt_height` (query, required, string) — Quilt height (in) Example: `80`
- `strip_width` (query, optional, string) — Binding strip width (in, default 2.5)
- `fabric_width` (query, optional, string) — Fabric width (in, default 44)
- `overlap` (query, optional, string) — Corner/join overlap (in, default 10)

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/sewing-api/v1/binding?quilt_width=60&quilt_height=80"
```

**Response:**
```json
{
    "data": {
        "note": "Binding length = perimeter + overlap for corners and joins. Strips = ceil(binding length ÷ fabric width), each cut at the strip width (2.5\" makes a common double-fold binding).",
        "inputs": {
            "quilt_width": 60,
            "strip_width": 2.5,
            "fabric_width": 44,
            "quilt_height": 80
        },
        "strips_needed": 7,
        "perimeter_inches": 280,
        "fabric_length_yards": 0.4861,
        "fabric_length_inches": 17.5,
        "fabric_length_meters": 0.4445,
        "binding_length_inches": 290
    },
    "meta": {
        "timestamp": "2026-06-06T07:14:09.691Z",
        "request_id": "4811186a-5c31-4043-8f3b-8c4d9ed95fdb"
    },
    "status": "ok",
    "message": "Quilt binding",
    "success": true
}
```

#### `GET /v1/curtain` — Curtain fabric

**Parameters:**
- `window_width` (query, required, string) — Window/rod width (in) Example: `60`
- `finished_length` (query, required, string) — Finished curtain length (in) Example: `84`
- `fullness` (query, optional, string) — Fullness ratio (default 2) Example: `2.5`
- `fabric_width` (query, optional, string) — Fabric width (in, default 54) Example: `54`
- `hem_allowance` (query, optional, string) — Top+bottom hems (in, default 16)
- `pattern_repeat` (query, optional, string) — Pattern repeat (in)

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/sewing-api/v1/curtain?window_width=60&finished_length=84&fullness=2.5&fabric_width=54"
```

**Response:**
```json
{
    "data": {
        "note": "Drops = ceil(window width × fullness ÷ fabric width). Each drop is the finished length plus hems (rounded up to the pattern repeat). 2× fullness is standard, 2.5–3× for a luxe gather.",
        "drops": 3,
        "inputs": {
            "fullness": 2.5,
            "fabric_width": 54,
            "window_width": 60,
            "hem_allowance": 16,
            "finished_length": 84
        },
        "cut_length_inches": 100,
        "total_length_yards": 8.3333,
        "fabric_width_needed": 150,
        "total_length_inches": 300,
        "total_length_meters": 7.62
    },
    "meta": {
        "timestamp": "2026-06-06T07:14:09.787Z",
        "request_id": "c6121e11-e087-4bf4-b5ea-97ed2f46edb9"
    },
    "status": "ok",
    "message": "Curtain fabric",
    "success": true
}
```

#### `GET /v1/yardage` — Fabric for cut pieces

**Parameters:**
- `piece_width` (query, required, string) — Piece width (in) Example: `18`
- `piece_height` (query, required, string) — Piece height (in) Example: `22`
- `quantity` (query, optional, string) — Number of pieces (default 1) Example: `6`
- `fabric_width` (query, optional, string) — Bolt width (in, default 44) Example: `44`
- `waste_percent` (query, optional, string) — Waste % (default 10)

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/sewing-api/v1/yardage?piece_width=18&piece_height=22&quantity=6&fabric_width=44"
```

**Response:**
```json
{
    "data": {
        "note": "Pieces per row = floor(fabric width ÷ piece width); rows = ceil(quantity ÷ per row); fabric length = rows × piece height, plus waste. Add pattern-repeat allowance for prints.",
        "inputs": {
            "quantity": 6,
            "piece_width": 18,
            "fabric_width": 44,
            "piece_height": 22,
            "waste_percent": 10
        },
        "rows_needed": 3,
        "length_yards": 2.0167,
        "length_inches": 72.6,
        "length_meters": 1.844,
        "pieces_per_row": 2
    },
    "meta": {
        "timestamp": "2026-06-06T07:14:09.859Z",
        "request_id": "cb2b33c4-4afd-4290-bf69-b2a5f837167b"
    },
    "status": "ok",
    "message": "Fabric yardage",
    "success": true
}
```

### Meta

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

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

**Response:**
```json
{
    "data": {
        "notes": "Imperial inches in, yards and metres out. Defaults: 44\" quilting cotton / 54\" home-dec fabric, 2× curtain fullness, 2.5\" binding. Add pattern-repeat allowance for prints. A planning aid.",
        "service": "sewing-api",
        "endpoints": {
            "GET /v1/meta": "This document.",
            "GET /v1/binding": "Quilt binding strip length and fabric from the quilt perimeter.",
            "GET /v1/curtain": "Curtain fabric: drops, cut length and total from window width and fullness.",
            "GET /v1/yardage": "Fabric length to cut N pieces of a size from a bolt of a width."
        },
        "description": "Sewing & fabric maths: fabric yardage for cut pieces, curtain fabric with fullness, and quilt binding."
    },
    "meta": {
        "timestamp": "2026-06-06T07:14:09.952Z",
        "request_id": "19d91fb9-f0c0-4cdd-b453-f1187357043d"
    },
    "status": "ok",
    "message": "Meta",
    "success": true
}
```


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