KNOWN ISSUES:
You can use Knicker to add dictionary lookup capabilities to your own Java programs. Knicker has been designed to be simple and straightforward to use. It does not require any third party libraries, just Java 1.6 or higher.
Version 2.x of Knicker supports version 4 of the Wordnik API.
Version 1.x of Knicker supports version 3 of the Wordnik API.
To use Knicker, you will need to obtain a Wordnik API key. More information about the Wordnik API can be found on their developer site at http://developer.wordnik.com.
Knicker looks for the system property WORDNIK_API_KEY, so you need to set it before you try to use Knicker:
Then just call the API methods using the Knicker class:
The Wordnik API is divided into different sections based on the API endpoint. Knicker, for the most part, follows this logical arrangement. If you want to call methods on the account endpoint, use the AccountApi class, for methods on the word endpoint, use the WordApi class, and so on.
Here's a quick sample showing how to check the API key status and look up the definition of a word:
import java.util.List;
import net.jeremybrooks.knicker.AccountApi;
import net.jeremybrooks.knicker.WordApi;
import net.jeremybrooks.knicker.dto.Definition;
import net.jeremybrooks.knicker.dto.TokenStatus;
public class TestKnicker {
public static void main(String[] args) throws Exception {
// use your API key here
System.setProperty("WORDNIK_API_KEY", "your api key");
// check the status of the API key
TokenStatus status = AccountApi.apiTokenStatus();
if (status.isValid()) {
System.out.println("API key is valid.");
} else {
System.out.println("API key is invalid!");
System.exit(1);
}
// get a list of definitions for a word
List def = WordApi.definitions("siren");
System.out.println("Found " + def.size() + " definitions.");
int i = 1;
for (Definition d : def) {
System.out.println((i++) + ") " + d.getPartOfSpeech() + ": " + d.getText());
}
}
}