A go wrapper for the Toggl API
github.com/andreaskoch/togglapi is a simple wrapper for the Toggl API (https://github.com/toggl/toggl_api_docs).
Download github.com/andreaskoch/togglapi:
go get github.com/andreaskoch/togglapigithub.com/andreaskoch/togglapi currently only supports the following methods of the Toggl API:
- Clients
CreateClient(client Client) (Client, error)GetClients() ([]Client, error)
- Workspaces
GetWorkspaces() ([]Workspace, error)
- Projects
CreateProject(project Project) (Project, error)GetProjects(workspaceID int) ([]Project, error)
- Time Entries
CreateTimeEntry(timeEntry TimeEntry) (TimeEntry, error)GetTimeEntries(start, end time.Time) ([]TimeEntry, error)
I might add the missing methods in the future, but if you need them now please add them and send me a pull-request.
package main
import (
"time"
"github.com/andreaskoch/togglapi"
)
func main() {
apiToken := "Your-API-Token"
baseURL := "https://www.toggl.com/api/v8"
api := togglapi.NewAPI(baseURL, apiToken)
// workspaces
workspaces, workspacesError := api.GetWorkspaces()
...
// clients
clients, clientsError := api.GetClients()
...
// projects by workspace
for _, workspace := range workspaces {
projects, projectsError := api.GetProjects(workspace.ID)
...
}
// time entries
stop := time.Now()
start := stop.AddDate(0, -1, 0)
timeEntries, timeEntriesError := api.GetTimeEntries(start, stop)
...
}You can also have a look at the example command line utility: example/main.go
cd $GOPATH/src/github.com/andreaskoch/togglapi/example
go run main.go Your-Toggl-API-TokenRun the unit tests:
cd $GOPATH/src/github.com/andreaskoch/togglapi
make testCreate code coverage reports:
cd $GOPATH/src/github.com/andreaskoch/togglapi
make coverageTogglCSV is licensed under the Apache License, Version 2.0. See LICENSE for the full license text.