https://github.com/andreaskoch/togglapi
A go wrapper for the Toggl API
https://github.com/andreaskoch/togglapi
Last synced: about 1 year ago
JSON representation
A go wrapper for the Toggl API
- Host: GitHub
- URL: https://github.com/andreaskoch/togglapi
- Owner: andreaskoch
- License: apache-2.0
- Created: 2016-09-18T14:56:49.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2016-10-03T12:32:44.000Z (over 9 years ago)
- Last Synced: 2024-06-21T14:17:49.340Z (about 2 years ago)
- Language: Go
- Size: 44.9 KB
- Stars: 3
- Watchers: 3
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# Toggl API for go
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).
[](https://travis-ci.org/andreaskoch/togglapi)
## Installation
Download `github.com/andreaskoch/togglapi`:
```bash
go get github.com/andreaskoch/togglapi
```
## Supported API methods
`github.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.
## Usage
```go
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](example/main.go)
```bash
cd $GOPATH/src/github.com/andreaskoch/togglapi/example
go run main.go Your-Toggl-API-Token
```
## Development
Run the unit tests:
```bash
cd $GOPATH/src/github.com/andreaskoch/togglapi
make test
```
Create code coverage reports:
```bash
cd $GOPATH/src/github.com/andreaskoch/togglapi
make coverage
```
## Licensing
TogglCSV is licensed under the Apache License, Version 2.0. See [LICENSE](LICENSE) for the full license text.