Bash script for fetching a list of image urls from unsplash.com
#!/usr/bin/env bash
# after register app on unsplash.com
# we get an access key for calling the apis
result="output.json"
accessKey="0370897a07d67db513b29e1dd4823ef70b17a161dca323b1e3952b8bcaef352c"
counter=1
iterations=50
while [ ${counter} -le ${iterations} ]
do
# make api request to get a list of photos
# and save the response to a file
curl --request GET --url "https://api.unsplash.com/photos/?page=${counter}&client_id=${accessKey}" >> ${result}
((counter++))
done
# replace ][ occurrences with ,\n to make appropriate JSON
sed -i '' 's|\]\[|,\
|g' ${result}
# parse the specific response using http://jsonpath.com/ to retrive specific fields
# for example: to retrieve urls.full from each array, we use following in JSONPath Syntax:
# $.[:].urls.full