/TogglApiDotNet

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

Primary LanguageC#MIT LicenseMIT

Build status codecov 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 no automated tests for this library at present. There is 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.