Skip to main content

Python Toggl API Wrapper

PyPI - Version PyPI - Python Version GitHub Actions Workflow Status Codecov PyPI - Downloads

Simple Toggl API wrapper for non-premium features primarily focused on creating a cached framework for developing custom commands.


Installation

Install with pip:

pip install toggl-api-wrapper

Or if using SQLite cache:

pip install "toggl-api-wrapper[sqlite]"

Or if using async classes:

pip install "toggl-api-wrapper[async]"

Usage

  • Currently supports interacting with Trackers, Projects, Clients, Tags, Reports and some extras.
  • Designed to be rudimentary to allow simple development of custom commands.

Examples

Tracker Endpoint
from datetime import timedelta
from pathlib import Path

from toggl_api.config import generate_authentication
from toggl_api import TrackerBody, TrackerEndpoint, JSONCache


WORKSPACE_ID = 2313123123
AUTH = generate_authentication()
cache = JSONCache(Path("cache"), timedelta(hours=24))
endpoint = TrackerEndpoint(WORKSPACE_ID, AUTH, cache)

body = TrackerBody("My First Tracker", tags=["My First Tag"])
tracker = endpoint.add(body)
print(tracker)

Outputs:

>>> TogglTracker(
        id=3482231563,
        name="My First Tracker",
        workspace=2313123123,
        start=datetime.datetime(2024, 6, 10, 14, 59, 20, tzinfo=datetime.timezone.utc),
        duration=datetime.timedelta(seconds=1, microseconds=179158),
        stop=None,
        project=None,
        tags=[],
    )
Project Endpoint
from datetime import timedelta
from pathlib import Path

from toggl_api import ProjectBody, ProjectEndpoint, TogglProject
from toggl_api.config import retrieve_togglrc_workspace_id, use_togglrc
from toggl_api.meta.cache import JSONCache

WORKSPACE_ID = retrieve_togglrc_workspace_id()
AUTH = use_togglrc()
cache = JSONCache[TogglProject](Path("cache"), timedelta(hours=24))
endpoint = ProjectEndpoint(WORKSPACE_ID, AUTH, cache)

color = ProjectEndpoint.get_color("red")
body = ProjectBody(
    "My First Project",
    client_name="My First Client",
    color=color,
)
project = endpoint.add(body)
print(project)

Outputs:

>>> TogglProject(
        id=203366783,
        name='My First Project',
        workspace=2313123123,
        color='#d92b2b',
        client=65298912,
        active=True,
    )

Documentation

Contributing

See CONTRIBUTING.

License

MIT. Check LICENSE for more information.

Metadata

Release files for toggl-api-wrapper 2.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for toggl-api-wrapper 2.2.0
File Size Uploaded
toggl_api_wrapper-2.2.0.tar.gz 171.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for toggl-api-wrapper 2.2.0
File Interpreter ABI Platform
toggl_api_wrapper-2.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 265.9 kB

Release files / toggl_api_wrapper-2.2.0.tar.gz

Download URL toggl_api_wrapper-2.2.0.tar.gz
Size 171.5 kB
Tags Source
SHA-256 checksum
How to use checksums
89d00ad68720e02bdf58aff60cbbcff70c2eea82d8c35656a13f28e4bb277348
BLAKE2b-256 checksum
How to use checksums
7ecaa0e9566f43cd2fccd5b60474c94796ce6fa5dc4f682228a06a0b0eabe756
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.7.3

Release files / toggl_api_wrapper-2.2.0-py3-none-any.whl

Download URL toggl_api_wrapper-2.2.0-py3-none-any.whl
Size 94.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
49ec45fc77231d346dd12fac8fafaf1f23b41fdd9ac8170f0421a472c2a1fca6
BLAKE2b-256 checksum
How to use checksums
24f960c1ac5980757ce5ad85f0eb75f2bfaf36031678fb2f67c9c22038118c2d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.7.3

Release history Release notifications | RSS feed

This release

2.2.0 This release

2 release files

2.1.0

2 release files

2.0.0

2 release files

1.6.0

2 release files

1.5.1

2 release files

1.5.0

2 release files

1.4.0

2 release files

1.3.2

2 release files

1.3.1

2 release files

1.3.0

2 release files

1.2.0

2 release files

1.1.1

2 release files

1.1.0

2 release files

1.0.4

2 release files

1.0.3

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0.0

2 release files

0.5.1

2 release files

0.5.0

2 release files

0.4.0

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.3

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page