Esteban | ˈe-stə-vən - /collection/apis-ii/

Fun APIs I: Cats as a Service (Cataas)

Mar. 4, 2021

Read time: 1 minutes and 15 seconds.

tags:

Cats

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:

A photo from the Cataas API

A photo from the Cataas API

Requirements

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.

Basic cURL Commands

Random Cat

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 !

Random :tag Cat

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  

Cat says ‘shortcodes’

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 

blurry cat, blurry cat, what are they feeding you?

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

APIs are Fun

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.