Skip to main content

Simple Toggl API wrapper for non-premium features.

Project description

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

toggl_api_wrapper-2.1.0.tar.gz (167.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

toggl_api_wrapper-2.1.0-py3-none-any.whl (88.5 kB view details)

Uploaded Python 3

File details

Details for the file toggl_api_wrapper-2.1.0.tar.gz.

File metadata

  • Download URL: toggl_api_wrapper-2.1.0.tar.gz
  • Upload date:
  • Size: 167.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.6.14

File hashes

Hashes for toggl_api_wrapper-2.1.0.tar.gz
Algorithm Hash digest
SHA256 2f6ccf22c73bfb1e67447b565d85245f78f2e62fbb43c6ae52dbbd01e6d2e578
MD5 dfc661a5c116025d230bd73758720624
BLAKE2b-256 fba732f441f32df604a6a07233906d457e54e3582bae133ead4a89b532eb60f3

See more details on using hashes here.

File details

Details for the file toggl_api_wrapper-2.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for toggl_api_wrapper-2.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5aac13c98702cd88d227ec137be65182af0adf292cdd8545b7bee970163a0fce
MD5 0e84abc657a3ccec7fd47fcdfea909fc
BLAKE2b-256 0cfccbca205355ebe745e249c876543a10010b7944ff770ebc3e184e0672a043

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page