API Wrapper for the Merriam-Webster API.
Project description
mwdictionary
Small wrapper around the Merriam-Webster API. Has both a sync and async interface thanks to httpx.
Installation
pip install mwdictionary
Usage
Using mwdictionary's sync interface:
>>> from mwdictionary import MWClient
>>> client = MWClient(key="YOUR-KEY-HERE")
>>> client.get("python")
Word(word='python', wordtype='noun', shortdef='as in anaconda, boa', synonyms=['adder', 'anaconda', 'asp', 'black racer', 'blacksnake', 'blue racer', 'boa', 'bull snake', 'bushmaster', 'chicken snake', 'cobra', 'constrictor', 'copperhead', 'coral snake', 'cottonmouth moccasin', 'diamondback rattlesnake', 'fer-de-lance', 'garter snake', 'gopher snake', 'green snake', 'hognose snake', 'horned viper', 'indigo snake', 'king cobra', 'king snake', 'krait', 'mamba', 'milk snake', 'moccasin', 'pine snake', 'pit viper', 'puff adder', 'racer', 'rat snake', 'rattlesnake', 'sea serpent', 'sea snake', 'sidewinder', 'taipan', 'water moccasin', 'water snake', 'worm snake', 'serpent', 'snake', 'viper'], antonyms=[], stems='python')
Using the async interface:
>>> import asyncio
>>> asyncio.run(client.aget("python"))
Word(word='python', wordtype='noun', shortdef='as in anaconda, boa', synonyms=['adder', 'anaconda', 'asp', 'black racer', 'blacksnake', 'blue racer', 'boa', 'bull snake', 'bushmaster', 'chicken snake', 'cobra', 'constrictor', 'copperhead', 'coral snake', 'cottonmouth moccasin', 'diamondback rattlesnake', 'fer-de-lance', 'garter snake', 'gopher snake', 'green snake', 'hognose snake', 'horned viper', 'indigo snake', 'king cobra', 'king snake', 'krait', 'mamba', 'milk snake', 'moccasin', 'pine snake', 'pit viper', 'puff adder', 'racer', 'rat snake', 'rattlesnake', 'sea serpent', 'sea snake', 'sidewinder', 'taipan', 'water moccasin', 'water snake', 'worm snake', 'serpent', 'snake', 'viper'], antonyms=[], stems='python')
If you want the word as a dictionary, just pass the result to dataclasses.asdict()
:
>>> from dataclasses import asdict
>>> asdict(client.get("python"))
{'word': 'python', 'wordtype': 'noun', 'shortdef': 'as in anaconda, boa', 'synonyms': ['adder', 'anaconda', 'asp', 'black racer', 'blacksnake', 'blue racer', 'boa', 'bull snake', 'bushmaster', 'chicken snake', 'cobra', 'constrictor', 'copperhead', 'coral snake', 'cottonmouth moccasin', 'diamondback rattlesnake', 'fer-de-lance', 'garter snake', 'gopher snake', 'green snake', 'hognose snake', 'horned viper', 'indigo snake', 'king cobra', 'king snake', 'krait', 'mamba', 'milk snake', 'moccasin', 'pine snake', 'pit viper', 'puff adder', 'racer', 'rat snake', 'rattlesnake', 'sea serpent', 'sea snake', 'sidewinder', 'taipan', 'water moccasin', 'water snake', 'worm snake', 'serpent', 'snake', 'viper'], 'antonyms': [], 'stems': 'python'}
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
mwdictionary-0.1.2.tar.gz
(3.2 kB
view details)
Built Distribution
File details
Details for the file mwdictionary-0.1.2.tar.gz
.
File metadata
- Download URL: mwdictionary-0.1.2.tar.gz
- Upload date:
- Size: 3.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.0.0 CPython/3.7.0 Windows/10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9e324aadbe1111990d0d289024a7f9aa4eabe20c17467fdf887b6e3883f31f94 |
|
MD5 | d6bcaccdba2e84bb42ab5a858907cf0a |
|
BLAKE2b-256 | 564ff319e3a1f2063492875836c69547b136d4c5a2ea742fb573b0730d282266 |
File details
Details for the file mwdictionary-0.1.2-py3-none-any.whl
.
File metadata
- Download URL: mwdictionary-0.1.2-py3-none-any.whl
- Upload date:
- Size: 3.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.0.0 CPython/3.7.0 Windows/10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 381c48bd8aa15817b1199f1072207c40377875a92fa7c74a5a5eabdaf10aa303 |
|
MD5 | 83464745946767a9b760b423211ea147 |
|
BLAKE2b-256 | cfc99786ccf0fe3d7cbaac02ec25835a95069f2101bb3213204a5cc84080a5c5 |