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]"

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 import (
    TrackerBody,
    TrackerEndpoint,
    generate_authentication,
    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=[],
    )
User Endpoint
from datetime import timedelta
from pathlib import Path

from toggl_api import (
    UserEndpoint,
    generate_authentication,
    JSONCache,
)
from toggl_api.config import retrieve_workspace_id

WORKSPACE_ID = retrieve_workspace_id()
AUTH = generate_authentication()
cache = JSONCache(Path("cache"), timedelta(weeks=1))
endpoint = UserEndpoint(workspace_id, AUTH, CACHE)

tracker = endpoint.get(3482231563, refresh=True)
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=[],
    )

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-1.5.1.tar.gz (43.4 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-1.5.1-py3-none-any.whl (56.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: toggl_api_wrapper-1.5.1.tar.gz
  • Upload date:
  • Size: 43.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.4 CPython/3.12.1 Linux/6.5.0-1025-azure

File hashes

Hashes for toggl_api_wrapper-1.5.1.tar.gz
Algorithm Hash digest
SHA256 8cbff8f97196e8cc7b958148ba0b003c63034859a56c3c8b446e7da2e5c98408
MD5 17e561952790041604f9540a9080404f
BLAKE2b-256 02999dd786f47839677ceed74b6b0b306afeb7d42a57e2b6b66462ed5e7ac2dc

See more details on using hashes here.

File details

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

File metadata

  • Download URL: toggl_api_wrapper-1.5.1-py3-none-any.whl
  • Upload date:
  • Size: 56.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.4 CPython/3.12.1 Linux/6.5.0-1025-azure

File hashes

Hashes for toggl_api_wrapper-1.5.1-py3-none-any.whl
Algorithm Hash digest
SHA256 70141043931d8e3012a2fbbd02671cd730256335d893bcd4e4c6fb67ccae25c9
MD5 984295c0460c0b7a508e362600125a21
BLAKE2b-256 c4cedbfd8f14d9399a3d6114338fb98b580599bf790a4db084ed272a8696c7c3

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