Clash Royale is a freemium strategy game by Supercell. In this tutorial, I’ll show you how to get a Clash Royale API token and how to make requests to the Clash Royale API in Google Sheets:

  1. Install the Apipheny Google Sheets add-on
  2. Get a Clash Royale API Key & Token
  3. Choose a Clash Royale API endpoint
  4. Enter your Clash Royale API request into the Apipheny add-on
  5. Run the Clash Royale API request in your Google Sheets

Step 1.) Install and open the Apipheny add-on for Google Sheets

Apipheny is an API connector for Google Sheets. You can use Apipheny to connect your Google Sheets to unlimited API data sources, make unlimited API requests, and more. There is a 30 day free trial included.

1.) Install Apipheny by opening the following link on desktop and then clicking the Install button in the Google Marketplace: https://apipheny.io/install

2.) After you’ve installed Apipheny, open a Google Sheet and then click on the Extensions dropdown in the menu at the top.

In the dropdown list you should see Apipheny. Click Apipheny then click Import API to open the Apipheny sidebar in your Google Sheet.

open apipheny

Tip: you can open a new Google Sheet by entering this URL in your browser: sheet.new

Step 2.) Get your Clash Royale API Key & Token

To get your Key and Token, first log in to your Clash Royale developer account, or sign up for one if you haven’t already.

After logging in to your developer account, click on your username and then click My Account:

Go to your Clash Royale developer account
Go to your Clash Royale developer account

The My Keys section will then be displayed.

Click the Create New Key button:

Click the "Create New Key" button in your dev account
Click the “Create New Key” button in your dev account

Next, complete the key name and description.

Add an allowed IP address by completing the corresponding field and clicking the +Add IP Address button.

Finally, click the Create Key button:

Fill in the key name, description, add an IP address, and click "Create Key"
Fill in the key name, description, add an IP address, and click “Create Key”

Your Clash Royale API key will then be created.

Then, click the arrow next to your key to display your token:

Click the little arrow next to your Key to see your Token
Click the little arrow next to your Key to see your Token

Your Clash Royal API token will then be displayed.

Copy and paste your token to a safe location, because you’ll need it in the next steps:

Clash Royale API Token
Clash Royale API Token

Step 3.) Choose a Clash Royale API endpoint

In this section, I’ll show you how to browse the Clash Royale API documentation to find an API endpoint that retrieves the specific information you need from your Clash Royale account.

If you already know your API URL endpoint, or you want to use the same example URL as us, just skip to Step 4.

First, open the Clash RoyaleAPI documentation page: https://developer.clashroyale.com/#/documentation

The main page contains a list of endpoint’s categories: clans, players, cards, tournaments, locations and global tournaments:

https://developer.clashroyale.com/#/documentation
Clash Royale API documentation

Clicking on the corresponding Show/Hide link for a category will expand a list of specific endpoints.

Clash Royale API endpoints
Clash Royale API endpoints

 Clicking one of the available Clah Royale API’s endpoints will open its documentation page, containing the endpoint’s HTTP method and URL, a short description of its purpose, a list of the accepted parameters and response messages, as well as a sample request and its associated sample response.

The example endpoint we’ll take a look at is /players/{playerTag}/battlelog from the Players category. The corresponding URL for this endpoint is:

https://api.clashroyale.com/v1/players/playerTag/battlelog
Example Clash Royale API endpoint documentation
Example Clash Royale API endpoint documentation

All API calls to Clash Royale should be made with this base URL:

https://api.clashroyale.com/v1/

More Clash Royale API endpoint examples

The Cards endpoint, which gets list of available cards.

Method: GET
API URL Path: https://api.clashroyale.com/v1/cards
Headers:
    Header 1 Key:
       Accept
    Header 1 Value:
       application/json

    Header 2 Key:
       Authorization
    Header 2 Value:
       Bearer your_token

your_token is the value of the token you obtained previously, in Step 2. There should be a literal space between Bearer and your_token.


The GET /locations/global/seasons endpoint, which lists top player league seasons.

Method: GET
API URL Path: https://api.clashroyale.com/v1/locations/global/seasons
Headers:
    Header 1 Key:
       Accept
    Header 1 Value:
       application/json

    Header 2 Key:
       Authorization
    Header 2 Value:
       Bearer your_token

your_token is the value of the token you obtained previously, in Step 2. There should be a literal space between Bearer and your_token.


The GET /challenges endpoint, which gets current and upcoming challenges. Challenges are returned as chains.

Method: GET
API URL Path: https://api.clashroyale.com/v1/challenges
Headers:
    Header 1 Key:
       Accept
    Header 1 Value:
       application/json

    Header 2 Key:
       Authorization
    Header 2 Value:
       Bearer your_token

your_token is the value of the token you obtained previously, in Step 2. There should be a literal space between Bearer and your_token.


The GET /locations endpoint, which lists locations.

Method: GET
API URL Path: https://api.clashroyale.com/v1/locations
Headers:
    Header 1 Key:
       Accept
    Header 1 Value:
       application/json

    Header 2 Key:
       Authorization
    Header 2 Value:
       Bearer your_token

your_token is the value of the token you obtained previously, in Step 2. There should be a literal space between Bearer and your_token.

Clash Royale API pagination

Pagination is a process that is used to divide a large dataset into smaller chunks (pages). Usually the endpoints that return a list of resources support pagination. 

Most of the Clash Royale API endpoints use the pagination option. This means you need to add pagination some of these parameters at the end of the URL:

  • limit – limit the number of items returned in the response.;
  • after – return only items that occur after this marker. Before marker can be found from the response, inside the ‘paging’ property. Note that only after or before can be specified for a request, not both;
  • before – return only items that occur before this marker. Before marker can be found from the response, inside the ‘paging’ property. Note that only after or before can be specified for a request, not both.

Each endpoint that needs pagination will have in its documentation relevant information on which of these parameters you can use and how to do it.

Example:
https://api.clashroyale.com/v1/cards?limit=200

In the example above, the data set will have a limit of 200 records.

Step 4.) Enter your Clash Royale API request into the Apipheny add-on

Okay, now we’re in the home stretch. Now go back to your Google Sheet and make sure that the Apipheny add-on is open on the Import tab. With the Import Tab open, enter these details into the add-on:

Method: At the top of the Apipheny sidebar, select the HTTP method (GET or POST) as required by your Clash Royale API endpoint. For this example, we are using the GET method.

API URL: In Step 3, I explained how you can find the Clash Royale API endpoint that you need. Now copy the complete API URL into the Apipheny add-on, where it says API URL Path, followed by any GET parameters required for your query.

For this example, we are using the Clans endpoint, which retrieves all the information about a clan. The corresponding URL for this endpoint is:

https://api.clashroyale.com/v1/clans

If you’re following the same example as us, just copy and paste the URL above into the “API URL” field in Apipheny.

Headers: In the Headers section of the Apipheny add-on, add two rows, with the following keys and values:

Header 1
Key:
Accept
Value:
application/json
Header 2
Key:
Authorization
Value:
Bearer your_token

your_token is the value of the token you obtained previously, in Step 2. There should be a literal space between Bearer and your_token

This is what your API request should look like when entered into Apipheny:

Clash Royale API request entered into Apipheny with an API URL and 2 sets of headers
Clash Royale API request entered into Apipheny with an API URL and 2 sets of headers

Step 5.) Run the Clash Royale API request in your Google Sheet

The last step is to click the Run button at the bottom of the Apipheny add-on and then your Clash Royale data will be imported into your Google Sheet:

Clash Royale API data imported into Google Sheets using Apipheny
Clash Royale API data imported into Google Sheets using Apipheny

After making a successful request to the Clash Royale API, try querying a different Clash Royale API endpoint, or try using one of the more advanced features in the Apipheny add-on, such as:

  • Save and schedule your Clash Royale API request
  • Make a POST request to the Clash Royale API (if available)
  • Use the custom =APIPHENY() function to call the Clash Royale API request inside your spreadsheet
  • Create an API request by referencing the value of a cell in your Clash Royale API URL with three curly braces eg. {{{Sheet1!A1}}}

Crypto API Tutorials:


API Tutorials


API Knowledge

What is an API?

What is an API URL?

What are parameters?

What is an endpoint?

What is an API key/token?

What is basic authentication?

What are headers?

What is a GET request?

What is a POST request?