If you are using an
Ad Blocking Browser Extension
please consider deactivating
it for this website.
Also see our Ads Policy.
In today’s world where language is somewhat neglected modern ‘word-related’ services are a welcome edition to the struggle against illiteracy. One such service provider, Wordnik, offers unique word and other English language related services.
Wordnik bills itself as “a place for all the words, and everything known about them.” They allow users to look up definitions, add new words to their online database and provide example sentences pulled from the internet. Unlike many online dictionaries, Wordnik’s content can be accessed through their API.
From their website:
“Wordnik has amassed an incredible amount of data… one of our core principles is that you shouldn’t have to come to any particular web site to learn about words: the word data should come to you wherever you are.”
Wordnik’s RESTful API allows developers to look up definitions, display the use of words in example sentences and return data about how frequently the word appears in Wordnik’s corpus. The Wordnik API also gives developers access to an auto complete function, and both a ‘random word’ and a ‘word of the day’ listing. Data for each function is accessed by GET request, and data can be returned in either XML or JSON format.
For the official Python library see Github and follow the instructions there. Other code libraries can be obtained here.
Pip needs to be installed:
sudo apt-get install python-pip
sudo pip install --upgrade pip --index-url=https://pypi.python.org/simple/
After installation, sign up for a Wordnik account and and get an API key.
Wordnik API Python sample script
Create a new Python script in a desired location. For the Word Of The Day script I will use
/home/pi/wotd/wotd.py for explanation purposes. In a freshly booted Raspberry Pi terminal use:
and copy the following code into it:
# -*- coding: utf-8 -*-
from wordnik import *
apiUrl = 'http://api.wordnik.com/v4'
apiKey = 'your-api-key-here'
client = swagger.ApiClient(apiKey, apiUrl)
wordsApi = WordsApi.WordsApi(client)
wotd = wordsApi.getWordOfTheDay()
Change the API details to the one from your own account, exit and save (Ctrl + X & Y).
To run the script use:
You can see more Words functions on the official Python development page (https://github.com/wordnik/wordnik-python).
Behind the Scenes is a free, informative website. If you find value in any of our content, please consider making a donation to our cause.
About the author
Renier busies himself with improving his English writing, creative web design and his websites, photoshopping, micro-electronics, multiple genres of music, superhero movies and badass series.
Save, share & Disqus
Use the buttons below, on the left or the bottom of this page to share this post. Your comment is important, but don't be a knob. Keep it constructive and polite.
Comment via Disqus
Disqus is a worldwide comment hosting service for web sites and online communities. This secure platform ensures a pleasant commenting environment which is manageable from one account. Use the Login button to sign up.
More website development related posts
What beginners should know about JSON
1 January 2018
Using Cron for scheduling tasks
30 June 2017 | Updated 11 July 2017
Cron is an Unix-like operating system software utility used to schedule automatic time-based commands. Entered commands can be in the form of Bash or Bash scripts that are meant to be automatically executed periodically at fixed times, dates or intervals.
App settings to access the Facebook Graph API
17 March 2017 | Updated 6 February 2019
The Facebook Graph API is a platform that allows data into and out of the Facebook platform. “It’s a low-level HTTP-based API that Apps can use to programmatically query data, post new stories, manage ads, upload photos, and perform a wide variety of other tasks.”
Eclipse IDE for Python developers
7 December 2016
Eclipse IDE is a wonderful piece of free IDE software and Python is the language that makes many programmers very “excited” – so why not bring them together? Eclipse IDE added full functionality for Python developers through PyDev.