# Two-Stroke Mix API
> Two-stroke premix maths as an API, computed locally and deterministically — the gas-to-oil numbers anyone running a chainsaw, string trimmer, leaf blower, outboard, dirt bike or RC engine mixes fuel by. The mix endpoint gives the oil to add to a tank of fuel at a given ratio: oil = fuel ÷ ratio, so one US gallon at 50:1 needs about 75.7 ml (2.6 fl oz) of two-stroke oil, 40:1 about 94.6 ml (3.2 fl oz) and 32:1 about 118 ml (4.0 fl oz), and it returns the total mix and the oil percentage too, in litres, gallons, millilitres or fluid ounces. The ratio endpoint runs it the other way — measure the fuel and the oil you actually put in and it tells you the real N:1 ratio, the oil percentage and the nearest common ratio, so you can check a mix or reverse-engineer a pre-mixed can. Get it wrong and it matters: too little oil and the engine seizes, too much and it fouls plugs and smokes — so always use the ratio in your tool’s manual. Everything is computed locally and deterministically, so it is instant and private. Ideal for small-engine, outdoor-power-equipment, marine, powersports and DIY app developers, fuel-mixing and shop tools, and maintenance software. Pure local computation — no key, no third-party service, instant. Live, nothing stored. 2 compute endpoints.

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

## Pricing
- **Free** (Free) — 6,880 calls/Mo, 2 req/s
- **Starter** ($4/Mo) — 55,900 calls/Mo, 6 req/s
- **Pro** ($12/Mo) — 229,800 calls/Mo, 15 req/s
- **Mega** ($37/Mo) — 1,334,000 calls/Mo, 40 req/s

## Endpoints

### TwoStroke

#### `GET /v1/mix` — Oil for a fuel volume

**Parameters:**
- `fuel` (query, required, string) — Fuel volume Example: `1`
- `ratio` (query, required, string) — Gas:oil ratio ('50:1' or '50') Example: `50:1`
- `unit` (query, optional, string) — l, gal, impgal, ml or floz (default l) Example: `gal`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/twostroke-api/v1/mix?fuel=1&ratio=50%3A1&unit=gal"
```

**Response:**
```json
{
    "data": {
        "note": "Oil = fuel ÷ ratio (a 50:1 mix is 50 parts fuel to 1 part oil). One US gallon at 50:1 needs about 2.6 fl oz of oil; at 40:1 about 3.2; at 32:1 about 4.0. Measure into the fuel, not the other way round, and shake.",
        "inputs": {
            "fuel": 1,
            "unit": "gal",
            "ratio": "50:1"
        },
        "oil_ml": 75.7,
        "fuel_ml": 3785.4,
        "oil_fl_oz": 2.56,
        "oil_percent": 1.96,
        "total_mix_ml": 3861.1
    },
    "meta": {
        "timestamp": "2026-06-06T07:13:56.538Z",
        "request_id": "66b07f2c-2257-4e32-9fa9-5a45ad840543"
    },
    "status": "ok",
    "message": "Premix oil",
    "success": true
}
```

#### `GET /v1/ratio` — Ratio from amounts

**Parameters:**
- `fuel` (query, required, string) — Fuel amount Example: `5000`
- `oil` (query, required, string) — Oil amount Example: `100`
- `unit` (query, optional, string) — same unit for both (default ml) Example: `ml`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/twostroke-api/v1/ratio?fuel=5000&oil=100&unit=ml"
```

**Response:**
```json
{
    "data": {
        "note": "Ratio = fuel ÷ oil (both in the same unit), reported as N:1. A bigger first number is leaner (less oil). Always use the ratio your engine's manual specifies; too little oil seizes it, too much fouls plugs and smokes.",
        "ratio": 50,
        "inputs": {
            "oil": 100,
            "fuel": 5000,
            "unit": "ml"
        },
        "oil_percent": 1.96,
        "ratio_label": "50:1",
        "nearest_common_ratio": "50:1"
    },
    "meta": {
        "timestamp": "2026-06-06T07:13:56.631Z",
        "request_id": "28a15af7-b16f-408f-b9d1-b07a20b49b26"
    },
    "status": "ok",
    "message": "Identify ratio",
    "success": true
}
```

### Meta

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

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

**Response:**
```json
{
    "data": {
        "notes": "Ratio as '50:1' or a number; volume in l, gal (US), impgal, ml or floz. Oil = fuel ÷ ratio. Use the manufacturer's specified ratio and a quality two-stroke oil. For four-stroke or fuel economy use a different API.",
        "service": "twostroke-api",
        "endpoints": {
            "GET /v1/mix": "Oil (ml / fl oz) to add to a fuel volume at a given ratio.",
            "GET /v1/meta": "This document.",
            "GET /v1/ratio": "The gas:oil ratio from measured fuel and oil amounts."
        },
        "description": "Two-stroke premix maths: oil needed for a fuel volume at a gas:oil ratio, and the ratio from measured amounts."
    },
    "meta": {
        "timestamp": "2026-06-06T07:13:56.717Z",
        "request_id": "6cf4962f-25de-4ec4-9e38-268236203a27"
    },
    "status": "ok",
    "message": "Meta",
    "success": true
}
```


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