# Metal Weight API
> Metal stock weight and cost as an API, computed locally and deterministically. The weight endpoint computes the mass of a length of metal stock from its shape, dimensions and material: round bar, square bar, flat bar or plate, sheet, hexagonal bar, round tube or pipe and rectangular (box) tube. It works out the cross-sectional area, multiplies by the length and the material density, and returns the weight per piece and the total for a quantity — in kilograms, pounds, grams and tonnes — along with the volume. Material density is looked up from a built-in table of metals (steel, stainless, aluminium, copper, brass, bronze, lead, zinc, titanium, nickel, gold, silver and more) or you can pass an explicit density. The cost endpoint multiplies that weight by a price per kilogram, pound or tonne to give the material cost per piece and in total. The materials endpoint lists the densities. Dimensions accept millimetres, centimetres, metres, inches or feet. Everything is computed locally and deterministically, so it is instant and private. Ideal for metal fabrication and machine-shop tools, engineering and CAD apps, scrap and stock quoting, and shipping-weight estimates. Pure local computation — no key, no third-party service, instant. Live, nothing stored. 3 endpoints. This is metal stock weight from geometry and density; for beam reactions and deflection use a beam API and for live metal spot prices use a commodities 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/metalweight-api/..."
```

## Pricing
- **Free** (Free) — 13,335 calls/Mo, 2 req/s
- **Starter** ($15/Mo) — 22,950 calls/Mo, 8 req/s
- **Pro** ($35/Mo) — 279,500 calls/Mo, 20 req/s
- **Mega** ($73/Mo) — 1,440,000 calls/Mo, 50 req/s

## Endpoints

### Metal

#### `GET /v1/cost` — Material cost

**Parameters:**
- `shape` (query, required, string) — Stock shape Example: `round_bar`
- `material` (query, optional, string) — Material Example: `steel`
- `unit` (query, optional, string) — Dimension unit Example: `mm`
- `length` (query, required, string) — Length Example: `1000`
- `diameter` (query, optional, string) — Diameter (per shape) Example: `50`
- `quantity` (query, optional, string) — Pieces Example: `1`
- `price_per_kg` (query, optional, string) — Price per kg Example: `2`
- `price_per_lb` (query, optional, string) — Or per lb
- `price_per_tonne` (query, optional, string) — Or per tonne

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/metalweight-api/v1/cost?shape=round_bar&material=steel&unit=mm&length=1000&diameter=50&quantity=1&price_per_kg=2"
```

**Response:**
```json
{
    "data": {
        "note": "total cost = total weight (kg) × price per kg. Prices in pounds/tonne are converted to per-kg.",
        "shape": "round_bar",
        "material": "steel",
        "quantity": 1,
        "total_cost": 30.8269,
        "price_per_kg": 2,
        "cost_per_piece": 30.8269,
        "total_weight_kg": 15.4134
    },
    "meta": {
        "timestamp": "2026-06-04T01:59:10.045Z",
        "request_id": "c586b4ef-9af4-4592-b5b7-54079f31283c"
    },
    "status": "ok",
    "message": "Material cost from weight & price",
    "success": true
}
```

#### `GET /v1/materials` — Metal density reference

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

**Response:**
```json
{
    "data": {
        "note": "Typical engineering densities. Pass material=<name> or an explicit density to the weight/cost endpoints.",
        "materials": {
            "tin": 7280,
            "gold": 19320,
            "lead": 11340,
            "zinc": 7140,
            "brass": 8500,
            "steel": 7850,
            "bronze": 8800,
            "copper": 8960,
            "nickel": 8900,
            "silver": 10490,
            "aluminum": 2700,
            "chromium": 7190,
            "platinum": 21450,
            "titanium": 4500,
            "tungsten": 19300,
            "aluminium": 2700,
            "cast_iron": 7200,
            "magnesium": 1740,
            "wrought_iron": 7700,
            "stainless_steel": 8000
        },
        "density_unit": "kg/m³"
    },
    "meta": {
        "timestamp": "2026-06-04T01:59:10.145Z",
        "request_id": "cf33f935-2eb8-4d5a-81b3-ecc4d5f0c72c"
    },
    "status": "ok",
    "message": "Metal density reference",
    "success": true
}
```

#### `GET /v1/weight` — Metal stock weight

**Parameters:**
- `shape` (query, required, string) — round_bar|square_bar|flat_bar|plate|sheet|hex_bar|round_tube|pipe|rect_tube Example: `round_bar`
- `material` (query, optional, string) — steel|aluminium|copper|… (default steel) Example: `steel`
- `density` (query, optional, string) — Or explicit density (kg/m³)
- `unit` (query, optional, string) — mm|cm|m|in|ft (default mm) Example: `mm`
- `length` (query, required, string) — Length along the axis Example: `1000`
- `diameter` (query, optional, string) — Round bar / tube diameter Example: `50`
- `side` (query, optional, string) — Square bar side
- `width` (query, optional, string) — Flat/plate/box width
- `height` (query, optional, string) — Box height
- `thickness` (query, optional, string) — Flat/plate thickness
- `across_flats` (query, optional, string) — Hex across-flats
- `outer_diameter` (query, optional, string) — Tube OD
- `wall_thickness` (query, optional, string) — Tube/box wall
- `quantity` (query, optional, string) — Number of pieces Example: `1`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/metalweight-api/v1/weight?shape=round_bar&material=steel&unit=mm&length=1000&diameter=50&quantity=1"
```

**Response:**
```json
{
    "data": {
        "note": "mass = cross-section area × length × density. Per-metre weight = weight_per_piece ÷ length_m.",
        "shape": "round_bar",
        "length_m": 1,
        "material": "steel",
        "quantity": 1,
        "total_weight": {
            "g": 15413.4,
            "kg": 15.4134,
            "lb": 33.9808,
            "tonnes": 0.015413
        },
        "density_kg_m3": 7850,
        "dimension_unit": "mm",
        "total_volume_m3": 0.001963495,
        "weight_per_piece": {
            "g": 15413.4,
            "kg": 15.4134,
            "lb": 33.9808
        },
        "cross_section_area_m2": 0.0019635
    },
    "meta": {
        "timestamp": "2026-06-04T01:59:10.241Z",
        "request_id": "631541fa-f0da-4ab0-827c-a20688912ba0"
    },
    "status": "ok",
    "message": "Metal stock weight from shape & material",
    "success": true
}
```

### Meta

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

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

**Response:**
```json
{
    "data": {
        "api": "metalweight",
        "note": "Metal weight & cost maths — computed locally and deterministically, no key, no third-party service.",
        "shapes": [
            "round_bar",
            "square_bar",
            "flat_bar",
            "plate",
            "sheet",
            "hex_bar",
            "round_tube",
            "pipe",
            "rect_tube"
        ],
        "endpoints": [
            "/v1/weight",
            "/v1/cost",
            "/v1/materials",
            "/v1/meta"
        ],
        "length_units": [
            "mm",
            "cm",
            "m",
            "in",
            "inch",
            "ft"
        ]
    },
    "meta": {
        "timestamp": "2026-06-04T01:59:10.331Z",
        "request_id": "5c7f3fee-090c-4d93-afa4-0e722c1bf1a9"
    },
    "status": "ok",
    "message": "Meta",
    "success": true
}
```


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