Skip to main content

mwthesaurus

Small wrapper around the Merriam-Webster API. Has both a sync and async interface thanks to httpx.

Installation

pip install mwthesaurus

Usage

Basic usage:

>>> from mwthesaurus 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'])]
...
>>> 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'])]

MWClient.get() returns a list of definitions for a given word.

If you want the definitions as dictionaries, just pass the results to dataclasses.asdict():

>>> from dataclasses import asdict
>>> [asdict(w) for w in 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']}]

Release files for mwthesaurus 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mwthesaurus 0.1.2
File Size Uploaded
mwthesaurus-0.1.2.tar.gz 3.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for mwthesaurus 0.1.2
File Interpreter ABI Platform
mwthesaurus-0.1.2-py3-none-any.whl Python 3 none any Details

Total release size:7.8 kB

Release files / mwthesaurus-0.1.2.tar.gz

Download URL mwthesaurus-0.1.2.tar.gz
Size 3.8 kB
Tags Source
SHA-256 checksum
How to use checksums
8f2d8caf6cdacca0e02fc2e1624809a7efcd59ad7d26cfc1d83af3ee2f4c74fb
BLAKE2b-256 checksum
How to use checksums
e6cb2cee31964c761d357d8cb64d0e382a3c570cde6d9bd116a6bd1e9e95d86f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.0.5 CPython/3.8.3 Windows/10

Release files / mwthesaurus-0.1.2-py3-none-any.whl

Download URL mwthesaurus-0.1.2-py3-none-any.whl
Size 4.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
afeef3db37307e9cad160f219f3bb2275944aee278f86d95b15029cb851804bb
BLAKE2b-256 checksum
How to use checksums
598ad8931ba3140e2b0aaddc7cb1e0b8979348b3f0352481c00a4f8c741a1ba2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.0.5 CPython/3.8.3 Windows/10

Release history Release notifications | RSS feed

This release

0.1.2 This release

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page