Skip to main content

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

Project description

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.

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

wordsapy-1.1.1.tar.gz (7.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

wordsapy-1.1.1-py3-none-any.whl (7.3 kB view details)

Uploaded Python 3

File details

Details for the file wordsapy-1.1.1.tar.gz.

File metadata

  • Download URL: wordsapy-1.1.1.tar.gz
  • Upload date:
  • Size: 7.4 kB
  • Tags: Source
  • Uploaded using 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

File hashes

Hashes for wordsapy-1.1.1.tar.gz
Algorithm Hash digest
SHA256 41a79a37591abffaf6790e4353eadce9f9bcc7597433c5ed4a504c2ce73a9d18
MD5 98cc7dc289ad718acbf176c16160f4ac
BLAKE2b-256 de93b7fcb26f3afb68fc7027da59c06c57a184101c48bd9e52bd9df52f46876b

See more details on using hashes here.

File details

Details for the file wordsapy-1.1.1-py3-none-any.whl.

File metadata

  • Download URL: wordsapy-1.1.1-py3-none-any.whl
  • Upload date:
  • Size: 7.3 kB
  • Tags: Python 3
  • Uploaded using 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

File hashes

Hashes for wordsapy-1.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 f9e5b28e6676b43c0b7795284bab5f42633277d0e1ea220514cb740c740f6e85
MD5 2fc89e8886a36d79b4d3bed4fa935deb
BLAKE2b-256 7166f7ff06e788452d783543edf79ff0fb0091399fa8c3278caad32749e0bcb5

See more details on using hashes here.

Supported by

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