7 cool APIs you didn't know you needed
Time to read: 5 minutes
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.
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:
- The easiest way to call an API is to use your web browser
- You can also use a tool called Postman
- Or you can write a little code. My personal favorite programming language, JavaScript, just so happens to be the world’s most popular programming language. If you want to learn about how to call APIs from your JavaScript code, check out this blog post on making HTTP requests in Node.js.
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:
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.
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.
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.
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:
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:
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:
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:
- You can get photos from the Mars Rover. Sam Agnew built a Twilio app that sends you a Mars Rover photo of the day.
- April Speight wrote a post using the astronomy photo of the day API to send yourself the photo of the day using Azure Functions and Twilio.
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.
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.
Related Posts
Related Resources
Twilio Docs
From APIs to SDKs to sample apps
API reference documentation, SDKs, helper libraries, quickstarts, and tutorials for your language and platform.
Resource Center
The latest ebooks, industry reports, and webinars
Learn from customer engagement experts to improve your own communication.
Ahoy
Twilio's developer community hub
Best practices, code samples, and inspiration to build communications and digital engagement experiences.