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.3.tar.gz
(29.6 kB
view details)
Built Distribution
File details
Details for the file toggl_api_wrapper-1.0.3.tar.gz
.
File metadata
- Download URL: toggl_api_wrapper-1.0.3.tar.gz
- Upload date:
- Size: 29.6 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 | 9de4f58c6f62ff4e76c1da98aa6a8ea1810b3d2a230517317f7341c4db81ff46 |
|
MD5 | b478ed985885518b59e824ad37727bdb |
|
BLAKE2b-256 | 13b4a1c3e2b63553bc4462a1d0d0490a8a28eeb2d7149b272d7c3ad4b1a7088d |
File details
Details for the file toggl_api_wrapper-1.0.3-py3-none-any.whl
.
File metadata
- Download URL: toggl_api_wrapper-1.0.3-py3-none-any.whl
- Upload date:
- Size: 38.7 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 | 2722e6a1a1d9eb38d5e71f8cbea279d3105e4c25571a70ba258a8f4ae7988fd9 |
|
MD5 | ebc787c264c8e248d85a43f50075a2bb |
|
BLAKE2b-256 | f65cd96ea12e4972666e31c64fd192a78c401e7851bf90dcda6bf5a4e1fe9aae |