Search API Connector Documentation
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
- Part 1: Get your Toggl API Key
- Part 2: Create your API Request URL
- Part 3: Pull Toggl API Data into Sheets
- Part 4: More Example API URLs
- Part 5: Handle Pagination
- Part 6: API Documentation
Before You Begin
Click here to install the API Connector add-on from the Google Marketplace.
Part 1: Get Your Toggl API Key
- Log into your account on Toggl.com
- From the main dashboard, click your name and then Profile Settings
- Scroll down the page until you see a section called “API Token”. Copy this to your clipboard.
- One last step: Because the Toggl API requires Basic Authentication, we need to encode our authentication info to base 64. Enter 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.
(check the final section of this article for an alternative method of encoding your credentials)
Part 2: Create Your Toggl API Request URL
We’ll first get your time stats.
- API root: https://api.track.toggl.com/reports/api
- Endpoint: /v2/summary
- Query String:workspace_id=YOUR_WORKSPACE_ID&user_agent=YOUR_EMAIL
You can retrieve your workspace ID by checking your URL while logged into the Toggl dashboard:
Putting it all together, we get the full API Request URL:
https://api.track.toggl.com/reports/api/v2/summary?workspace_id=3994670&[email protected]
Just substitute in your own email address and workspace ID.
Part 3: Pull Toggl API Data into Sheets
Now let’s enter that URL into API Connector.
- Open up Google Sheets and click Extensions > API Connector > Open.
- In the Create screen, enter the Request URL we just created
- Under Headers, enter a set of key-value pairs, like this:
Authorization Basic YOUR_BASE64_ENCODED_STRING Replace YOUR_BASE64_ENCODED_STRING with your encoded string from part 1.
- Create a new tab and click Set current to use that tab as your data destination.
- Under Output options, switch to Grid mode (this makes the output easier to read).
- Name your request and click Run. A moment later you’ll see your time stats populate the Toggl_Summary tab in your Google Sheet:
Part 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:
- Weekly report
https://api.track.toggl.com/reports/api/v2/weekly?user_agent=YOUR_EMAIL&workspace_id=YOUR_ID&since=2021-05-19&until=2021-05-20&
- Detailed report
https://api.track.toggl.com/reports/api/v2/details?user_agent=YOUR_EMAIL&workspace_id=YOUR_ID&since=2021-05-19&until=2021-05-20&
- Summary report
https://api.track.toggl.com/reports/api/v2/summary?user_agent=YOUR_EMAIL&workspace_id=YOUR_ID&since=2021-05-19&until=2021-05-20&
Part 5: Handle Pagination
By default, Toggl only returns 50 records at a time for certain endpoints. To get more you need to use the “page” parameter as described in their documentation.
In API Connector you can do this automatically with pagination handling, like this:
- Pagination:
page parameter
- Page parameter:
page
- Run until: choose when to stop fetching data

Part 6: API Documentation
Official documentation: https://github.com/toggl/toggl_api_docs/blob/master/reports.md
Note that Toggl’s API documentation provides many example curl requests, which you can import using API Connector’s curl import tool. These curl snippets look like this:curl -v -u 1971800d4d82861d8f2c1651fea4d212:api_token -X GET "https://api.track.toggl.com/reports/api/v2/summary?workspace_id=123&since=2021-05-19&until=2021-05-20&user_agent=api_test"
Just copy and paste those snippet into the curl import tool, replacing the bold values with your own. When you import from curl, your token will automatically be encoded and your request details will automatically appear in the sidebar.
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
Hi Gilberto, thank you! I’ve just updated the article with the new hostname and will update the screenshots soon.
Here are specifics on the authorization header format:
https://github.com/toggl/toggl_api_docs/blob/master/chapters/authentication.md
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?
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.
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!
This works for me, but I get a maximum of 50 lines of data. I would like to be able to generate an entire year of data in my sheet. Is this possible?
Good question, please use ‘page’ parameter pagination. Under Output Options > pagination choose Pagination = “page parameter”, and then enter Page parameter = “page” and the number of pages you’d like to fetch. I’ll update the article to reflect this!
Hi,
Thank you so much for this article it really helps a lot.
May I ask if is it possible to fetch all the data from the other member? Let say, I’d like to auto fetch all the entries of 15 agents. Is it possible?
Thank you so much.
Hi Zella, thank you, I’m glad the article helped. However I’m not entirely sure of the answer to your question since I’m not really sure what “member” or “agent” corresponds to. If you check their API documentation you can see many different parameters like “client_ids”, “user_ids”, and so on, so you can add any of those if that’s what you’re looking for.
I suspect there may also be authentication limits here as well, like most likely you can only retrieve data that you have access to in the interface.