# UN/LOCODE API
> The UN/LOCODE registry (United Nations Code for Trade and Transport Locations) as an API — 116,000+ ports, airports, rail and road terminals and trade points across 249 countries. Resolve any 5-character code (e.g. USNYC → New York; DEHAM → Hamburg; NLRTM → Rotterdam) to its name, country, subdivision, transport functions (port, rail, road, airport, postal, …), IATA code and coordinates; search locations by name with country and function filters; or list every location in a country. UN/LOCODE is the standard used in shipping, logistics, customs and EDI. Ideal for supply-chain, freight, trade-compliance and logistics software.

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

## Pricing
- **Free** (Free) — 5,000 calls/Mo, 2 req/s
- **Starter** ($5/Mo) — 55,000 calls/Mo, 8 req/s
- **Pro** ($16/Mo) — 280,000 calls/Mo, 20 req/s
- **Mega** ($38/Mo) — 1,400,000 calls/Mo, 50 req/s

## Endpoints

### UN/LOCODE

#### `GET /v1/code` — A location by UN/LOCODE

**Parameters:**
- `code` (query, required, string) — 5-character UN/LOCODE, e.g. USNYC Example: `USNYC`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/locode-api/v1/code?code=USNYC"
```

**Response:**
```json
{
    "data": {
        "code": "USNYC",
        "iata": null,
        "name": "New York",
        "country": "US",
        "latitude": 40.7,
        "location": "NYC",
        "functions": [
            "Port",
            "Rail terminal",
            "Road terminal",
            "Airport",
            "Postal exchange"
        ],
        "longitude": -74,
        "subdivision": "NY"
    },
    "meta": {
        "timestamp": "2026-05-31T06:28:06.938Z",
        "request_id": "472962c1-acd1-4534-9417-4045b81c82e9"
    },
    "status": "ok",
    "message": "Location retrieved",
    "success": true
}
```

#### `GET /v1/country` — All locations in a country

**Parameters:**
- `country` (query, required, string) — 2-letter country code, e.g. DE Example: `DE`
- `function` (query, optional, string) — Filter by function, e.g. port
- `limit` (query, optional, string) — Max results (1-200, default 50) Example: `50`
- `offset` (query, optional, string) — Pagination offset Example: `0`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/locode-api/v1/country?country=DE&limit=50&offset=0"
```

**Response:**
```json
{
    "data": {
        "count": 50,
        "limit": 50,
        "total": 10025,
        "offset": 0,
        "country": "DE",
        "results": [
            {
                "code": "DE222",
                "name": "Brandscheid/Westerwald",
                "country": "DE",
                "latitude": 50.567,
                "functions": [
                    "Road terminal"
                ],
                "longitude": 7.917
            },
            {
                "code": "DE223",
                "name": "Brandshagen",
                "country": "DE",
                "latitude": 54.25,
                "functions": [
                    "Road terminal"
                ],
                "longitude": 13.183
            },
            {
                "code": "DE225",
                "name": "Braschwitz",
                "country": "DE",
                "latitude": 51.517,
                "functions": [
                    "Road terminal"
                ],
                "longitude": 12.067
            },
            {
                "code": "DE226",
                "name": "Bräsen",
                "country": "DE",
                "latitude": 51.967,
                "functions": [
                    "Road terminal"
                ],
                "longitude": 12.383
            },
            {
                "code": "DE229",
                "name": "Braunfels",
                "country": "DE",
                "latitude": 50.517,
                "functions
…(truncated, see openapi.json for full schema)
```

#### `GET /v1/search` — Search locations by name with country / function filters

**Parameters:**
- `q` (query, optional, string) — Name search, e.g. rotterdam Example: `rotterdam`
- `country` (query, optional, string) — 2-letter country, e.g. NL
- `function` (query, optional, string) — port | rail | road | airport | postal | multimodal | border
- `limit` (query, optional, string) — Results per page (1-100, default 20) Example: `20`
- `offset` (query, optional, string) — Pagination offset Example: `0`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/locode-api/v1/search?q=rotterdam&limit=20&offset=0"
```

**Response:**
```json
{
    "data": {
        "count": 3,
        "limit": 20,
        "query": "rotterdam",
        "total": 3,
        "offset": 0,
        "filters": {
            "country": null,
            "function": null
        },
        "results": [
            {
                "code": "NLRTM",
                "name": "Rotterdam",
                "country": "NL",
                "latitude": 51.917,
                "functions": [
                    "Port",
                    "Rail terminal",
                    "Road terminal",
                    "Airport",
                    "Postal exchange"
                ],
                "longitude": 4.5
            },
            {
                "code": "USRAJ",
                "name": "Rotterdam",
                "country": "US",
                "latitude": 42.783,
                "functions": [
                    "Port",
                    "Rail terminal",
                    "Road terminal"
                ],
                "longitude": -73.967
            },
            {
                "code": "USRJN",
                "name": "Rotterdam Junction",
                "country": "US",
                "latitude": null,
                "functions": [
                    "Road terminal"
                ],
                "longitude": null
            }
        ]
    },
    "meta": {
        "timestamp": "2026-05-31T06:28:07.093Z",
        "request_id": "665e8de8-a570-4665-80c2-e5e357045e14"
    },
    "status": "ok",
    "message": "Locat
…(truncated, see openapi.json for full schema)
```

### Meta

#### `GET /v1/meta` — Totals & functions

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

**Response:**
```json
{
    "data": {
        "note": "5-character code = 2-letter country + 3-character location. Functions indicate port/rail/road/airport/postal/etc.",
        "total": 116213,
        "fields": [
            "code",
            "country",
            "location",
            "name",
            "subdivision",
            "iata",
            "functions",
            "latitude",
            "longitude"
        ],
        "source": "UN/LOCODE — UN Code for Trade and Transport Locations",
        "countries": 249,
        "functions": [
            "port",
            "rail",
            "road",
            "airport",
            "postal",
            "multimodal",
            "fixed",
            "border"
        ],
        "with_coordinates": 93151
    },
    "meta": {
        "timestamp": "2026-05-31T06:28:07.152Z",
        "request_id": "9d304420-653f-4de4-90da-d83625c66d69"
    },
    "status": "ok",
    "message": "Meta retrieved",
    "success": true
}
```


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