# Resistor Color Code API
> Read and write resistor colour codes and snap values to the standard E-series. The decode endpoint takes the colour bands of a 3-, 4-, 5- or 6-band resistor and returns the resistance in ohms (nicely formatted as Ω/kΩ/MΩ/GΩ), the significant digits and multiplier, the tolerance, the minimum and maximum resistance that tolerance implies, and — for 6-band parts — the temperature coefficient in ppm/K. The encode endpoint goes the other way: give it a resistance in ohms (and optionally a band count and tolerance) and it returns the colour bands, picking the nearest value representable with the available significant digits. The eseries endpoint snaps any value to the nearest preferred resistor value in the E6, E12, E24, E48 or E96 series and reports the percentage error and the neighbouring preferred values. It uses the standard IEC 60062 colour assignments (including gold ×0.1 and silver ×0.01 multipliers and the implicit ±20% of a 3-band part). Everything is computed locally and deterministically, so it is instant and private. Ideal for electronics design, PCB and BOM work, lab and hobby bench use, repair and reverse-engineering, and teaching. Pure local computation — no key, no third-party service, instant. Live, nothing stored. 4 endpoints. This is for resistor colour codes; for general number formatting use a number-format 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/resistor-api/..."
```

## Pricing
- **Free** (Free) — 5,735 calls/Mo, 2 req/s
- **Starter** ($7/Mo) — 15,250 calls/Mo, 8 req/s
- **Pro** ($27/Mo) — 203,500 calls/Mo, 20 req/s
- **Mega** ($65/Mo) — 1,060,000 calls/Mo, 50 req/s

## Endpoints

### Resistor

#### `GET /v1/decode` — Colour bands to resistance

**Parameters:**
- `bands` (query, required, string) — Comma-separated colours Example: `yellow,violet,red,gold`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/resistor-api/v1/decode?bands=yellow%2Cviolet%2Cred%2Cgold"
```

**Response:**
```json
{
    "data": {
        "ohms": 4700,
        "bands": [
            "yellow",
            "violet",
            "red",
            "gold"
        ],
        "max_ohms": 4935,
        "min_ohms": 4465,
        "formatted": "4.7 kΩ",
        "band_count": 4,
        "multiplier": 100,
        "tolerance_percent": 5,
        "significant_digits": 47
    },
    "meta": {
        "timestamp": "2026-06-03T17:42:16.364Z",
        "request_id": "4ae34783-4253-4429-8588-a124e38a0b34"
    },
    "status": "ok",
    "message": "Decode bands",
    "success": true
}
```

#### `GET /v1/encode` — Resistance to colour bands

**Parameters:**
- `ohms` (query, required, string) — Resistance in ohms Example: `4700`
- `bands` (query, optional, string) — 4, 5 or 6 (default 4) Example: `4`
- `tolerance` (query, optional, string) — Tolerance percent Example: `5`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/resistor-api/v1/encode?ohms=4700&bands=4&tolerance=5"
```

**Response:**
```json
{
    "data": {
        "ohms": 4700,
        "bands": [
            "yellow",
            "violet",
            "red",
            "gold"
        ],
        "exact": true,
        "formatted": "4.7 kΩ",
        "encoded_ohms": 4700,
        "requested_bands": 4,
        "tolerance_percent": 5
    },
    "meta": {
        "timestamp": "2026-06-03T17:42:16.460Z",
        "request_id": "3fe14a0c-f97a-4b09-a838-655fd166565a"
    },
    "status": "ok",
    "message": "Encode value",
    "success": true
}
```

#### `GET /v1/eseries` — Nearest preferred value

**Parameters:**
- `ohms` (query, required, string) — Resistance in ohms Example: `4800`
- `series` (query, optional, string) — E6/E12/E24/E48/E96 (default E24) Example: `E24`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/resistor-api/v1/eseries?ohms=4800&series=E24"
```

**Response:**
```json
{
    "data": {
        "ohms": 4800,
        "lower": 4300,
        "higher": 5100,
        "series": "E24",
        "error_percent": -2.083,
        "nearest_formatted": "4.7 kΩ",
        "nearest_preferred": 4700
    },
    "meta": {
        "timestamp": "2026-06-03T17:42:16.570Z",
        "request_id": "6b8fdfc4-51a1-4718-a542-06a2469acfd9"
    },
    "status": "ok",
    "message": "E-series",
    "success": true
}
```

### Meta

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

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

**Response:**
```json
{
    "data": {
        "name": "Resistor Color Code API",
        "notes": "Multiplier colours: gold = ×0.1, silver = ×0.01. 3-band resistors imply ±20% tolerance. Nothing is stored.",
        "colours": {
            "digit": "black0 brown1 red2 orange3 yellow4 green5 blue6 violet7 grey8 white9",
            "tolerance": "brown±1 red±2 green±0.5 blue±0.25 violet±0.1 grey±0.05 gold±5 silver±10 (none ±20)",
            "multiplier": "…gold ×0.1, silver ×0.01"
        },
        "version": "v1",
        "endpoints": [
            {
                "path": "/v1/decode",
                "params": {
                    "bands": "comma-separated colours, e.g. brown,black,red,gold"
                },
                "returns": "resistance, tolerance, min/max, tempco"
            },
            {
                "path": "/v1/encode",
                "params": {
                    "ohms": "resistance in ohms",
                    "bands": "4, 5 or 6 (default 4)",
                    "tolerance": "percent (default 5 for 4-band, 1 otherwise)"
                },
                "returns": "the colour bands"
            },
            {
                "path": "/v1/eseries",
                "params": {
                    "ohms": "resistance in ohms",
                    "series": "E6/E12/E24/E48/E96 (default E24)"
                },
                "returns": "nearest preferred value + error"
            },
            {
                "path": "/v1/meta",
             
…(truncated, see openapi.json for full schema)
```


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