Response parser¶
- class freedictionaryapi.parsers.response_parser.DictionaryApiParser(response: Union[dict, list])[source]¶
Bases:
freedictionaryapi.parsers.base_parser.BaseDictionaryApiParserImplements dictionary API response parser. Parses from API json response in
ParsedObjecttypes.For getting data like from simple API response but with fields hinting: get
Wordobject withwordproperty and navigate through.For getting some sample data quickly it is possible to use some of prepared methods and properties.
- __init__(response: Union[dict, list]) → None[source]¶
Init dictionary API parser response instance. Parse API response.
responsehas typeUnion[dict, list]since in response we have such format and simpler would be just with the web library do like this:response.json()- to get python object loaded from json.- Parameters
response (
Union[dict, list]) – API json response loaded in python object
- property data: dict¶
- Returns
API response data
- Return type
dict
- get_all_definitions() → List[str][source]¶
Get all definitions (phrases that telling meaning of the word).
- Returns
list of definitions
- Return type
list[str]
- get_all_examples() → List[str][source]¶
Get all examples of word usage.
- Returns
list of examples
- Return type
list[str]
- get_all_parts_of_speech() → List[str][source]¶
Get all parts of speech.
- Returns
all parts of speech
- Return type
list[str]
- get_all_synonyms() → List[str][source]¶
Get all synonyms.
- Returns
list of synonyms
- Return type
list[str]
- get_all_transcriptions() → List[str][source]¶
Get all transcriptions that fetched in response.
- Returns
list of transcriptions
- Return type
list[str]
- get_link_on_audio_with_pronunciation() → str[source]¶
Get link on audio with pronunciation. If in response fetched few return first.
For more detailed (get few links) use
Word.phoneticsproperty - it`ll be more obvious way .- Returns
link on audio with pronunciation
- Return type
str
- get_transcription() → str[source]¶
Get transcription. If in response fetched few then return first.
- Returns
transcription
- Return type
str
- property meanings: List[freedictionaryapi.types.meaning.Meaning]¶
Meanings data. Shortcut for
Word.meanings.- Returns
meanings data
- Return type
list[Meaning]
- property phonetics: List[freedictionaryapi.types.phonetic.Phonetic]¶
Phonetics data. Shortcut for
Word.phonetics.- Returns
phonetics data
- Return type
list[Phonetic]
- property word: freedictionaryapi.types.word.Word¶
- Returns
word object
- Return type
Word