Urban Dictionary API
Benefits of using an Urban Dictionary API!
There are numerous dictionary API services available on the web that enable users to look up word definitions. However, the Urban Dictionary API sets itself apart in two significant aspects. Support for slang words and colloquial phrases and a Community-driven user-contributed rating system. The community-driven approach of the Urban Dictionary influences both these aspects. Since the user community collectively contributes to the dictionary, more contemporary, slang, and colloquial phrases are continuously added to the dictionary database. Thus the dictionary is richer and more relevant to the current times. Moreover, the user-contributed rating system allows users to rate word definitions and usage examples using up-votes and down-votes. This further democratizes the relevance of word definitions. Thus an end-user is presented with a list of word definitions and their corresponding example usages in addition to their up-votes and down-votes. This empowers the end-user with a choice to select and use a particular word definition and example from the returned list of multiple definitions.
// package examples;
// import org.json.JSONArray;
// import urbanapi.Definition;
// import urbanapi.UDParser;
public class APITestDriver
{
public static void main (String[] args)
{
UDParser udparser = new UDParser("http://api.urbandictionary.com/v0/");
String JSONData = udparser.getJSONData("chris+hansen");
// String JSONData = udparser.getJSONData(6730949);
// System.out.println(JSONData);
Definition[] test = udparser.getDefinitionsWithJSONData(JSONData);
for(int i = 0; i < test.length; i++)
{
System.out.println("WORD");
System.out.println(test[i].getWordName());
System.out.println("DEFINITION");
System.out.println(test[i].getDefinition());
System.out.println("AUTHOR");
System.out.println(test[i].getAuthor());
System.out.println("WRITTEN DATE");
System.out.println(test[i].getWrittenDate());
System.out.println("REFERENCE ID");
System.out.println(test[i].getRefID());
System.out.println("PERMALINK");
System.out.println(test[i].getPermalink());
}
JSONArray keywordTags = udparser.getTagsWithJSONData(JSONData);
System.out.println("TAGS");
for(int i = 0; i < keywordTags.length(); i++)
{
System.out.println(keywordTags.get(i));
}
}
}
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://mashape-community-urban-dictionary.p.rapidapi.com/define?term=wat"))
.header("X-RapidAPI-Key", "b256ce775fmsh9e5a7319b6e6e38p1d5c1fjsnae19e21ba599")
.header("X-RapidAPI-Host", "mashape-community-urban-dictionary.p.rapidapi.com")
.method("GET", HttpRequest.BodyPublishers.noBody())
.build();
HttpResponse<String> response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://nfl-schedule.p.rapidapi.com/v1/schedules"))
.header("X-RapidAPI-Key", "9fb1283360mshedc514375b603d6p156a26jsna7cd4ca5744a")
.header("X-RapidAPI-Host", "nfl-schedule.p.rapidapi.com")
.method("GET", HttpRequest.BodyPublishers.noBody())
.build();
HttpResponse<String> response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());