Search API Connector Documentation

Print

Import Toggl Data to Google Sheets

In this guide, we’ll walk through how to pull time tracking data from the Toggl API directly into Google Sheets, using the API Connector add-on for Sheets. We’ll first get an API key from Toggl, and then set up a request to pull in your time tracking stats to your spreadsheet.

CONTENTS

BEFORE YOU BEGIN

Click here to install the API Connector add-on from the Google Marketplace.

PART 1: GET YOUR TOGGL API KEY

  1. Log into your account on Toggl.com
  2. From the main dashboard, click your name > Profile Settings
    toggl-img1
  3. Scroll down the page until you see a section called “API Token”. Copy this to your clipboard.
    toggl-img2
  4. One last step: Because the Toggl API requires Basic Authentication, we need to encode our authentication info to base 64. You can do this by entering your your credentials in the format YOUR_API_KEY:api_token into this form, where you substitute in your own api key where it says YOUR_API_KEY, and follow it with a colon and then the string ‘api_token’. Your encoded credentials will appear underneath.

    The encoding script runs in your browser, and none of your credentials are seen or stored by this site.

     

     

    (If you have any problems with the above, please check this post for some alternate methods of encoding your credentials).

PART 2: CREATE YOUR TOGGL API REQUEST URL

We’ll follow the Toggl API documentation to access your time stats.

  • API root: https://api.track.toggl.com/reports/api
  • Endpoint: /v2/summary
  • Query String:?user_agent=YOUR_EMAIL&workspace_id=YOUR_WORKSPACE_ID

You can retrieve your workspace ID by checking your URL while logged into the Toggl dashboard:
toggl-img3

Putting it all together, we get the full API Request URL:

https://api.track.toggl.com/reports/api/v2/summary?user_agent=hello@mixedanalytics.com&workspace_id=3994670

Just substitute in your own email address and workspace ID.

PART 3: PULL TOGGL API DATA INTO SHEETS

Now let’s enter our URL into API Connector and import Toggl data into Google Sheets.

  1. Open up Google Sheets and click Add-ons > API Connector > Open.
  2. In the Create screen, enter the Request URL we just created
    toggl-img4
  3. Under Headers, enter a set of key-value pairs, like this:
    AuthorizationBasic YOUR_BASE64_ENCODED_STRING

    Replace YOUR_BASE64_ENCODED_STRING with your encoded string from part 1.
    toggl-img5

  4. Create a new tab and click ‘Set current’ to use that tab as your data destination.
  5. Name your request and click Run. A moment later you’ll see your time stats populate the Toggl_Summary tab in your Google Sheet:toggl-img6

STEP 4: MORE EXAMPLE API URLS

You can check the documentation for the full list of available API requests,  but if you just want to jump in, you can play around with the URLs you enter in the API URL path field. Try the following (one at a time), including your email address and workspace ID:
https://api.track.toggl.com/reports/api/v2/weekly?user_agent=YOUR_EMAIL.com&workspace_id=YOUR_ID
https://api.track.toggl.com/reports/api/v2/weekly?user_agent=YOUR_EMAIL.com&workspace_id=YOUR_ID
https://api.track.toggl.com/reports/api/v2/summary?user_agent=YOUR_EMAIL.com&workspace_id=YOUR_ID

Additional metrics are available for users on the paid Toggl plans.

Previous Import Todoist Data to Google Sheets
Next Import Torn API Data to Google Sheets

8 thoughts on “Import Toggl Data to Google Sheets”

  1. Please update the article to use api.track.toggl.com:
    References:
    -https://github.com/toggl/toggl_api_docs
    -https://toggl.com/blog/api-documentation-change

    Reply
  2. Hi,

    I’ve been following strictly step by step several times this procedure and can’t obtain another result than:

    “1) Toggl_summary time stats: Completed with errors
    – We received an error from the API server (401) show response
    {“error”:{“message”:”api token missing”,”tip”:”You can find your API Token in your profile at https://www.toggl.com“,”code”:401}}”

    I did convert my API to Base 64, referred to your article several times, reset & recreated my API and started from scratch again: same result. What can I be missing?

    Reply
    • I just went through the steps in this article and it worked for me, so I’m not sure.
      Can you try a simple URL like https://api.track.toggl.com/api/v8/me and see if that works?
      Also, can you please doublecheck that you are including your token as an Authorization/Basic header like shown in the article? The only way I can get this error in my tests is if I don’t include it in as a header.

      Reply
      • Oh, dang, it has to be me of course! Thanks for your reply!
        What I was misunderstanding & missing was to *litterally* write ‘API_KEY:api_token’ and not to understand this part as just ‘API_KEY’ by itself (without the ‘:api_token’ in it).
        *facepalm.
        Thought it’s not my native language, but still, my bad : )
        While at it, do you know how I could display the results in lines and not in columns? Because one week of Toggl data (I query ‘details’) already go until JF column. Some sort of ‘transpose’ parameter within the initial query?

      • Oh yeah, it is confusing that one is the actual API key and one is just the word! Glad you got it sorted out 🙂

      • Wait, that’s ok, I think I found a good compromise playing with your tool settings.
        Thanks again! Will look to automate more things with your solution!

Leave a Comment

Table of Contents