A summary of the provided functions in the krdict
module and the arguments they expect.
With the exception of set_key
and set_default
,
all of the functions listed below expect keyword arguments.
The krdict
module also exports all of the enumerations described in
the parameter types of the functions below.
advanced_search¶
Performs an advanced search on the Korean Learners' Dictionary API.
def advanced_search(*,
query: str,
raise_api_errors: bool = False,
guarantee_keys: bool = False,
key: str = None,
page: int = 1,
per_page: int = 10,
sort: SortMethod = SortMethod.ALPHABETICAL,
search_type: SearchType = SearchType.WORD,
translation_language: TranslationLanguage | Iterable[TranslationLanguage] = None,
search_target: SearchTarget = SearchTarget.HEADWORD,
target_language: TargetLanguage = TargetLanguage.ALL,
search_method: SearchMethod = SearchMethod.EXACT,
classification: Classification | Iterable[Classification] = Classification.ALL,
origin_type: OriginType | Iterable[OriginType] = OriginType.ALL,
vocabulary_grade: VocabularyLevel | Iterable[VocabularyLevel] = VocabularyLevel.ALL,
part_of_speech: PartOfSpeech | Iterable[PartOfSpeech] = PartOfSpeech.ALL,
multimedia_info: MultimediaType | Iterable[MultimediaType] = MultimediaType.ALL,
min_syllables: int = 1,
max_syllables: int = 0,
meaning_category: MeaningCategory = MeaningCategory.ALL,
subject_category: SubjectCategory | Iterable[SubjectCategory] = SubjectCategory.ALL,
options: OptionsDict = None
) -> SearchResponse | KRDictError: ...
Warning
Use of any search type other than SearchType.WORD
for the search_type
parameter with advanced search is
undefined behavior. It is likely that incomplete or empty results will be returned.
The parameter is included for completeness, but is not recommended for usage.
Parameters:
query
: The search query.raise_api_errors
: Sets whether aKRDictException
will be raised if an API error occurs. A value ofTrue
guarantees that the result is not an error object.guarantee_keys
: Sets whether keys that are missing from the response should be inserted with default values. A value ofTrue
guarantees that every key marked as not required is included, including keys set by the scraper. Default values:- The empty string
""
for string values. - Zero
0
for integer values. - An empty list
[]
for list values.
- The empty string
key
: The API key. If a key was set withset_key
, this can be omitted.page
: The page at which the search should start[1, 1000]
.per_page
: The maximum number of search results to return[10, 100]
.sort
(SortMethod
): The sort method that should be used.search_type
(SearchType
): The type of search to perform.translation_language
(TranslationLanguage
): A language for which translations should be included.search_target
(SearchTarget
): The target field of the search query.target_language
(TargetLanguage
): The original language to search by. Ifsearch_target
is set to any value other than'original_language'
, this parameter has no effect.search_method
(SearchMethod
): The method used to match against the query.classification
(Classification
): An entry classification to filter by.origin_type
(OriginType
): A word origin type to filter by.vocabulary_grade
(VocabularyLevel
): A vocabulary level to filter by.part_of_speech
(PartOfSpeech
): A part of speech to filter by.multimedia_info
(MultimediaType
): A multimedia type to filter by.min_syllables
: The minimum number of syllables in result words[1, 80]
.max_syllables
: The maximum number of syllables in results words. A value of0
denotes no maximum[0, 80]
.meaning_category
(MeaningCategory
): The meaning category to filter by.subject_category
(SubjectCategory
): A subject category to filter by.options
(OptionsDict
): Additional options to apply.
Returns:
Depending on the value of search_type
and whether an error occurred, returns one of:
WordSearchResponse
DefinitionSearchResponse
(potentially empty or incomplete)ExampleSearchResponse
(potentially empty or incomplete)IdiomProverbSearchResponse
(potentially empty or incomplete)KRDictError
search¶
Performs a basic search on the Korean Learners' Dictionary API.
def search(*,
query: str,
raise_api_errors: bool = False,
guarantee_keys: bool = False,
key: str = None,
page: int = 1,
per_page: int = 10,
sort: SortMethod = SortMethod.ALPHABETICAL,
search_type: SearchType = SearchType.WORD,
translation_language: TranslationLanguage | Iterable[TranslationLanguage] = None,
options: OptionsDict = None
) -> SearchResponse | KRDictError: ...
Parameters:
query
: The search query.raise_api_errors
: Sets whether aKRDictException
will be raised if an API error occurs. A value ofTrue
guarantees that the result is not an error object.guarantee_keys
: Sets whether keys that are missing from the response should be inserted with default values. A value ofTrue
guarantees that every key marked as not required is included, including keys set by the scraper. Default values:- The empty string
""
for string values. - Zero
0
for integer values. - An empty list
[]
for list values.
- The empty string
key
: The API key. If a key was set withset_key
, this can be omitted.page
: The page at which the search should start[1, 1000]
.per_page
: The maximum number of search results to return[10, 100]
.sort
(SortMethod
): The sort method that should be used.search_type
(SearchType
): The type of search to perform.translation_language
(TranslationLanguage
): A language for which translations should be included.options
(OptionsDict
): Additional options to apply.
Returns:
Depending on the value of search_type
and whether an error occurred, returns one of:
WordSearchResponse
DefinitionSearchResponse
ExampleSearchResponse
IdiomProverbSearchResponse
KRDictError
set_default¶
Sets a default value for a library option.
def set_default(name: Option, value: bool) -> None: ...
Parameters:
name
: The name of the option to set. Accepted values:'fetch_multimedia'
: Controls whether multimedia is scraped during view queries. No effect unless the'use_scraper'
option isTrue
.'fetch_page_data'
: Controls whether pronunciation URLs and extended language information are scraped. No effect unless the'use_scraper'
option isTrue
.'raise_scraper_errors'
: Controls whether errors that occur during scraping are raised. No effect unless the'use_scraper'
option isTrue
.'use_scraper'
: Controls whether the scraper should be used to fetch more information.
value
: The new default value of the option.
set_key¶
Sets a default API key to use, if one is not provided in a query.
def set_key(key: str | None) -> None: ...
Parameters:
- key: The Korean Learners' Dictionary API key. To unset a key, use
None
.
view¶
Performs a view query, which retrieves information about a particular entry, on the Korean Learners' Dictionary API.
def view(*,
query: str,
homograph_num: int = 0,
raise_api_errors: bool = False,
guarantee_keys: bool = False,
key: str = None,
translation_language: TranslationLanguage | Iterable[TranslationLanguage] = None,
options: OptionsDict = None
) -> ViewResponse | KRDictError: ...
def view(*,
target_code: int,
raise_api_errors: bool = False,
guarantee_keys: bool = False,
key: str = None,
translation_language: TranslationLanguage | Iterable[TranslationLanguage] = None,
options: OptionsDict = None
) -> ViewResponse | KRDictError: ...
Parameters:
query
: The search query.homograph_num
: The superscript number used to distinguish homographs.target_code
: The target code of the desired result.raise_api_errors
: Sets whether aKRDictException
will be raised if an API error occurs. A value ofTrue
guarantees that the result is not an error object.guarantee_keys
: Sets whether keys that are missing from the response should be inserted with default values. A value ofTrue
guarantees that every key marked as not required is included, including keys set by the scraper. Default values:- The empty string
""
for string values. - Zero
0
for integer values. - An empty list
[]
for list values.
- The empty string
key
: The API key. If a key was set withset_key
, this can be omitted.translation_language
(TranslationLanguage
): A language for which translations should be included.options
(OptionsDict
): Additional options to apply.
Returns:
Depending on whether an error occurred, returns ViewResponse
or
KRDictError
.