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.4.tar.gz
(29.8 kB
view details)
Built Distribution
File details
Details for the file toggl_api_wrapper-1.0.4.tar.gz
.
File metadata
- Download URL: toggl_api_wrapper-1.0.4.tar.gz
- Upload date:
- Size: 29.8 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
Algorithm | Hash digest | |
---|---|---|
SHA256 | c83ad289698089934bfba768c7ccdec3020756f7cb50ee454b741827ca1dff4b |
|
MD5 | dc19b73eaae2b623d57f483e0e9c07ef |
|
BLAKE2b-256 | 190ace88ed41c87149f038898bfdb5c0efdb496e731bfa4f30cff33fc785b625 |
File details
Details for the file toggl_api_wrapper-1.0.4-py3-none-any.whl
.
File metadata
- Download URL: toggl_api_wrapper-1.0.4-py3-none-any.whl
- Upload date:
- Size: 38.9 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
Algorithm | Hash digest | |
---|---|---|
SHA256 | 997a64db206da3d5a952bd4ef6e5919c14a2a7d742bfa0516776a4caa76852c7 |
|
MD5 | 2af4875b7978b59d3413d5482d11c379 |
|
BLAKE2b-256 | bb8b347266e5497f6adebc9f96034cc6d85b8c72c5a10e6ca730f7285d9644b5 |