# WKT API
> Convert geometry between WKT (Well-Known Text) and GeoJSON, in both directions. WKT is the textual geometry format used by PostGIS, Spatialite, GEOS, JTS, Shapely and the OGC Simple Features standard (POINT (30 10), LINESTRING (...), POLYGON ((...))); GeoJSON is what web maps and JavaScript expect. The to-geojson endpoint turns a WKT string into a GeoJSON geometry, and to-wkt does the reverse from a GeoJSON geometry or Feature. Supports Point, LineString, Polygon, MultiPoint, MultiLineString, MultiPolygon and GeometryCollection. Perfect for bridging a spatial database and a front-end map, importing and exporting geometry, and data-migration scripts. Pure local computation — no key, no third-party service, instant; send large geometries via POST. Live, nothing stored. 3 endpoints. Distinct from coordinate-format conversion, EPSG/CRS lookups, slippy map tiles and GeoJSON geospatial metrics.

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

## Pricing
- **Free** (Free) — 920 calls/Mo, 2 req/s
- **Starter** ($2/Mo) — 7,700 calls/Mo, 8 req/s
- **Pro** ($21/Mo) — 133,000 calls/Mo, 20 req/s
- **Mega** ($57/Mo) — 685,000 calls/Mo, 50 req/s

## Endpoints

### WKT

#### `GET /v1/to-geojson` — Convert WKT to GeoJSON

**Parameters:**
- `wkt` (query, required, string) — WKT geometry string Example: `POLYGON ((30 10, 40 40, 20 40, 10 20, 30 10))`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/wkt-api/v1/to-geojson?wkt=POLYGON+%28%2830+10%2C+40+40%2C+20+40%2C+10+20%2C+30+10%29%29"
```

**Response:**
```json
{
    "data": {
        "geometry": {
            "type": "Polygon",
            "coordinates": [
                [
                    [
                        30,
                        10
                    ],
                    [
                        40,
                        40
                    ],
                    [
                        20,
                        40
                    ],
                    [
                        10,
                        20
                    ],
                    [
                        30,
                        10
                    ]
                ]
            ]
        }
    },
    "meta": {
        "timestamp": "2026-06-02T16:51:46.471Z",
        "request_id": "f5c8cdfe-6eb9-4c23-aa8e-283392fd5b3a"
    },
    "status": "ok",
    "message": "WKT to GeoJSON",
    "success": true
}
```

#### `GET /v1/to-wkt` — Convert GeoJSON to WKT

**Parameters:**
- `geojson` (query, required, string) — GeoJSON geometry or Feature Example: `{"type":"Point","coordinates":[30,10]}`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/wkt-api/v1/to-wkt?geojson=%7B%22type%22%3A%22Point%22%2C%22coordinates%22%3A%5B30%2C10%5D%7D"
```

**Response:**
```json
{
    "data": {
        "wkt": "POINT (30 10)"
    },
    "meta": {
        "timestamp": "2026-06-02T16:51:46.577Z",
        "request_id": "71abae52-028c-4c0d-ab4a-118215487ca6"
    },
    "status": "ok",
    "message": "GeoJSON to WKT",
    "success": true
}
```

### Meta

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

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

**Response:**
```json
{
    "data": {
        "name": "WKT API",
        "notes": "Coordinates use [longitude, latitude] order in GeoJSON and (x y) = (lon lat) in WKT. Pass a single geometry; a FeatureCollection is not a single WKT geometry. Send large geometries via POST.",
        "version": "v1",
        "endpoints": [
            {
                "path": "/v1/to-geojson",
                "params": {
                    "wkt": "a WKT string, e.g. POINT (30 10) (required)"
                },
                "returns": "the GeoJSON geometry"
            },
            {
                "path": "/v1/to-wkt",
                "params": {
                    "geojson": "a GeoJSON geometry or Feature (required)"
                },
                "returns": "the WKT string"
            },
            {
                "path": "/v1/meta",
                "params": [],
                "returns": "this document"
            }
        ],
        "description": "Convert geometry between WKT (Well-Known Text, as used by PostGIS, GEOS, Shapely and OGC) and GeoJSON, in both directions. Supports Point, LineString, Polygon, their Multi* variants and GeometryCollection. Pure local, no key."
    },
    "meta": {
        "timestamp": "2026-06-02T16:51:46.682Z",
        "request_id": "6112d8fa-7ae4-474a-a9c9-83c327c8b2b6"
    },
    "status": "ok",
    "message": "Meta",
    "success": true
}
```


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