Clash Royale is a freemium strategy game by Supercell. In this tutorial, I’ll show you how to easily connect the Clash Royale REST API to Google Sheets in 5 steps:

  1. Install the Apipheny Add-on
  2. Create a Clash Royale API Key and 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 in Google Sheets

To pull data from the Clash Royale API into Google Sheets, first install and open the Apipheny Google Sheets add-on.

Apipheny is a no-code API integrator for Google Sheets that you can use to make unlimited API requests, connect to unlimited APIs, save API requests, schedule API requests, and more.

1. Install Apipheny by opening the following link on desktop and then clicking the Install button on the page: https://gsuite.google.com/marketplace/app/apipheny/966163326746

Install Apipheny to connect the Clash Royale API to Google Sheets
Install Apipheny to connect the Clash Royale API to Google Sheets

2. After you’ve installed Apipheny, open a Google Sheet and then click on the Add-Ons option in the top menu. In the add-ons menu, you should see Apipheny.

Click Apipheny > Import API to open the Apipheny sidebar in your Google Sheets.

Open the Apipheny add-on in your Google Sheets to connect the Clash Royale API
Open the Apipheny add-on in your Google Sheets to connect the Clash Royale API

Step 2.) Create a Clash Royale API Key and 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 token will 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 URL 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/

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>. Do not include the brackets “<>” around 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 Sheets

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}}}

Related articles:

Related Posts