Skip to main content

API Wrapper for the Merriam-Webster Collegiate Thesaurus API.

Project description

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']}]

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mwthesaurus-0.1.2.tar.gz (3.8 kB view details)

Uploaded Source

Built Distribution

mwthesaurus-0.1.2-py3-none-any.whl (4.0 kB view details)

Uploaded Python 3

File details

Details for the file mwthesaurus-0.1.2.tar.gz.

File metadata

  • Download URL: mwthesaurus-0.1.2.tar.gz
  • Upload date:
  • Size: 3.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.0.5 CPython/3.8.3 Windows/10

File hashes

Hashes for mwthesaurus-0.1.2.tar.gz
Algorithm Hash digest
SHA256 8f2d8caf6cdacca0e02fc2e1624809a7efcd59ad7d26cfc1d83af3ee2f4c74fb
MD5 51f7e76d1fd7173c981fb6c6537750f1
BLAKE2b-256 e6cb2cee31964c761d357d8cb64d0e382a3c570cde6d9bd116a6bd1e9e95d86f

See more details on using hashes here.

File details

Details for the file mwthesaurus-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: mwthesaurus-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 4.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.0.5 CPython/3.8.3 Windows/10

File hashes

Hashes for mwthesaurus-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 afeef3db37307e9cad160f219f3bb2275944aee278f86d95b15029cb851804bb
MD5 69e01d8de2576d2835c8cc9d4e70a11f
BLAKE2b-256 598ad8931ba3140e2b0aaddc7cb1e0b8979348b3f0352481c00a4f8c741a1ba2

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page