Mar. 4, 2021
Read time: 1 minutes and 15 seconds.
tags:Whether you like it or are allergic, cats have found residency on the internet as the cutest pets on the planet for some. They purrr, play, and plan like few other animals and happen to look great in photos:
If you haven’t already, checkout my post about getting Started with APIs that will share with you useful resources such as the curlconverter.com which lets you use your code of choice you use an API service by way of Python, R, Java, etc.
Here’s a random cat
curl -i -H "Accept: application/json" -H "Content-Type: application/json" -X GET https://cataas.com/cat
see photo above !
Here you can set a tag to specify the type of cat you’re looking for. A ‘cute’ cat
curl -i -H "Accept: application/json" -H "Content-Type: application/json" -X GET https://cataas.com/cat/cute
or a fat cat
curl -i -H "Accept: application/json" -H "Content-Type: application/json" -X GET https://cataas.com/cat/fat
You can also leverage shortcodes within the API to do the same actions with fewer characters in the command like this:
curl -i -H "Accept: application/json" -H "Content-Type: application/json" -X GET https://cataas.com/c/s/shortcode
APIs can also have filtering and other mutations to the requested output such as an image blur for a random cat:
curl -i -H "Accept: application/json" -H "Content-Type: application/json" -X GET https://cataas.com/c?fi=blur
Now you can see just how to automate the process of using these incredibly useful random cat commands when necessary by creating cron jobs or event listeners that automatically activate the most appropriate API command.