Several dictionaries on the Web offer an API to interact with their website via scripts. This recipe demonstrates how to use a popular one.
Accessing word definitions via a web server
Getting ready
We are going to use curl, sed, and grep for this define utility. There are a lot of dictionary websites where you can register and use their APIs for personal use for free. In this example, we are using Merriam-Webster's dictionary API. Perform the following steps:
- Go to http://www.dictionaryapi.com/register/index.htm, and register an account for yourself. Select Collegiate Dictionary and Learner's Dictionary:
- Log in using the newly created account and go to My Keys to access the keys. Note the key for the learner's dictionary.