# Fraction API
> Exact fraction maths with arbitrary-precision integers — no floating-point rounding. The simplify endpoint reduces any fraction to its lowest terms and returns the decimal value, the mixed-number form (10/4 → 2 1/2) and whether it is a whole number. The calc endpoint adds, subtracts, multiplies or divides two values — given as fractions (1/2), whole numbers, mixed numbers (1 1/2) or decimals (0.5) — and returns the simplified result. The fromdecimal endpoint turns a decimal into a fraction: exactly for terminating decimals, and precisely for repeating decimals written with parentheses, so 0.(3) becomes 1/3 and 0.1(6) becomes 1/6. Because every step uses big integers, results are always exact and very large numerators or denominators are returned as strings rather than losing precision. Ideal for education and maths tools, recipes and unit scaling, engineering and woodworking measurements, finance, and anywhere fractions must stay exact. Pure local computation — no key, no third-party service, instant. Live, nothing stored. 4 endpoints. This is fraction maths; for general expressions use a math-engine API and for prime factorization use a number-theory 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/fraction-api/..."
```

## Pricing
- **Free** (Free) — 4,435 calls/Mo, 2 req/s
- **Starter** ($6/Mo) — 13,950 calls/Mo, 8 req/s
- **Pro** ($26/Mo) — 190,500 calls/Mo, 20 req/s
- **Mega** ($64/Mo) — 995,000 calls/Mo, 50 req/s

## Endpoints

### Fraction

#### `GET /v1/calc` — Fraction arithmetic

**Parameters:**
- `a` (query, required, string) — First value (n/d, integer, mixed or decimal) Example: `1/2`
- `b` (query, required, string) — Second value Example: `1/3`
- `op` (query, required, string) — add, subtract, multiply or divide Example: `add`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/fraction-api/v1/calc?a=1%2F2&b=1%2F3&op=add"
```

**Response:**
```json
{
    "data": {
        "a": "1/2",
        "b": "1/3",
        "op": "add",
        "result": {
            "mixed": {
                "text": "0 5/6",
                "whole": 0,
                "fraction": "5/6"
            },
            "decimal": "0.833333333333",
            "fraction": "5/6",
            "is_whole": false,
            "numerator": 5,
            "denominator": 6
        }
    },
    "meta": {
        "timestamp": "2026-06-03T17:42:20.979Z",
        "request_id": "f56e8d29-11de-4245-8b4f-d1b48214eb7c"
    },
    "status": "ok",
    "message": "Fraction arithmetic",
    "success": true
}
```

#### `GET /v1/fromdecimal` — Decimal to fraction

**Parameters:**
- `value` (query, required, string) — A decimal — 0.75, or repeating like 0.1(6) Example: `0.75`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/fraction-api/v1/fromdecimal?value=0.75"
```

**Response:**
```json
{
    "data": {
        "mixed": {
            "text": "0 3/4",
            "whole": 0,
            "fraction": "3/4"
        },
        "value": "0.75",
        "decimal": "0.75",
        "fraction": "3/4",
        "is_whole": false,
        "numerator": 3,
        "denominator": 4
    },
    "meta": {
        "timestamp": "2026-06-03T17:42:21.086Z",
        "request_id": "b955a172-ef54-49af-bac3-fdba24fb91ae"
    },
    "status": "ok",
    "message": "Decimal to fraction",
    "success": true
}
```

#### `GET /v1/simplify` — Simplify a fraction

**Parameters:**
- `fraction` (query, optional, string) — A fraction like 6/8 Example: `10/4`
- `numerator` (query, optional, string) — Numerator (integer)
- `denominator` (query, optional, string) — Denominator (integer)

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/fraction-api/v1/simplify?fraction=10%2F4"
```

**Response:**
```json
{
    "data": {
        "mixed": {
            "text": "2 1/2",
            "whole": 2,
            "fraction": "1/2"
        },
        "decimal": "2.5",
        "fraction": "5/2",
        "is_whole": false,
        "numerator": 5,
        "denominator": 2
    },
    "meta": {
        "timestamp": "2026-06-03T17:42:21.186Z",
        "request_id": "f33900c0-d4f5-48d5-a8ad-9b4e4529583e"
    },
    "status": "ok",
    "message": "Simplify a fraction",
    "success": true
}
```

### Meta

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

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

**Response:**
```json
{
    "data": {
        "name": "Fraction API",
        "notes": "Repeating decimals use parenthesis notation for the repeating part: 0.(3)=1/3, 0.1(6)=1/6. Values are exact via BigInt; very large numerators/denominators are returned as strings. This is fraction maths — for general expressions use a math-engine API and for prime factorization use a number-theory API. Nothing is stored.",
        "version": "v1",
        "endpoints": [
            {
                "path": "/v1/simplify",
                "params": {
                    "fraction": "a fraction like 6/8 (or use numerator + denominator)",
                    "numerator": "the numerator (integer)",
                    "denominator": "the denominator (integer)"
                },
                "returns": "the reduced fraction, decimal, mixed number and gcd info"
            },
            {
                "path": "/v1/calc",
                "params": {
                    "a": "first value (n/d, integer, mixed, or decimal)",
                    "b": "second value",
                    "op": "add, subtract, multiply or divide"
                },
                "returns": "the simplified result fraction"
            },
            {
                "path": "/v1/fromdecimal",
                "params": {
                    "value": "a decimal — 0.75, or repeating like 0.1(6)"
                },
                "returns": "the equivalent fraction"
            },
            {
                "path": "/v1/meta",
…(truncated, see openapi.json for full schema)
```


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