Usage examples
Bash (curl)
$ curl -f -s
Bash (wget)
$ wget -qO-
Python 3
import urllib.request
word_generator_api_url = ""
new_word = urllib.request.urlopen(word_generator_api_url).read().decode("utf-8")
print(new_word) #
Python 2
import urllib2
word_generator_api_url = ""
new_word = urllib2.urlopen(word_generator_api_url).read()
print new_word #
JavaScript
var apiEndpointUrl = "";
var httpGetAsync = function(requestUrl, successCallback, errorCallback)
{
var xmlHttp = new XMLHttpRequest();
xmlHttp.onreadystatechange = function() {
if (xmlHttp.readyState == 4) {
if (xmlHttp.status == 200) {
successCallback(xmlHttp.responseText);
}
else {
errorCallback(xmlHttp);
}
}
}
xmlHttp.open("GET", requestUrl, true);
xmlHttp.send(null);
}
httpGetAsync(
apiEndpointUrl,
function(newWord) {
alert("New word: " + newWord); //
},
function() {
alert("An error occurred in generating the new word.");
}
);