Simple Toggl API wrapper for non-premium features.
Project description
Python Toggl API Wrapper
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,
)
WORKSPACE_ID = 2313123123
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
Release history Release notifications | RSS feed
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.0.2.tar.gz
(29.5 kB
view hashes)
Built Distribution
Close
Hashes for toggl_api_wrapper-1.0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 852821d4da5a1f30279ba01925d6e8639fe2f4cd5b3bbc88dd0c0f2d8494b3ee |
|
MD5 | 5bd5d65051f5137d0caf41acb248789a |
|
BLAKE2b-256 | 90fb54f59ff1f06554b0aedc58e67255dd8f15e6aa453065ba8b585a9a5e25b0 |