https://github.com/dev-shimada/toggl-go
https://github.com/dev-shimada/toggl-go
Last synced: 8 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/dev-shimada/toggl-go
- Owner: dev-shimada
- License: bsd-3-clause
- Created: 2024-12-08T15:42:17.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-02-23T09:11:46.000Z (over 1 year ago)
- Last Synced: 2025-02-23T10:20:05.044Z (over 1 year ago)
- Language: Go
- Size: 31.3 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 13
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://goreportcard.com/report/github.com/dev-shimada/toggl-go)
[](https://coveralls.io/github/dev-shimada/toggl-go?branch=main)
[](https://github.com/dev-shimada/toggl-go/actions/workflows/CI.yaml)
[](https://github.com/dev-shimada/toggl-go/blob/master/LICENSE)
# Toggl Time Entries Go Client
This project provides a Go client for interacting with the [Toggl Track API](https://developers.track.toggl.com/docs/). It allows developers to integrate Toggl time tracking functionalities into their Go applications.
## Features
- Retrieve time entries with various query parameters
- Fetch the current running time entry
- Get a specific time entry by ID
- Create new time entries
- Bulk edit time entries
- Update existing time entries
- Delete time entries
- Stop a running time entry
## Installation
Use `go get` to install the package:
```plaintext
go get github.com/dev-shimada/toggl-go
```
## Usage
Here is an example of how to use the package:
```go
package main
import (
"fmt"
"os"
"time"
"github.com/dev-shimada/toggl-go/timeentries"
"github.com/dev-shimada/toggl-go/toggl"
)
func main() {
// Get your API token from https://toggl.com/app/profile
token := os.Getenv("TOKEN")
client := toggl.NewClient(token)
// Get time entries for the last 7 days
now := time.Now()
start := now.Add(-24 * 7 * time.Hour).Format(time.RFC3339)
end := now.Format(time.RFC3339)
result, err := client.TimeEntriesClient.GetTimeEntries(
timeentries.GetTimeEntriesInput{
Query: timeentries.GetTimeEntriesQuery{
StartDate: &start,
EndDate: &end,
},
},
)
if err != nil {
fmt.Println(err)
}
for _, v := range result {
fmt.Printf(
"ID: %d, Description: %s, Start: %s, Stop: %s, Duration: %d\n",
*v.Id, *v.Description, *v.Start, *v.Stop, *v.Duration,
)
}
}
```