# Pad API
> Pad and align strings to a target width. The pad endpoint adds a fill character to the start, end, or both sides of a value until it reaches the width you ask for — zero-pad a number (7 → 007), right-align a price column, centre a heading, or build a fixed-width field — with any fill string (space, 0, dash, dots) and an optional truncate flag to cut values that are already too long. The align endpoint takes a whole list of lines (or newline-separated text) and pads every line to a common width, so columns line up in fixed-width tables, ASCII layouts, receipts, invoices and logs. Width is counted in Unicode code points, so emoji and accented letters each count as one and never get split. Pure local computation — no key, no third-party service, instant. Live, nothing stored. 3 endpoints. This pads to a width; to wrap long text across lines use a word-wrap API, and to convert between case styles use a text-case 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/pad-api/..."
```

## Pricing
- **Free** (Free) — 1,335 calls/Mo, 2 req/s
- **Starter** ($3/Mo) — 10,850 calls/Mo, 8 req/s
- **Pro** ($23/Mo) — 159,500 calls/Mo, 20 req/s
- **Mega** ($61/Mo) — 840,000 calls/Mo, 50 req/s

## Endpoints

### Pad

#### `GET /v1/align` — Align lines

**Parameters:**
- `lines` (query, optional, string) — JSON array of strings Example: `["a","bbb","cc"]`
- `text` (query, optional, string) — Newline-separated lines (alternative to lines)
- `width` (query, optional, string) — Target width (default = longest line)
- `side` (query, optional, string) — start|end|both (default start)
- `fill` (query, optional, string) — Fill string (default space)
- `truncate` (query, optional, string) — true to cut long lines

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/pad-api/v1/align?lines=%5B%22a%22%2C%22bbb%22%2C%22cc%22%5D"
```

**Response:**
```json
{
    "data": {
        "side": "start",
        "count": 3,
        "width": 3,
        "joined": "  a\nbbb\n cc",
        "aligned": [
            "  a",
            "bbb",
            " cc"
        ]
    },
    "meta": {
        "timestamp": "2026-06-03T09:25:07.709Z",
        "request_id": "bbb780fc-2fb4-49b7-933a-677d6206380d"
    },
    "status": "ok",
    "message": "Align lines",
    "success": true
}
```

#### `GET /v1/pad` — Pad a value

**Parameters:**
- `value` (query, required, string) — The string to pad Example: `7`
- `length` (query, required, string) — Target width in characters Example: `3`
- `side` (query, optional, string) — start|left, end|right, both|center (default start)
- `fill` (query, optional, string) — Fill string, default space Example: `0`
- `truncate` (query, optional, string) — true to cut a value longer than length

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/pad-api/v1/pad?value=7&length=3&fill=0"
```

**Response:**
```json
{
    "data": {
        "side": "start",
        "added": 2,
        "width": 3,
        "padded": "007",
        "truncated": false,
        "padded_length": 3,
        "original_length": 1
    },
    "meta": {
        "timestamp": "2026-06-03T09:25:07.809Z",
        "request_id": "75d9f8cb-6703-405c-9c20-be60b3da9124"
    },
    "status": "ok",
    "message": "Pad a value",
    "success": true
}
```

### Meta

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

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

**Response:**
```json
{
    "data": {
        "name": "Pad API",
        "notes": "Width is counted in Unicode code points, so emoji and accented letters count as one. Nothing is stored.",
        "version": "v1",
        "endpoints": [
            {
                "path": "/v1/pad",
                "params": {
                    "fill": "fill string, default space; repeated and trimmed to fit",
                    "side": "start|left, end|right, both|center (default start)",
                    "value": "the string (required)",
                    "length": "target width in characters (required)",
                    "truncate": "true to cut the value when it is longer than length"
                },
                "returns": "the padded string + length metadata"
            },
            {
                "path": "/v1/align",
                "params": {
                    "fill": "fill string (default space)",
                    "side": "start|end|both (default start)",
                    "text": "newline-separated lines (alternative to lines)",
                    "lines": "JSON array of strings (or use text)",
                    "width": "target width (default = longest line)",
                    "truncate": "true to cut long lines to width"
                },
                "returns": "the aligned lines as an array and joined with newlines"
            },
            {
                "path": "/v1/meta",
                "params": [],
                "returns": "this document"
      
…(truncated, see openapi.json for full schema)
```


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