# Vietnamese Dictionary & Word Chain API

> Look up 41,000+ Vietnamese words from Wiktionary (accents optional): meanings, examples, synonyms, IPA, chữ Hán, plus helpers for nối từ word-chain bots.

- Endpoint: `GET | POST https://apibox.io.vn/v1/vn-dictionary`
- Category: Text
- HTML docs: https://apibox.io.vn/docs/vn-dictionary/ (Vietnamese: https://apibox.io.vn/vi/docs/vn-dictionary/)
- Online tool: https://apibox.io.vn/tools/vn-dictionary/
- Authentication: `Authorization: Bearer <API key>` or `X-API-Key: <API key>` (free key: https://apibox.io.vn/dashboard/#signup)

The dictionary holds the Vietnamese headwords of the Vietnamese Wiktionary (about 41,500 entries, extracted by wiktextract / kaikki.org, refreshed weekly). `word` can be typed with or without accents (`hoc sinh` finds `học sinh`); an entry gives the parts of speech with Vietnamese and English labels, definitions with examples, synonyms and antonyms when Wiktionary has them, the IPA of Hà Nội and Sài Gòn, the chữ Hán / Nôm form and etymology, and a link to the Wiktionary page. `action=suggest&q=nha t` autocompletes.

`action=chain` serves "nối từ" game bots (Discord, Zalo, Messenger): it says whether a two-syllable word is valid (about 26,800 common two-syllable words, no proper nouns or idioms), checks the link with `previous`, lists continuations starting with the last syllable (excluding `used` words), flags dead ends and, with `strategy=trap`, sorts replies that leave the opponent the fewest moves. Without `word` it proposes a start word. `action=random` draws words by `syllables`, `pos` or `letters` (for guessing games).

Definitions are licensed CC BY-SA 4.0: every answer carries the attribution; credit Wiktionary and share derived data under the same licence.

## Parameters

| Name | In | Type | Required | Default | Description |
|---|---|---|---|---|---|
| `word` | query|body | string | no |  | Word to look up (accents optional) or to check in the chain. |
| `action` | query|body | string | no | `lookup` | `lookup`, `suggest`, `chain`, `random` or `stats`. |
| `q` | query|body | string | no |  | suggest: beginning of a word. |
| `previous` | query|body | string | no |  | chain: the previous word, to check the link. |
| `used` | query|body | array | no |  | chain: words already played. |
| `strategy` | query|body | string | no | `any` | chain: `any`, `trap`, `safe` or `random` ordering of candidates. |
| `syllables` | query|body | number | no |  | random: number of syllables. |
| `pos` | query|body | string | no |  | random: part of speech (`noun`, `verb`, `adj`…). |
| `examples` | query|body | boolean | no | `true` | lookup: include examples. |
| `limit` | query|body | number | no | `20` | Maximum suggestions / candidates. |

## Example request

```bash
curl "https://apibox.io.vn/v1/vn-dictionary?word=hoc%20sinh" \
  -H "Authorization: Bearer YOUR_API_KEY"
```

## Example response

```json
{
  "query": "hoc sinh",
  "match": "folded",
  "count": 1,
  "entries": [
    {
      "word": "học sinh",
      "syllables": 2,
      "meanings": [
        {
          "pos": "noun",
          "pos_en": "noun",
          "pos_vi": "danh từ",
          "senses": [
            {
              "definition": "Trẻ em học tập ở nhà trường.",
              "examples": [
                "Học sinh trung học.",
                "Học sinh tiên tiến."
              ]
            }
          ]
        }
      ],
      "synonyms": [
        "sĩ tử",
        "giám sinh",
        "học viên",
        "sinh viên"
      ],
      "antonyms": [],
      "ipa": {
        "ha_noi": "ha̰ʔwk˨˩ sïŋ˧˧",
        "sai_gon": "hawk˨˩˨ ʂɨn˧˧"
      },
      "han_nom": "學生",
      "etymology": "Âm Hán-Việt của chữ Hán 學生.",
      "in_word_chain_list": true,
      "url": "https://vi.wiktionary.org/wiki/h%E1%BB%8Dc_sinh"
    }
  ],
  "attribution": {
    "source": "Wiktionary tiếng Việt (vi.wiktionary.org), extracted by wiktextract / kaikki.org",
    "license": "CC BY-SA 4.0",
    "license_url": "https://creativecommons.org/licenses/by-sa/4.0/",
    "authors": "Wiktionary contributors",
    "note": "Definitions are shared under CC BY-SA 4.0: credit Wiktionary and share derived data under the same licence."
  }
}
```

## Use cases

- Run a nối từ bot on Discord or Zalo with a dictionary of known licence
- Show definitions and pronunciation in a Vietnamese learning app
- Autocomplete Vietnamese words typed without accents
- Draw random words for word-guessing games

## FAQ

### Where do the definitions come from?

From the Vietnamese Wiktionary (CC BY-SA 4.0), extracted by wiktextract / kaikki.org and rebuilt weekly. Some old-format entries have short definitions.

### Which words are allowed in the word chain?

Lowercase two-syllable common words of the dictionary; proper nouns, idioms, phrases and abbreviations are excluded.

### Do I have to type accents?

No. Lookups try the exact word, then case-insensitive, then accent-insensitive matches, and return every candidate.
