Hearthstone is a digital collectible game based on cards. The typical gameplay revolves around turn-based card show, but with a difference. Players can choose from multiple card decks each associated with a hero with a unique power and they can attack the opponent’s heroes by summoning minions and other means.
In this article, we will learn how to consume the Hearthstone API with Rakuten Rapid API. By leveraging the Hearthstone API, you can get all the information about the card data available under Hearthstone.
Setting up Hearthstone API
To get started you must have a Rakuten Rapid API account and get hold of the API keys you get with it. Once done, head over to the Hearthstone API page and you can see the options available for the API.
Rakuten Rapid API provides a test console to test the API. You can make use of the options provided in the console the test the API and it will directly pull the data from the game.
Let’s look at some of the important data about the Hearthstone game that you can get from this API.
API for Hearthstone Game Info
The Info API endpoint provides all the information about Hearthstone, including the card sets, game modes, game characters and more.
You can call the API by clicking on the “Test Endpoint” button. Alternatively, you can also use the unirest package to test the API.
Here is the part of API response which shows the card sets available in the game.
You can scroll up and down the results section to see other data apart from the card sets.
If you are looking for specific information on cards then the Hearthstone API also provides more granular API endpoints.
Getting Card Info
If you want to get all the cards then you can call the ‘cards’ API endpoint
Similarly, for getting the information on a single card, you can call the same endpoint with the card name. Here is an example of using the API with a card named “AFK”
You can also fetch information about a card set by extending the same API endpoint as follows
This is the API endpoint for the card set named “Basic”.
And the output contains a paginated response with an array of 100 cards, each containing a card detail.
You can also filter the cards based on cost, attack, durability, and health. All these are optional parameters to the API.
The Hearthstone API also gives you options to categorize cards based on several gameplay options. These include class, race, factions and more. All these APIs returns the cards in a paginated array format.
Here is the API endpoint of fetching the cards based on the class warriors
Like all digital games, Hearthstone also has its own signature graphics embedded in the cards. You can get the cards images by looking for the keys “img” or “imgGold” in the JSON response.
Here is the image retrieved from the “img” key in the JSON response of card “AFK”.
For some cards, the API also returns the animated GIFs of the card backs, by using the cardbacks API.
This API also returns a paginated list of card back info. The URL to the animated GIF is contained in the “imgAnimated” key of JSON response for each card. Here is a GIF for one fo the card backs randomly picked from the API response.
Take Charge of the HearthStone Cards
You are now ready to go. Get your API key now, subscribe to the Hearthstone API and start exploring all the cards and their stats.
You can also check out the other Gaming APIs offered by Rakuten Rapid API.
About Rakuten RapidAPI
Rakuten RapidAPI is the world’s largest API marketplace with 8,000+ third-party APIs and used by over 500,000 active developers. We enable developers to build transformative apps through the power of APIs. Find, test and connect to all the APIs you need in one place!