URL generating¶
- class freedictionaryapi.urls.ApiUrl(word: str, *, language_code: freedictionaryapi.languages.LanguageCodes = <LanguageCodes.ENGLISH_US: 'en_US'>)[source]¶
Implements API URL object.
- API_URL_PATTERN: str = 'https://api.dictionaryapi.dev/api/v2/entries/{language_code}/{word}'¶
Pattern of the API URL
- __init__(word: str, *, language_code: freedictionaryapi.languages.LanguageCodes = <LanguageCodes.ENGLISH_US: 'en_US'>) → None[source]¶
Init API URL instance.
- Parameters
word (
str) – searched wordlanguage_code (
LanguageCodes) – language of the searched word
- Raise
- ValueError
raised if
wordis empty- TypeError
raised if
language_codeis not an instance ofLanguageCodes
- get_url() → str[source]¶
Get prepared (with substituted word and language code) URL that is ready for request.
- Returns
prepared URL
- Return type
str
- property language_code: freedictionaryapi.languages.LanguageCodes¶
- Returns
language code
- Return type
LanguageCodes
- property word: str¶
- Returns
word
- Return type
str