# Indent API
> Indent, dedent and convert tabs to spaces on plain text, line by line. The indent endpoint prefixes every line with a fixed indentation — a number of spaces or tabs, or any custom prefix like "> " for quoting — and can optionally indent blank lines too. The dedent endpoint removes the longest common leading whitespace from a block (the same idea as Python textwrap.dedent), so you can flatten an over-indented snippet and get back exactly which prefix was stripped. The tabs endpoint converts between tabs and spaces honouring tab stops — expand tabs to spaces or collapse runs of spaces back to tabs, at a chosen tab size, leading whitespace only or throughout. It works on any text without parsing it as code, and CRLF line endings are preserved. Pure local computation — no key, no third-party service, instant. Live, nothing stored. 4 endpoints. It only touches whitespace structure: to trim or sort lines use a lines API, to reflow long lines use a word-wrap API, and to reformat real source code use a code-formatter 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/indent-api/..."
```

## Pricing
- **Free** (Free) — 1,435 calls/Mo, 2 req/s
- **Starter** ($3/Mo) — 10,950 calls/Mo, 8 req/s
- **Pro** ($23/Mo) — 160,500 calls/Mo, 20 req/s
- **Mega** ($61/Mo) — 845,000 calls/Mo, 50 req/s

## Endpoints

### Indent

#### `GET /v1/dedent` — Dedent text

**Parameters:**
- `text` (query, required, string) — The text to dedent Example: `    a
      b`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/indent-api/v1/dedent?text=++++a%0A++++++b"
```

**Response:**
```json
{
    "data": {
        "text": "a\n  b",
        "lines": 2,
        "removed_length": 4,
        "removed_prefix": "    "
    },
    "meta": {
        "timestamp": "2026-06-03T09:25:07.275Z",
        "request_id": "0b781906-d20a-4b8d-87f0-e41624043d3f"
    },
    "status": "ok",
    "message": "Dedent text",
    "success": true
}
```

#### `GET /v1/indent` — Indent text

**Parameters:**
- `text` (query, required, string) — The text to indent Example: `a
b`
- `amount` (query, optional, string) — Number of units (default 4) Example: `4`
- `char` (query, optional, string) — 'space' or 'tab' (default space)
- `prefix` (query, optional, string) — Custom prefix (overrides amount/char)
- `blank_lines` (query, optional, string) — true to also indent empty lines

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/indent-api/v1/indent?text=a%0Ab&amount=4"
```

**Response:**
```json
{
    "data": {
        "text": "    a\n    b",
        "lines": 2,
        "prefix_length": 4
    },
    "meta": {
        "timestamp": "2026-06-03T09:25:07.378Z",
        "request_id": "ada36515-16aa-453f-9639-7de80d073b8c"
    },
    "status": "ok",
    "message": "Indent text",
    "success": true
}
```

#### `GET /v1/tabs` — Convert tabs/spaces

**Parameters:**
- `text` (query, required, string) — The text to convert Example: `	x`
- `mode` (query, optional, string) — 'expand' (tabs→spaces) or 'collapse' (spaces→tabs) Example: `expand`
- `tab_size` (query, optional, string) — Spaces per tab stop (default 4) Example: `4`
- `leading_only` (query, optional, string) — Only leading whitespace (default true)

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/indent-api/v1/tabs?text=%09x&mode=expand&tab_size=4"
```

**Response:**
```json
{
    "data": {
        "mode": "expand",
        "text": "    x",
        "lines": 1,
        "tab_size": 4,
        "leading_only": true
    },
    "meta": {
        "timestamp": "2026-06-03T09:25:07.481Z",
        "request_id": "b3169daf-99d4-490b-8a75-d1bcfc779486"
    },
    "status": "ok",
    "message": "Convert tabs and spaces",
    "success": true
}
```

### Meta

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

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

**Response:**
```json
{
    "data": {
        "name": "Indent API",
        "notes": "Operates purely on leading/whitespace structure — it does not trim or reflow text (use a lines or word-wrap API) and does not parse code grammar (use a code formatter). CRLF line endings are preserved. Nothing is stored.",
        "version": "v1",
        "endpoints": [
            {
                "path": "/v1/indent",
                "params": {
                    "char": "'space' or 'tab' (default space)",
                    "text": "the text (required)",
                    "amount": "number of units (default 4)",
                    "prefix": "custom prefix string (overrides amount/char)",
                    "blank_lines": "true to also indent empty lines (default false)"
                },
                "returns": "the indented text"
            },
            {
                "path": "/v1/dedent",
                "params": {
                    "text": "the text (required)"
                },
                "returns": "the dedented text plus the common prefix that was removed"
            },
            {
                "path": "/v1/tabs",
                "params": {
                    "mode": "'expand' (tabs→spaces) or 'collapse' (spaces→tabs)",
                    "text": "the text (required)",
                    "tab_size": "spaces per tab stop (default 4)",
                    "leading_only": "only convert leading whitespace (default true)"
                },
                "returns":
…(truncated, see openapi.json for full schema)
```


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