Database Reference
In-Depth Information
other tools, such as jq . For example, the API from http://randomuser.me returns data
in the following JSON structure:
$ curl -s http://api.randomuser.me | jq '.'
{
"results": [
{
"version": "0.3.2",
"seed": "1c5b868416387bf",
"user": {
"picture": "http://api.randomuser.me/0.3.2/portraits/women/2.jpg",
"SSN": "972-79-4140",
"cell": "(519)-135-8132",
"phone": "(842)-322-2703",
"dob": "64945368",
"registered": "1136430654",
"sha1": "a3fed7d4f481fbd6845c0c5a19e4f1113cc977ed",
"gender": "female",
"name": {
"last": "green",
"first": "scarlett",
"title": "miss"
},
"location": {
"zip": "43413",
"state": "nevada",
"city": "redding",
"street": "8608 crescent canyon st"
},
"email": "scarlett.green32@example.com",
"username": "reddog82",
"password": "ddddd",
"salt": "AEKvMi$+",
"md5": "f898fc73430cff8327b91ef6d538be5b"
}
}
]
}
The data is piped to the jq command-line tool in order to display it in a nice way. jq
has many more possibilities that we will explore in Chapter 5 .
Some web APIs return data in a streaming manner. This means that once you con‐
nect to it, the data will continue to pour in forever. A well-known example is the
Twitter firehose, which constantly streams all the tweets sent around the world. Luck‐
ily, most command-line tools that we use also operate in a streaming manner, so that
we may also use this kind of data.
Some APIs require you to log in using the OAuth protocol. There's a convenient
command-line tool called curlicue (Foster, 2014) that assists in performing the so-
called OAuth dance . Once this has been set up, curlicue will call curl with the
Search WWH ::




Custom Search