---
title: "Punycode converter: IDN domain to ASCII and back, with IDNA2008 label validation"
method: GET
path: "/v1/code/idn"
tags: ["deterministic", "no-api-key", "code", "domains", "idna", "punycode"]
---

# Punycode converter: IDN domain to ASCII and back, with IDNA2008 label validation

`GET /v1/code/idn`

## Request

- Base URL: `https://api.duoleads.com`
- URL: `https://api.duoleads.com/v1/code/idn`
- Auth: none declared

Punycode converter: convert internationalised domain names between Unicode and ASCII punycode in either direction, label by label, and validate each label against IDNA2008: length, leading and trailing hyphens, the hyphen-hyphen rule at positions 3 and 4, disallowed code points and bidirectional rules. Returns both forms, the per-label breakdown and the first rule violated. Strict mode is IDNA2008 (UTS 46 non-transitional); it may reject names /v1/code/url displays.

**Output (`data`):** ascii (string|null, null only when a label cannot be converted at all, e.g. a disallowed code point; a label that merely breaks a hyphen rule is still converted, valid:false), unicode (string|null, same), valid, labels [{index, unicode, ascii (string|null), length (integer|null, null when the label cannot be converted), punycoded, valid, reason (string|null)}], reason (first failure or null), total_length (integer|null, null when a label cannot be converted).

Deterministic: identical input returns identical output, so the response is served with `Cache-Control: private, max-age=31536000, immutable` (the paying client may cache it indefinitely; shared caches must not, because the response is paid).

Sources: unicode-idna-tables Unicode 17.0.0 (UTS #46 IdnaMappingTable via tr46 6.0.0) (published 2026-09-29, Unicode License v3). Echoed in `meta.sources`.

Price: $0.05 USDC per call (x402, Base). Route contract version 1.0.0. Docs: https://api.duoleads.com/docs#code-idn

## Query parameters

- `domain` string, required
- `to` 'ascii' | 'unicode' | 'both'
- `strict` boolean

## Response `200`

Paid and settled. `data` is route-specific; a route that judges its input returns 200 with `data.valid: false` for a bad value.

- object
  - `ok` unknown, required
  - `route` '/v1/code/idn', required
  - `version` '1.0.0', required
  - `data` object, required: ascii (string|null, null only when a label cannot be converted at all, e.g. a disallowed code point; a label that merely breaks a hyphen rule is still converted, valid:false), unicode (string|null, same), valid, labels [{index, unicode, ascii (string|null), length (integer|null, null when the label cannot be converted), punycoded, valid, reason (string|null)}], reason (first failure or null), total_length (integer|null, null when a label cannot be converted).
    - `ascii` string, nullable, required
    - `unicode` string, nullable, required
    - `valid` boolean, required
    - `labels` object[], required
      - `index` integer, required
      - `unicode` string, required
      - `ascii` string, nullable, required
      - `length` integer, nullable, required
      - `punycoded` boolean, required
      - `valid` boolean, required
      - `reason` string, nullable, required
    - `reason` string, nullable, required
    - `total_length` integer, nullable, required
  - `meta` Meta, required
    - `disclaimer` string, required: Legal short disclaimer, identical on every response.
    - `request_id` string, required: ULID.
    - `computed_at` string, date-time, required: RFC 3339 UTC with milliseconds.
    - `price_usd` string, required: Decimal string, "0.05".
    - `deterministic` boolean, required
    - `sources` object[]: Present only on routes that read a vendored dataset: the exact edition that answered.
      - `id` string, required
      - `version` string, required
      - `published` string, required
      - `attribution` string
      - `licence` string

## Other responses

- `400`: MISSING_PARAM, INVALID_PARAM or UNSUPPORTED_VALUE. Not charged: validation runs before the paywall.
- `402`: Payment required. No valid PAYMENT-SIGNATURE was supplied: read the base64 PAYMENT-REQUIRED header (or this body) for the price ($0.05 = 50000 atomic USDC on eip155:8453), sign an EIP-3009 authorization and retry. Also returned when settlement is declined (PAYMENT_FAILED). Nothing is charged on a 402.
- `404`: NOT_FOUND: unknown path. Not charged.
- `405`: METHOD_NOT_ALLOWED: only GET and HEAD are served. Not charged.
- `413`: INPUT_TOO_LARGE: a parameter exceeded its documented maximum length. Not charged.
- `500`: INTERNAL: a server bug. Not charged.

---

[API](https://skmtc.dev/duoleads/apis/duo-data-utilities-iban-isin-vat-tax-id-barcode-timezone-geo.md) · [All operations](https://skmtc.dev/duoleads/apis/duo-data-utilities-iban-isin-vat-tax-id-barcode-timezone-geo/llms.txt) · [OpenAPI document](https://skmtc.dev/duoleads/apis/duo-data-utilities-iban-isin-vat-tax-id-barcode-timezone-geo/revisions/18790d59615e?raw)
