Skip to content

An API client for talking to both the Toggl API and the Toggl Reports API

License

Notifications You must be signed in to change notification settings

DaveTCode/TogglApiDotNet

Repository files navigation

CI Build Quality Gate Status codecov NuGet License: MIT

TogglAPI

This library provides a thin layer over the Toggl Json API as described here: https://github.com/toggl/toggl_api_docs.

Contributions are welcome, please submit issues or PRs.

Report API Usage

Get weekly report grouped by users for the most recent week:

var client = new TogglReportClient(httpClient: new HttpClient(), logger: Log);

var weeklyReport = await client.GetWeeklyReport(new WeeklyReportConfig<WeeklyReportResponseUserGroup>
            (
                userAgent: "test-app",
                workspaceId: workspaceId
            ), apiToken: apiToken);

Console.WriteLine(weeklyReport.Data[0].Title.User);

Get detailed report for fixed time period:

var detailedReport = await client.GetDetailedReport(new DetailedReportConfig
            (
                userAgent: "test-app",
                workspaceId: workspaceId,
                since: DateTime.UtcNow.AddDays(-14),
                until: DateTime.UtcNow
            ), apiToken: apiToken);

Development

Requirements

The library is written for .NET Standard 2.0 and is developed with the .NET Core 2.2 SDK.

Testing

There are a small suite of unit tests which mock out the Toggl API with canned responses as laid out in the TogglApi.Client.Tests project. These can be run from the command line with dotnet test.

There is also a manual test application which can be called from the command line using: dotnet run --project .\TogglApi.Client.ManualTest\TogglApi.Client.ManualTest.csproj -- <workspaceId> <apiKey>

where you can get your Api key from https://toggl.com/app/profile.

About

An API client for talking to both the Toggl API and the Toggl Reports API

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors 4

  •  
  •  
  •  
  •  

Languages