As an example of self-improvement using the Raspberry Pi, we will implement an example that retrieves the word of the day using the Wordnik API (https://www.wordnik.com/).
We need to install the Wordnik Python client (distributed under the Apache License) available as a Python package:
sudo pip install wordnik
The next step is to obtain an API key to make use of the API. This can be obtained by registering for an account with Wordnik and requesting an API key (http://developer.wordnik.com/).
Once the installation is complete, it is time to review the example.
from wordnik import *
url='http://api.wordnik.com/v4' key='API Key' client=swagger.ApiClient(key,url)
words = WordsApi.WordsApi(client) example = words.getWordOfTheDay()
WordOfTheDay
object (https://github.com/wordnik/wordnik-python/blob/master/wordnik/models/WordOfTheDay.py). Let's print the word, definition, and the published date:string = 'The Word of the Day is ' + example.word +'.' print string string = 'Definition: '+example.definitions[0].text print string string = 'Date = '+example.publishDate.strftime("%D") print string
The Word of the Day is asportation. Definition: The felonious removal of goods from the place where they were deposited. Date = 01/19/15
52.15.181.87