# DPI & Print Size API
> Resolution, print-size and pixel-density maths for print, design, photography and screens. The resolve endpoint takes any two of pixels, DPI and physical length and computes the third, returning the size in inches, centimetres, millimetres and points — so you can answer "how big will a 3000-pixel image print at 300 DPI" or "what DPI do I get printing 3000 px at 10 inches". The ppi endpoint computes a screen's pixel density from its resolution and diagonal size, plus the dot pitch in millimetres, the total megapixels and the aspect ratio. The convert endpoint converts a length between pixels, inches, centimetres, millimetres and points (PostScript points, 1/72 inch), using a DPI when pixels are involved. Everything is computed locally and deterministically, so it is instant and private. Ideal for print and prepress, graphic and web design, photography, and screen and display specs. Pure local computation — no key, no third-party service, instant. Live, nothing stored. 4 endpoints. This is DPI and print-size maths; for aspect ratios and resizing use an aspect-ratio API and for general unit conversion use a unit 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/dpi-api/..."
```

## Pricing
- **Free** (Free) — 6,535 calls/Mo, 2 req/s
- **Starter** ($8/Mo) — 16,050 calls/Mo, 8 req/s
- **Pro** ($28/Mo) — 211,500 calls/Mo, 20 req/s
- **Mega** ($66/Mo) — 1,100,000 calls/Mo, 50 req/s

## Endpoints

### DPI

#### `GET /v1/convert` — Convert a length

**Parameters:**
- `value` (query, required, string) — The length Example: `300`
- `from` (query, required, string) — px|in|cm|mm|pt Example: `px`
- `to` (query, required, string) — px|in|cm|mm|pt Example: `in`
- `dpi` (query, optional, string) — Needed for px Example: `150`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/dpi-api/v1/convert?value=300&from=px&to=in&dpi=150"
```

**Response:**
```json
{
    "data": {
        "to": "in",
        "dpi": 150,
        "from": "px",
        "value": 300,
        "result": 2
    },
    "meta": {
        "timestamp": "2026-06-03T17:42:12.971Z",
        "request_id": "8d26952d-dcb7-4175-82fe-7da5b5aeb5e1"
    },
    "status": "ok",
    "message": "Convert",
    "success": true
}
```

#### `GET /v1/ppi` — Screen pixel density

**Parameters:**
- `width` (query, required, string) — Width in px Example: `1920`
- `height` (query, required, string) — Height in px Example: `1080`
- `diagonal` (query, required, string) — Diagonal in inches Example: `24`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/dpi-api/v1/ppi?width=1920&height=1080&diagonal=24"
```

**Response:**
```json
{
    "data": {
        "ppi": 91.7878,
        "width_px": 1920,
        "height_px": 1080,
        "megapixels": 2.0736,
        "aspect_ratio": "16:9",
        "dot_pitch_mm": 0.276725,
        "diagonal_inches": 24
    },
    "meta": {
        "timestamp": "2026-06-03T17:42:13.051Z",
        "request_id": "28f5d491-caec-418e-a9db-4a673e7ec59a"
    },
    "status": "ok",
    "message": "PPI",
    "success": true
}
```

#### `GET /v1/resolve` — Pixels / DPI / size (give any two)

**Parameters:**
- `pixels` (query, optional, string) — Pixel count Example: `3000`
- `dpi` (query, optional, string) — Dots per inch Example: `300`
- `length` (query, optional, string) — Physical length
- `unit` (query, optional, string) — in|cm|mm|pt Example: `in`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/dpi-api/v1/resolve?pixels=3000&dpi=300&unit=in"
```

**Response:**
```json
{
    "data": {
        "cm": 25.4,
        "mm": 254,
        "dpi": 300,
        "inches": 10,
        "pixels": 3000,
        "points": 720
    },
    "meta": {
        "timestamp": "2026-06-03T17:42:13.158Z",
        "request_id": "c38fac87-af0d-48a7-bd2c-aaa501bf86da"
    },
    "status": "ok",
    "message": "Resolve",
    "success": true
}
```

### Meta

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

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

**Response:**
```json
{
    "data": {
        "name": "DPI & Print Size API",
        "notes": "1 inch = 2.54 cm = 25.4 mm = 72 points. Converting to/from px needs a dpi. Nothing is stored.",
        "version": "v1",
        "endpoints": [
            {
                "path": "/v1/resolve",
                "params": {
                    "dpi": "dots per inch",
                    "unit": "in|cm|mm|pt (default in)",
                    "length": "physical length",
                    "pixels": "pixel count"
                },
                "returns": "all of pixels, dpi and size (give any two)"
            },
            {
                "path": "/v1/ppi",
                "params": {
                    "width": "px",
                    "height": "px",
                    "diagonal": "screen diagonal in inches"
                },
                "returns": "PPI, dot pitch, megapixels and aspect ratio"
            },
            {
                "path": "/v1/convert",
                "params": {
                    "to": "px|in|cm|mm|pt",
                    "dpi": "needed when px is involved",
                    "from": "px|in|cm|mm|pt",
                    "value": "the length"
                },
                "returns": "the converted length"
            },
            {
                "path": "/v1/meta",
                "params": [],
                "returns": "this document"
            }
        ],
        "description": "Resolution, print-size and pixel-density maths for print, des
…(truncated, see openapi.json for full schema)
```


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