Table of Contents
How to connect wpDataTables with the Google Sheets API
Say your sales figures live in a private Google sheet that you don’t want to publish to the web, and your site’s table has to show every change right away. Connecting wpDataTables to the Google Sheets API solves both: wpDataTables reads the sheet through a Google service account, so the sheet can stay private, and changes show without Google’s 15-minute cache. You set up the account in Google Cloud once and paste its key into wpDataTables.
What do I need to connect the Google Sheets API?
You need a Google account that can create a project in the Google Cloud console, and about 10 minutes. The setup has four parts:
- A Google Cloud project with the Google Drive API and Google Sheets API turned on.
- A service account in that project, with a JSON key.
- The key pasted into wpDataTables → Settings.
- Each private sheet shared with the service account’s email.
How do I set up the project in Google Cloud?
Create a project, turn on the two APIs and create a service account with a JSON key, all in the Google Cloud console.
- Create a project. Open the Google Cloud console, click Select a project → New Project, enter a Project name, for example wpdatatables-sheets, and click Create. Then pick the new project in the project list at the top.
- Turn on the Google Drive API. Go to APIs & Services → Library, open Google Drive API and click Enable.
- Turn on the Google Sheets API. Go back to Library, open Google Sheets API and click Enable. Check that both APIs appear in Enabled APIs & services.
- Create the service account. Go to IAM & Admin → Service accounts and click + Create service account. Enter a Service account name; the Service account ID and email address fill in by themselves. Click Create and close. You can leave the optional Permissions and Principals with access steps empty.
- Create the key. Open the new service account, go to the Keys tab, click Add key → Create new key, keep the Key type JSON and click Create. Google downloads a .json file to your computer and shows Private key saved to your computer.

Where do I paste the service account key in wpDataTables?
Paste the whole content of the JSON file in Google service account data on the Google Spreadsheet API settings tab and click Validate & Save.
- Copy the key. Open the downloaded .json file in a text editor and copy all of its content.
- Open the settings. Go to wpDataTables → Settings and open the Google Spreadsheet API settings tab.
- Paste and validate. Paste the content in Google service account data and click Validate & Save.
- Check the connection. When the key is valid, the tab shows Your Google service account: with the service account email. You’ll need the email for private sheets.

To disconnect the account, click Remove account. Tables that read private sheets stop working until you connect an account again.
How do I create a table from a private Google sheet?
Share the sheet with the service account email, then create the table with the link from your browser’s address bar.
- Copy the email. Copy the email after Your Google service account: from the Google Spreadsheet API settings tab.
- Share the sheet. In Google Sheets, open the sheet and click Share. Paste the email in Add people, groups, spaces, and calendar events.
- Choose the role. The role list next to the email starts at Editor. Choose Viewer, which is enough for reading the sheet.
- Skip the notification. Clear Notify people. The Send button changes to Share; click it. The service account can now read the sheet, and the sheet stays private for everyone else.
- Create the table. Copy the sheet’s link from the address bar and use it to create a table from Google Sheets. You don’t need to publish the sheet.

What should I remember about the Google Sheets API?
Create a Google Cloud project, turn on the Google Drive API and Google Sheets API, create a service account and download its JSON key. Paste the key in Google service account data in wpDataTables → Settings → Google Spreadsheet API settings and click Validate & Save. Share private sheets with the service account email, keep the key private, and cache busy tables to stay within Google’s limits.
Where can I read more?
These pages cover Google Sheets tables and caching: