Get "PHP 8 in a Nuthshell" (Now comes with PHP 8.3)
Amit Merchant

Amit Merchant

A blog on PHP, JavaScript, and more

Interesting Public APIs to Play Around With

Any modern application (mobile or web) consists of two main parts: the frontend and the backend. Most of the time, the backend is a REST API that the frontend consumes.

If you’re a fronend developer, it would be rather difficult for you to build a backend if you just want to test the prototype of your frontend. The same goes for a mobile app developer.

And that’s where public APIs come to the rescue. In this article, I’m listing out some of the most interesting APIs that you can consume from your frontend while still having fun.

Star Wars API

If you’re a Star Wars fan, you probably know that the Star Wars API is a great resource to get information about the Star Wars universe.

There are endpoints to get information about the characters, planets, films, spaceships, vehicles, etc.

For instance, you can use the following endpoint to get the information about the Luke Skywalker character.

curl "https://swapi.dev/api/people/1"

Since this is a public API, there’s a rate limit of 10,000 API requests daily. So, use the API responsibly.

→ Learn more: Star Wars API

The Rick and Morty API

Talking about fictional characters and worlds, the The Rick and Morty API is a great resource to get information about the Rick and Morty universe.

You can get the list of all the characters, the list of all the episodes, the list of all the locations, and more.

For instance, you can get the list of all the characters using the following endpoint.

curl "https://rickandmortyapi.com/api/character"

The API would return a JSON object with the list of all the characters and their details like name, status, species, gender, origin, location, image, and more.

→ Learn more: The Rick and Morty API

PokéAPI

PokéAPI is a public API that provides information about Pokémon. It’s a great resource for Pokémon enthusiasts and gamers.

The API has endpoints to get information about Pokémon, their evolutions, their moves, their types, and more.

For instance, you can get the list of all the Pokémon in the Kanto region using the following endpoint.

curl "https://pokeapi.co/api/v2/pokemon?region=kanto"

→ Learn more: PokéAPI

IGDB API

IGDB API is a public API that provides information about games, including their titles, genres, game engine, company, release dates, and more.

To use this API, you need to have a Twitch account with a Client ID and Client Secret. You can get them from the Twitch Developer Portal.

A typical request to fetch video games looks like this.

curl 'https://api.igdb.com/v4/external_games' \
-d 'fields category,checksum,countries,created_at,game,media,name,platform,uid,updated_at,url,year;' \
-H 'Client-ID: Client ID' \
-H 'Authorization: Bearer access_token' \
-H 'Accept: application/json'

→ Learn more: IGDB API

Dictionary API

Dictionary API is a public API that provides definitions for words, phrases, and sentences.

The API is pretty simple. There’s only one endpoint that can be used to get the definition of a word.

curl "https://api.dictionaryapi.dev/api/v2/entries/en/<word>"

Replace <word> with the word you want to get the definition for. The API returns a JSON object with the definition, phonetics, origin, examples, and other details about the word.

→ Learn more: Dictionary API

DummyJSON API

When you just want a JSON response with a list of random data, you can use the DummyJSON API.

For instance, if you need a list of 10 users, you can use the following endpoint.

curl "https://dummyjson.com/users?limit=10"

The API also has endpoints to get the list of products, recipes, posts, quotes, etc.

I think this is a perfect API if you want to build a full-fledged application with related data.

→ Learn more: DummyJSON API

SpaceTraders API

With the SpaceTraders API, you can build an entire game all based on API calls. The API has endpoints using which you can acquire and manage a fleet of ships to explore, trade, and fight your way across the galaxy.

Every action you can take in the game is an HTTP endpoint you can hit with code. For instance, you can initiate a game using an endpoint to buy and sell ships. Everything is an endpoint, so you can build a game all based on API calls.

→ Learn more: SpaceTraders API

Like this article? Consider leaving a

Tip

👋 Hi there! I'm Amit. I write articles about all things web development. You can become a sponsor on my blog to help me continue my writing journey and get your brand in front of thousands of eyes.

Comments?