How to connect Discord to Google Sheets

Discord is a popular chat app, much like Slack. In this tutorial, we’ll show you how to connect the Discord API to Google Sheets in 7 steps:

  1. Install the Apipheny Add-on
  2. Create a Discord App
  3. Obtain your Discord Code
  4. Obtain a Bearer Access Token
  5. Choose your Endpoint URL
  6. Enter Discord API into Apipheny
  7. Run the Discord API request

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.) Create a Discord App

Go to https://discord.com/developers/applications and click the New Application button:

New Discord Application
New Discord Application

In the Create an application popup, complete the Name field and then click the Create button:

Create an application
Create an application

Your app will then be created and the client id and secret will be displayed on the screen:

Discord app client ID and secret
Discord app client ID and secret

Click the Copy button and then paste these values to a safe location, because you will need the ID and client secret in the following steps.

In the OAuth2 section, add a redirect URI by clicking the Add Redirect button:

Add redirect
Add redirect

Complete the Redirects field with any valid URL and then save the changes by clicking the Save Changes button:

Create redirect
Create redirect

Step 3.) Obtain a Discord code

Go to the following link into your browser:

https://discordapp.com/api/oauth2/authorize?response_type=code&client_id=your_client_id&scope=identify%20guilds.join&state=15773059ghq9183habn&redirect_uri=your_redirect_uri&prompt=consent

Don’t forget to replace your_client_id and your_redirect_uri values with the ones you obtained in Step 2 above.

Then you’ll be asked to authorize the action. Click the Authorize button:

Authorize the app
Authorize the app

You’ll then be redirected to your redirect URL. At the end of the URL, you’ll find the required code:

Copy the value after the “code“ parameter to a safe location, because you’ll need it later.

Step 4.) Obtain a Bearer Access Token

Open up a command prompt window (for Windows OS) or a terminal (for Mac OS) and enter the following command:

curl -X POST "https://discordapp.com/api/oauth2/token" --data "client_id=your_client_id" --data "client_secret=your_client_secret" --data "grant_type=authorization_code" --data "code=your_code" --data "redirect_uri=your_redirect_URI" --data "scope=identify"
Note: For Mac OS you may need to use single quotes ( ' ) instead of double quotes ( " ).

Don’t forget to replace these values:

  • your_code is the code you previously obtained in Step 3
  • your_client_id is your client id from Step 2
  • your_client_secret is your client secret from Step 2
  • your_redirect_URI is your redirect URI from Step 2
  • For the scope parameter, you should add any scopes that your requests need, separated by commas.

Your Bearer access token will then be displayed in the response:

Copy and paste your Bearer access token to a safe location because you’ll need it later.

Note: If the token/key that you generate has an expiration time, you will need to complete this same process again to get a new token when the old one expires.

Step 5.) Choose your endpoint URL

In this section, we’ll show you how to browse the Discord API documentation to find an API endpoint URL that retrieves the information you need. If you already know your endpoint URL, or you want to use the same example URL as us, just skip to Step 6.

First, open the Discord API documentation page: https://discord.com/developers/docs/reference

The menu on the left contains a list of categorized endpoints for the Discord API:

Discord API endpoints
Discord API endpoints

In this case, we’ll use the Invite category, which contains two endpoints: Get invite and Delete invite.

Invite API documentation
Invite API documentation

An example endpoint is the Get invite endpoint, which returns an invite object for the given code:

https://discordapp.com/api/v9/invites/{invite.code}

The documentation for this endpoint contains the HTTP method used (GET) and the request path, a short description of the endpoint’s purpose and a table describing the accepted parameters:

Get Invite and Delete Invite documentation
Get Invite and Delete Invite documentation

All API calls to Discord should be made to the https://discordapp.com/api/v9/ base domain.

Discord API base/root URL:

https://discordapp.com/api/v9/
Note: Discord changes the version of their API often. Check their documentation to confirm the latest version and update the version number in the URL if necessary.

Step 6.) Enter your API request into Apipheny

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) required by your API endpoint. For this example, we are using the GET method.

API URL: In Step 5, we explained how you can find the Discord API endpoint that you need. Now copy the complete URL into the Apipheny add-on, where it says API URL Path (JSON / CSV), followed by any GET parameters required for your query.

For this example, we are using the Get current user endpoint that returns the current user. The corresponding URL is:

https://discordapp.com/api/v9/users/@me

Headers: In the Headers section, add one row with the following key and value:

Key:
Authorization
Value:
Bearer your_token

Replace your_token with the value of the token you generated previously, in Step 4. There should be a space between Bearer and your_token.

Discord API request entered into Apipheny

Step 7.) Run the Discord API Request

Lastly, click the Run button at the bottom of the Apipheny add-on and then wait for the Discord API data to be pulled in to your Google Sheet:

Discord API data in Google Sheets

After making a successful request to the Discord API, try querying a different endpoint, or try using one of the more advanced features in the Apipheny add-on.


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?