How to connect the ElectionsOnline API to Google Sheets

The ElectionsOnline (REST) API retrieves voting data including elections, ballots, voter groups, positions, candidates, and rosters. We can use the Elections Online API to import data into Google Sheets. In this tutorial, we’ll show you how to connect the ElectionsOnline REST API to Google Sheets in 5 steps:

  1. Install the Apipheny add-on
  2. Obtain an API key
  3. Choose an ElectionsOnline endpoint
  4. Enter your ElectionsOnline API request into Apipheny
  5. Run the ElectionsOnline API request in your Google Sheet

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.) Obtain an API key

After logging to your account, go to My Info tab:

ElectionsOnline dasboard
ElectionsOnline dasboard

Click the My account profile link:

My account profile link
My account profile link

Here you’ll find the API token. Copy it to a safe location because you’ll need it later.

API token displayed on the screen
API token displayed on the screen

Step 3.) Choose an ElectionsOnline API Endpoint URL

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

First, open the ElectionOnline API documentation page: https://www.electionsonline.com/integrations/api.cfm

The main page contains Authentication, Tips for developers, Special Note for ColdFusion Websites, Styling the Ballot and if you scroll down the API Methods sections:

ElectionsOnline documentation page
ElectionsOnline documentation page
The API Methods section
The API Methods section

An example endpoint is Get Voters, which gets all voters for fully-hosted elections. he URL for this endpoint is:

https://www.electionsonline.com/rest/v3/elections/{electionID}/voters

Don’t forget to replace {electionID} with a real ID for an election.

Each endpoint’s documentation contains a descriptive title, a paragraph describing the endpoint’s purpose, the endpoint’s HTTP method (GET) and URL, as well as an example request and response:

Get voters endpoint documentation
Get voters endpoint documentation

All API calls to ElectionsOnline should be made to the https://www.electionsonline.com/rest/v3/ base domain. All endpoints should be appended to this base URL.

Step 4.) Enter your ElectionsOnline API request into Apipheny

Now, to get your ElectionsOnline data in your Google Sheet, go back to your Google Sheet and make sure that you’ve installed the Apipheny add-on and you have it opened on the Import tab. In the Import tab of Apipheny, enter the following details into the add-on:

Method: At the top of the Apipheny sidebar, select the HTTP method (GET, POST, PUT, PATCH or DELETE) required by your ElectionsOnline API endpoint. For this example, we are using the “GET” method.

API URL: In Step 3, we explained how you can find the ElectionsOnline API endpoint that you need. Now copy your complete ElectionsOnline API URL into the Apipheny add-on, in the field that says API URL Path, followed by any POST parameters required for your query (if applicable).

For this example, we are using the Get elections endpoint, which gets general data about elections useful for displaying an announcement about an upcoming election, or the deadline to vote in a currently-running election. The URL for this specific endpoint is:

https://www.electionsonline.com/rest/v3/elections?startdate=DATE

Make sure you replace DATE with a valid date in yyyy/mm/dd format.

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

Header 1
Key:
Authorization
Value:
Basic encoded_string

Header 2
Key:
Key
Value:
your_token

When entering the Header 1 Value, replace encoded_string with the Base64-encoded version of your concatenated Username and Password, with a semicolon separator between them. You can use a site you trust like https://www.base64encode.org/ to encode your username:password string. Just enter your details like this username:password and then click EncodeMore info about Base64 encoding.

When entering the Header 2 Value, replace your_token with the token value you obtain at Step 2.)

Here’s what our ElectionsOnline API request looks like in Apipheny:

ElectionsOnline API request entered in the Apipheny add-on
ElectionsOnline API request entered in the Apipheny add-on

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

Finally, the last step is to click the Run button at the bottom of the Apipheny add-on and then wait for the ElectionsOnline API data to be imported into your Google Sheet. Here’s what our request looked like when completed:

ElectionsOnline data imported into Google Sheets using the Apipheny add-on
ElectionsOnline data imported into Google Sheets using the Apipheny add-on

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?