# Metal Casting API
> Metal-casting and foundry maths as an API, computed locally and deterministically — the solidification-time, shrinkage and melt-weight numbers a foundryman, patternmaker or casting designer works a job to. The solidification-time endpoint applies Chvorinov's rule, t = B × (V/A)², where V/A is the casting modulus (volume ÷ cooling surface area) and B is the mould constant (~2–4 min/cm² for sand): a chunky part with little surface for its volume freezes slowly, a thin one fast — and because a riser must stay molten longer than the casting it feeds, its modulus has to be larger, which is the number that sizes it. The pattern-shrinkage endpoint makes the pattern oversize for the metal that shrinks as it cools: pattern = casting dimension × (1 + shrinkage/100), the patternmaker's contraction rule — about 1.0–1.6 % for grey iron, ~2 % for steel and aluminium — so a 100 mm steel feature needs a 102 mm pattern. The melt-weight endpoint gives the casting weight = volume × metal density (iron ~7.2, steel ~7.85, aluminium ~2.70 g/cm³) and the metal to actually pour = casting weight ÷ the casting yield, because the sprue, runners and risers are remelted scrap — a 7 kg iron casting at 70 % yield needs about 10 kg in the ladle. Everything is computed locally and deterministically, so it is instant and private. Ideal for foundry and patternmaking tools, casting-design and estimating apps, and metalworking calculators. Pure local computation — no key, no third-party service, instant. 3 compute endpoints. For a part's weight from its dimensions use a metal-weight API; for welded joints a welding 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/casting-api/..."
```

## Pricing
- **Free** (Free) — 6,900 calls/Mo, 2 req/s
- **Starter** ($9/Mo) — 63,500 calls/Mo, 6 req/s
- **Pro** ($29/Mo) — 258,000 calls/Mo, 15 req/s
- **Mega** ($89/Mo) — 1,195,000 calls/Mo, 40 req/s

## Endpoints

### Casting

#### `GET /v1/melt-weight` — Cast weight and metal to melt

**Parameters:**
- `volume_cm3` (query, required, string) — Casting volume (cm³) Example: `1000`
- `density_g_cm3` (query, required, string) — Metal density (g/cm³) Example: `7.0`
- `yield_pct` (query, optional, string) — Casting yield (%, default 70) Example: `70`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/casting-api/v1/melt-weight?volume_cm3=1000&density_g_cm3=7.0&yield_pct=70"
```

**Response:**
```json
{
    "data": {
        "note": "The casting weight = its volume × the metal density (grey iron ~7.2, steel ~7.85, aluminium ~2.70, brass ~8.5 g/cm³). But you must melt more than the part: the sprue, runners and risers are remelted scrap, so the metal to pour = casting weight ÷ the casting yield (the fraction that ends up as good casting, often 50–75 % for sand work). A 7 kg iron casting at 70 % yield needs about 10 kg in the ladle.",
        "inputs": {
            "yield_pct": 70,
            "volume_cm3": 1000,
            "density_g_cm3": 7
        },
        "cast_weight_g": 7000,
        "cast_weight_kg": 7,
        "metal_to_melt_g": 10000,
        "metal_to_melt_kg": 10
    },
    "meta": {
        "timestamp": "2026-06-07T08:17:50.241Z",
        "request_id": "ee9060ea-8668-4ea1-9373-f339a8e3631d"
    },
    "status": "ok",
    "message": "Melt weight",
    "success": true
}
```

#### `GET /v1/pattern-shrinkage` — Oversize pattern dimension

**Parameters:**
- `casting_dimension_mm` (query, required, string) — Finished casting dimension (mm) Example: `100`
- `shrinkage_pct` (query, optional, string) — Shrinkage (%, default 2.0) Example: `2.0`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/casting-api/v1/pattern-shrinkage?casting_dimension_mm=100&shrinkage_pct=2.0"
```

**Response:**
```json
{
    "data": {
        "note": "Metal shrinks as it cools from freezing to room temperature, so the pattern must be made oversize: pattern = casting dimension × (1 + shrinkage/100). The patternmaker's 'contraction rule' bakes this in — about 1.0–1.6 % for grey iron, ~2 % for steel and aluminium, ~1.5 % for brass. A 100 mm steel feature needs a 102 mm pattern. This is solid (linear) contraction only; liquid and freezing shrinkage are fed by the risers.",
        "inputs": {
            "shrinkage_pct": 2,
            "casting_dimension_mm": 100
        },
        "allowance_mm": 2,
        "pattern_dimension_mm": 102
    },
    "meta": {
        "timestamp": "2026-06-07T08:17:50.321Z",
        "request_id": "c9dbd87f-de1d-419a-ac89-1913d5e6f10e"
    },
    "status": "ok",
    "message": "Pattern shrinkage",
    "success": true
}
```

#### `GET /v1/solidification-time` — Chvorinov solidification time

**Parameters:**
- `volume_cm3` (query, required, string) — Casting volume (cm³) Example: `1000`
- `surface_area_cm2` (query, required, string) — Cooling surface area (cm²) Example: `600`
- `mold_constant_min_cm2` (query, optional, string) — Mould constant (min/cm², default 2.0) Example: `2.0`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/casting-api/v1/solidification-time?volume_cm3=1000&surface_area_cm2=600&mold_constant_min_cm2=2.0"
```

**Response:**
```json
{
    "data": {
        "note": "Chvorinov's rule sets how long a casting takes to freeze: t = B × (V/A)², where V/A is the casting modulus (volume ÷ cooling surface area) and B is the mould constant (~2–4 min/cm² for sand). A chunky part with a small surface for its volume cools slowly; a thin one freezes fast. Risers must have a larger modulus than the casting so they stay molten longer and feed the shrinkage — this is the number that sizes them.",
        "inputs": {
            "volume_cm3": 1000,
            "surface_area_cm2": 600,
            "mold_constant_min_cm2": 2
        },
        "casting_modulus_cm": 1.6667,
        "solidification_time_min": 5.556
    },
    "meta": {
        "timestamp": "2026-06-07T08:17:50.420Z",
        "request_id": "906d1c54-e74e-40d2-8ea9-d393328fdb61"
    },
    "status": "ok",
    "message": "Solidification time",
    "success": true
}
```

### Meta

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

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

**Response:**
```json
{
    "data": {
        "notes": "cm³, cm², mm, g/cm³, min. t = B·(V/A)²; pattern = casting·(1+shrink/100); cast = V·ρ, melt = cast/yield. For a part's weight from dimensions use a metal-weight API; for welding a welding API.",
        "service": "casting-api",
        "endpoints": {
            "GET /v1/meta": "This document.",
            "GET /v1/melt-weight": "Cast weight and metal to melt from volume, density and yield.",
            "GET /v1/pattern-shrinkage": "Oversize pattern dimension for shrinkage.",
            "GET /v1/solidification-time": "Solidification time and modulus by Chvorinov's rule."
        },
        "description": "Metal-casting / foundry maths: Chvorinov solidification time, pattern shrinkage allowance, and melt weight from volume and density."
    },
    "meta": {
        "timestamp": "2026-06-07T08:17:50.521Z",
        "request_id": "0b2eed4a-fe32-4464-abdc-21f0fc604f6e"
    },
    "status": "ok",
    "message": "Meta",
    "success": true
}
```


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