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 word

  • language_code (LanguageCodes) – language of the searched word

Raise
ValueError

raised if word is empty

TypeError

raised if language_code is not an instance of LanguageCodes

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