A package that helps with querying the Korean Learners' Dictionary API.


Keywords
korean, dictionary, api, python
License
MIT
Install
pip install krdict.py==3.0.2

Documentation

krdict.py

PyPI Documentation Tests
krdict.js

A python package that helps to query the API of the Korean Learners' Dictionary, provided by the National Institute of Korean Language.

Installation

To install the package via pip, run:

pip install krdict.py

You can also install from one of the releases.

Usage

To use most of the functionality provided by this package, you'll need to generate an API key via the portal (requires login).

A minimal example query that assumes the KRDICT_KEY environment variable is set:

import os
import json
import krdict

krdict.set_key(os.getenv('KRDICT_KEY'))
response = krdict.search(query='λ‚˜λ¬΄', raise_api_errors=True)

print(json.dumps(response.asdict(), indent=2, ensure_ascii=False))

Assuming an error does not occur, the output will be similar to:

{
  "data": {
    ...
    "results": [
      {
        "target_code": 32750,
        "word": "λ‚˜λ¬΄",
        "pronunciation": "λ‚˜λ¬΄",
        ...
        "definitions": [
          {
            "order": 1,
            "definition": "λ‹¨λ‹¨ν•œ 쀄기에 가지와 잎이 달린, μ—¬λŸ¬ ν•΄ λ™μ•ˆ μžλΌλŠ” 식물."
          },
          ...
        ]
      },
      ...
    ]
  },
  "request_params": {
    "q": "λ‚˜λ¬΄",
    "key": "YOUR_API_KEY"
  }
}

For more information and usage examples, please check the documentation.