mcndt/obsidian-toggl-integration

Migrate Toggl API endpoints to v9 API

GitMurf opened this issue · 5 comments

However in the future I might write fork this so I can refactor it to use mobile friendly APIs (e.g. using Obsidian’s own request API).

@mcndt you mentioned in your READ ME here that you eventually would like to move away from using the 3rd party Toggl API SDK and instead use Obsidian request API. I am building some simple Templater scripts to directly access the Toggl API so thought I would share some starter code here in case you decide to implement in your plugin.

If you have any questions let me know.

Here are the new Toggl API Docs which were very helpful: https://developers.track.toggl.com/docs/api/time_entries

Here is a simple example of retrieving your current running timer using just the Obsidian API:

const togglApiKey = 'YOUR_API_KEY';
const authString = `Basic ${btoa(togglApiKey + ':api_token')}`;
let reqParams = {
    url: 'https://api.track.toggl.com/api/v9/me/time_entries/current',
    method: 'GET',
    headers: {
        "Content-Type": "application/json",
        Authorization: authString,
    },
}
let requestResults = await window.request(reqParams);
let dataResults = JSON.parse(requestResults);
console.log(dataResults);
mcndt commented

Hi @GitMurf, as I mentioned in #90, I already implemented this a few months ago in my fork of the toggl-client NPM package.

You can find my fork on the branch here: https://github.com/mcndt/toggl-client/tree/obsidian-request-api

Feel free to use my fork of the toggl-client in your own project, it takes care of all the boilerplate required to interface with the Toggl API (thanks to original author of the library).

If you have any improvements to add, feel free to contribute to the forked repository :)

@mcndt thanks for sharing! Cool, I see it now in your fork :) I noticed that Toggl API is now on v9 which is documented here: https://developers.track.toggl.com/docs/

Any thoughts on migrating to v9 down the road? I am not sure if they will deprecate v8 or not so maybe it is unnecessary but curious if you have looked into it at all?

Toggl GH docs says moving docs to the URL listed above with v9 going forward.

image

image

mcndt commented

Thank you for bringing this to my attention. I read the following on their new documentation:

This documentation focuses on current API v9 and the old v8 version will soon be deprecated.

I currently do not have the time commitment to make a migration to v9 unfortunately, though I expect that it will take them quite some time to actually shut down the v8 services.

If you feel like contributing to the toggl-client project, you could make a PR to https://github.com/saintedlama/toggl-client with updated v9 endpoints and I'll be very grateful to pull that into this project!

Hey @mcndt and @GitMurf,

My name is Apostolos and I am an Engineering Team Lead at Toggl. I wanted to reach out to extend our gratitude for creating an open source integration between Toggl Track and Obsidian and thinking about updating it to API v9.

In the light of API v8 full sunset (expected to happen sometime between Q1 and Q2 of 2023) I wanted to draw your attention to our WebHooks API as well, in case you were open considering it as a more suitable candidate to use for updating your integration to API v9.

If you have questions or need any other clarification, I would be happy to help to the best of my ability.