Yandex Dictionary Api
Package to access the Yandex.Dictionary API over HTTP.
Getting Started
In the pubspec.yaml
of your flutter project, add the following dependency:
dependencies:
...
yandex_dictionary_api: ^latest
Import it:
import 'package:yandex_dictionary_api/yandex_dictionary_api.dart';
Usage Examples
Create the Yandex Dictionary API object as follows.
final yandexDictionaryKey = YandexDictionaryKey(apiKey: '');
final yandexDictionaryApi = YandexDictionaryApi(key: yandexDictionaryKey);
You can call 2 functions with yandexDictionaryApi: getLangs
and lookup
.
- getLangs
Returns a list of translation directions supported by the service.
final getLangsResponse = await yandexDictionaryApi.getLangs();
The lookup service can be used with the language list returned from here.
- lookup
Searches for a word or phrase in the dictionary and returns an automatically generated dictionary entry.
final lookupRequest = YandexLookupRequest(lang: 'en-ru', text: 'hello');
final result = await yandexDictionaryApi.lookup(lookupRequest);
Error Handling
API throws YandexDictionaryException in incorrect cases.
- YandexDictionaryInvalidKeyException
Thrown when invalid API key.
- YandexDictionaryBlockedKeyException
Thrown when this API key has been blocked.
- YandexDictionaryDailyRequestLimitException
Exceeded the daily limit on the number of requests.
- YandexDictionaryTextTooLongException
The text size exceeds the maximum.
- YandexDictionaryLangNotSupportedException
The specified translation direction is not supported.
- YandexDictionaryUnknownException
Thrown when unknown error cases.
For more API documentation
Libraries
- yandex_dictionary_api
- The API is used for getting detailed dictionary entries from the static Yandex.Dictionary. Unlike conventional translation dictionaries, it is compiled automatically using the technologies at the root of the Yandex machine translation system. Yandex.Dictionary entries include the word’s part of speech, and translations are grouped with examples. For English words, the transcription is provided. The service supports a total of 17 language pairs.