Skip to main content

Wordsapy

Build Status

Wordsapy is a python integration for the WordsAPI, that allows developers to retrieve information about English words like a dictionary.

Install

Wordsapy is available on the Python Package Index (PyPI): https://pypi.python.org/pypi/wordsapy

You can install wordsapy using pip.

$ pip install wordsapy

Usages

In order to use WordsAPI you need an API Key.

Get you Free API Key: https://rapidapi.com/dpventures/api/wordsapi/pricing

Setting your API Key

Initialize a Dictionary object and set your API Key.

from wordsapy import Dictionary


dictionary = Dictionary(api_key='your_api_key')

In this way the API Key will be defined as an environment variable, so with doing it only once is more than enough. Alternatively, you can export your API key as an environment variable.

$ export WORDS_API_KEY='your_api_key'

See examples/api_key.py for other examples.

Making queries

Once done, you can use the Dictionary object instance to perform queries.

Most methods of the Dictionary class have the same name as WordsAPI endpoints.

Check out the API Documentation: https://www.wordsapi.com/docs/

Assuming that the API Key is already defined as an environment variable, we retrieve the definitions of the word: example.

from wordsapy import Dictionary


dictionary = Dictionary()
results = dictionary.definitions('example')
for result in results:
    print('Definition: ' + result.definition)
    print('Part of speech: ' + result.partOfSpeech)

All responses will return a DictObj object or a list object. All dict objects in the response will be transformed into DictObj. You can access to the data of a DictObj object as you would with a dict object, or do it through the attributes. An example to illustrate this:

dictionary = Dictionary()
word = dictionary.word('example')

# It is the same::
for word['results'][0]['definition']
for word.results[0]['definition']
for word['results'][0].definition
for word.results.[0].definition # I love this one

# DictObj is iterable:
for key, value in word.items():
    print(key)
    print(value)

Examples

All usage examples can be found in the /examples folder of the project

Tests

You can run the tests via the command line. Your API Key must have been exported as an environment variable.

Place your terminal at the root of the project and run the following command.

$ python -m unittest discover tests "*_test.py"

Greetings

@AnthonyBloomer by tmdbv3api, with which I learned how to create a python interface for an API. The wordsapy structure is based on his library.

Metadata

Release files for wordsapy 1.1.1

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

Source distribution (sdist)

Source distribution for wordsapy 1.1.1
File Size Uploaded Provenance
wordsapy-1.1.1.tar.gz 7.4 kB Without provenance Details

Built distribution (wheel)

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

Total release size: 14.7 kB

Release files / wordsapy-1.1.1.tar.gz

Download URL wordsapy-1.1.1.tar.gz
Size 7.4 kB
Tags Source
SHA-256 checksum
How to use checksums
41a79a37591abffaf6790e4353eadce9f9bcc7597433c5ed4a504c2ce73a9d18
BLAKE2b-256 checksum
How to use checksums
de93b7fcb26f3afb68fc7027da59c06c57a184101c48bd9e52bd9df52f46876b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/51.1.1 requests-toolbelt/0.9.1 tqdm/4.55.0 CPython/3.9.0

Release files / wordsapy-1.1.1-py3-none-any.whl

Download URL wordsapy-1.1.1-py3-none-any.whl
Size 7.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f9e5b28e6676b43c0b7795284bab5f42633277d0e1ea220514cb740c740f6e85
BLAKE2b-256 checksum
How to use checksums
7166f7ff06e788452d783543edf79ff0fb0091399fa8c3278caad32749e0bcb5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/51.1.1 requests-toolbelt/0.9.1 tqdm/4.55.0 CPython/3.9.0

Security for wordsapy 1.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

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