# Dotenv API
> Convert between .env (dotenv) files and JSON, in both directions. The parse endpoint reads .env text into a clean JSON object: it skips blank lines and # comments, honours an optional leading export, unquotes single- and double-quoted values (interpreting \n, \t and \" escapes inside double quotes), strips inline comments after unquoted values, supports values that span several lines inside quotes, and can optionally expand ${VAR} and $VAR references against the variables already defined earlier in the same file — while leaving single-quoted values strictly literal. The stringify endpoint turns a JSON object back into a valid .env file, quoting only the values that actually need it and optionally prefixing every line with export for shell sourcing. Everything is computed locally and deterministically, so it is instant and private — your secrets never leave the request. Ideal for config tooling and migrations, CI/CD pipelines, converting .env to JSON for apps that want structured config (and back), and validating environment files. Pure local computation — no key, no third-party service, instant. Live, nothing stored. 3 endpoints. This handles the dotenv format; for INI files with [sections] use an INI API, and for YAML or TOML use those APIs.

## 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/dotenv-api/..."
```

## Pricing
- **Free** (Free) — 4,235 calls/Mo, 2 req/s
- **Starter** ($6/Mo) — 13,750 calls/Mo, 8 req/s
- **Pro** ($26/Mo) — 188,500 calls/Mo, 20 req/s
- **Mega** ($64/Mo) — 985,000 calls/Mo, 50 req/s

## Endpoints

### Dotenv

#### `GET /v1/parse` — Parse a .env file

**Parameters:**
- `env` (query, required, string) — The .env file text Example: `FOO=bar
export BAZ="hello world"`
- `expand` (query, optional, string) — Expand ${VAR}/$VAR references (default false)

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/dotenv-api/v1/parse?env=FOO%3Dbar%0Aexport+BAZ%3D%22hello+world%22"
```

**Response:**
```json
{
    "data": {
        "count": 2,
        "parsed": {
            "BAZ": "hello world",
            "FOO": "bar"
        },
        "expanded": false
    },
    "meta": {
        "timestamp": "2026-06-03T17:42:21.771Z",
        "request_id": "ce5aa50c-af0c-4c00-bf8a-92f1ee1b069d"
    },
    "status": "ok",
    "message": "Parse a .env file",
    "success": true
}
```

#### `GET /v1/stringify` — Build a .env file

**Parameters:**
- `json` (query, required, string) — An object (JSON) to serialize Example: `{"HOST":"localhost","PORT":"5432"}`
- `export` (query, optional, string) — true to prefix each line with export

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/dotenv-api/v1/stringify?json=%7B%22HOST%22%3A%22localhost%22%2C%22PORT%22%3A%225432%22%7D"
```

**Response:**
```json
{
    "data": {
        "env": "HOST=localhost\nPORT=5432",
        "count": 2
    },
    "meta": {
        "timestamp": "2026-06-03T17:42:21.879Z",
        "request_id": "9b7099a8-43fc-4ea1-ba96-044b34ba915d"
    },
    "status": "ok",
    "message": "Build a .env file",
    "success": true
}
```

### Meta

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

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

**Response:**
```json
{
    "data": {
        "name": "Dotenv API",
        "notes": "Single-quoted values are literal (never expanded); double-quoted values interpret escapes and may be expanded. This handles the dotenv format — for INI files with [sections] use an INI API, and for YAML/TOML use those APIs. Nothing is stored.",
        "version": "v1",
        "endpoints": [
            {
                "path": "/v1/parse",
                "params": {
                    "env": "the .env file text (required)",
                    "expand": "expand ${VAR}/$VAR references (default false)"
                },
                "returns": "the parsed key/value object"
            },
            {
                "path": "/v1/stringify",
                "params": {
                    "json": "an object (JSON) to serialize (required)",
                    "export": "true to prefix each line with export"
                },
                "returns": "the .env file text"
            },
            {
                "path": "/v1/meta",
                "params": [],
                "returns": "this document"
            }
        ],
        "description": "Convert between .env (dotenv) files and JSON, both ways. The parse endpoint reads .env text into a clean JSON object — skipping blank lines and # comments, honouring an optional leading export, unquoting single- and double-quoted values (with \\n, \\t and \\\" escapes inside double quotes), stripping inline comments after unquoted values, supporting v
…(truncated, see openapi.json for full schema)
```


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