Skip to content

simonwillcock/jstoggl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

JSToggl

An API wrapper to simplify interactions with the official Toggl API.

Find out more about Toggl.

Usage

You will need your API token that you can find in your Toggl profile.

You will also likely need to get the domain that you will be making requests from whitelisted so that the API returns the correct CORS headers. You can do so by emailing support@toggl.com with your domain name and requesting that it be added. They usually respond within 24 hours of making the request.

You will also require jQuery, but I hope to remove this requirement as it is really only being used to make the AJAX request.

Create your client

var Toggl = TogglClient(myToken);

Start and stop a timer

All requests return a promise with the API response that you can then use.

var timerId;
Toggl.timers.start('My Test Timer').then(function(timer){
    // Do stuff - eg. toggle the button state to stop the timer
    timerId = timer.data.id;
});

Toggl.timers.stop(timerId).then(function(){
    // Do stuff - eg. toggle the button state back to start another timer
});

Get the currently running timer

var timerId;
Toggl.timers.current().then(function(timer){
    if(timer.data !== null)
        timerId = timer.data.id;
    }
});

Create a new Client

Toggl.clients.create('My Client Pty Ltd').then(function(client){
    
});

Create projects assigned to a client

Toggl.clients.getProjects(clientId).then(function(projectArray){
    // for(var i = 0; i < projectArray.length; i++){ ... }
});

License

JSToggl may be freely distributed under the GPL v2 license.

About

An API wrapper to simplify interactions with the Toggl API

Resources

License

Stars

Watchers

Forks

Packages

No packages published