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.3.1.tar.gz (35.1 kB view details)

Uploaded Source

Built Distribution

toggl_api_wrapper-1.3.1-py3-none-any.whl (46.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: toggl_api_wrapper-1.3.1.tar.gz
  • Upload date:
  • Size: 35.1 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.3.1.tar.gz
Algorithm Hash digest
SHA256 ece63160764dbcb579fc3f09a37e69959091a571c497b7ca7812b4cafb9a9e1b
MD5 06c6c6cd94381875e754a7fcccc69be9
BLAKE2b-256 9d0724f212112f8a7ddd32224b9aae37b012ad8062baa24dc829c5e5d8ded98f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: toggl_api_wrapper-1.3.1-py3-none-any.whl
  • Upload date:
  • Size: 46.0 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.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 591e7f224fc3263f1ffa7aacef6ff2d39cfc4d2220180a2074276fae68b648c1
MD5 e861579c8b046710073c478d1b6f6182
BLAKE2b-256 ba3533601cb251c39af02c020c0c82175ae948aab1b8ea56b3090fa9971d7667

See more details on using hashes here.

Supported by

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