7 cool APIs you didn't know you needed

March 24, 2020
Written by

7 cool APIs you didn't know you needed

Human beings learn better through play.

No matter what your experience level, this post will show you 7 fun and silly APIs you can play with and build on top of.

If you’ve never written a line of code, don’t fret -- we’ll show you how to get started. Experienced programmers, feel free to skip down to the 7 APIs section.

What is an API?

An API stands for Application Programming Interface, which is a way for a program to communicate with another program. These programs can be running on the same computer, or not -- it really doesn’t matter. There are different types of APIs -- it’s a really broad term. Today we’ll focus on REST APIs.

REST APIs follow a pattern that specifies how the information will be transmitted from one computer to another. The computer asking for the data is called the client, and the computer sending the data back is known as a server. This dance is called the request-response cycle.

Illustrated diagram of the request-response cycle. A purple computer with heart shaped eyes and feet, labeled "client" has an arrow with the words "request" pointing towards the other computer, which is pink and labeled "server." The server has an arrow pointing back towards the client, with the text "response."

If you want a more in-depth definition of "API" before trying them out, peep our docs for an in-depth explanation of REST APIs.

Tools you’ll need to get started

There are a few different ways you can set things up:

7 APIs that are better than sliced bread

The Dog API

What can we say -- they’re good APIs, Brent. The Dog API allows you to search for dog photos, find information about different dog breeds, and more.

To try it out, navigate to https://api.thedogapi.com/v1/images/search in your browser. Congratulations, you just made an API call! 🎉 🐶

You should see some code in the browser that looks like this:

{"breeds":[]

But what does it mean? Many REST APIs give you a response that’s formatted as JSON (JavaScript Object Notation.) The data comes in pairs of keys and values that are colon-separated.

diagram of key-value pairs in some example JSON. The text reads {"name": "Lizzo", "feelin": "good as hell"}

Going back to the example API response above, for the key width, the value would be 560.

If you copy the url value out of that code and load it in your browser, you should see a super adorbs gif or image.

gif of a dalmation spooning a human and patting his head with a paw.

Check out the Dog API documentation (dogumentation?) to learn what else you can do.

Pokemon API

Supposedly, PokeApi handles 17 million requests per month. Gotta serve ‘em all, I guess!

This API only returns data about the Pokemon video game franchise. Since Pokemon has movies, TV shows, and comics it would be overwhelming for one API to cover everything. Even scoped just to the games, PokeApi has over 9,000 different kinds of data in their database.

Let’s try exploring the Pokemon species endpoint. To get a list of all the genderless Pokemon species, you’d call https://pokeapi.co/api/v2/gender/3/.

It returns a long list. TIL, there are currently 104 genderless Pokemon species. 😲 Also, Poke-gender is very complicated and backwards-incompatible between different versions of the game.

Gif of a Squirtle pokemon wearing flowers on its head, neck, and wrist winking at you with its wrist behind its head.

PokeApi is open source. You can browse the code or contribute on GitHub.

Fun Translations

How many flavors of geekery can be crammed into one API? Quite a few, as it turns out. Fun translations allows you to translate between English and many other quirky or nerdy languages such as:

  • Klingon
  • Yoda-speak
  • Pig Latin
  • Cockney
  • Ermahgerd

To try out the translations API in the browser you need to url-encode the text so that any special characters can be universally understood by any server. Good news -- the browser handles this for you.

If you paste “https://api.funtranslations.com/translate/doge.json?text=Good morning” into a browser URL bar, it will turn into “https://api.funtranslations.com/translate/doge.json?text=Good%20morning” when you load the page.

You’ll also see a response that looks like this:

{
    "success": {
        "total": 1
    },
    "contents": {
        "translated": "Grrr shiba shiba woof woof ... pant! shiba barkbarkbark doge lick doge grrr ",
        "text": "Good morning",
        "translation": "doge"
    }
}

affirmations.dev

When my therapist first suggested I try affirmations, I couldn’t roll my eyes hard enough. But I gave them a shot anyway, and they were actually helpful combating impostor syndrome. So I created a tiny API to supply affirmations on demand, and even built my first hardware project on top of it.

To get an affirmation, head on over to https://www.affirmations.dev/ in your browser and receive a heartwarming response such as:

{"affirmation":"Sucking at something is the first step towards being good at something"}

Affirmations.dev is open source. If you’re shy about contributing code, contributions of new affirmations are also welcome. 💖

HTTP Status Cats

Since we included a doggo API, it seems only fair to include cat lovers too. 😻 When you call any REST API, the API returns a status code to indicate whether or not the call was successful and why.

Http.cat returns a photo of a cat to illustrate each http status code. To see the photo for the most objectively hilarious one, hop on over to http.cat/418.

I can haz dad joke

No lie: dad jokes got me this job at Twilio. I wrote an editor extension that uses the Dad Jokes API, gave a talk about it, and the rest was history.

Alas, there’s no easy way to try this API in a browser. If you go to the API URL, it loads an entire web page rather than returning a code response with just the joke. If you have access to a terminal, you can try running this code from the command line to fetch a joke instead:

curl -H "Accept: text/plain" https://icanhazdadjoke.com/
What kind of music do planets listen to? Nep-tunes.

For more experienced folks, the Dad Jokes API has an endpoint that provides Slack-formatted responses. If you’ve been itching to make your first Slack app, what better time than now? This API even speaks GraphQL if you’ve been looking for an excuse to dive into that.

NASA's Big Collection of Sciency APIs

There’s a whole smorgasbord of sciencey APIs at api.nasa.gov.

Some of the most popular NASA APIs are photo-related:

There are more APIs than just photo fetching, though.

  • Search for the asteroids based on which are nearest to Earth
  • Query the database of exoplanets

To try the astronomy photo of the day API, go to https://api.nasa.gov/planetary/apod?api_key=DEMO_KEY in your browser and copy the url value out of the response.

Photo of a galaxy from NASA's photo of the day API.

Wrapping it up

Massive thanks to the creators and maintainers of these delightful projects! 💜

My hope is that learning about these rad APIs has gotten you jazzed up to build something. Or at least brought a smile to your face.

Have you come across other APIs that spark joy? Or have you built something interesting with an API? Let me know in the comments, or find me on Twitter at @annthurium.