The official Python client for SweatStack
Project description
SweatStack Python client library
Quickstart
uv pip install sweatstack
import sweatstack as ss
ss.login()
ss.list_activities()
Authentication
SweatStack supports three authentication methods:
1. Browser-Based OAuth2 Authentication
ss.login() # Opens your default browser for authentication
2. Direct API Key Authentication
client = ss.Client(api_key="your-api-key")
3. Environment Variable
Set the SWEATSTACK_API_KEY environment variable:
export SWEATSTACK_API_KEY="your-api-key"
SweatStack follows this priority order:
- Browser-based OAuth2 (
ss.login()) - Direct API key via
Clientconstructor SWEATSTACK_API_KEYenvironment variable
For example, calling ss.login() or client.login() will override any existing API key authentication, including those set through the constructor or environment variables.
Interfaces: Singleton vs Class-based
This library provides both a singleton interface and a class-based interface.
Singleton interface:
import sweatstack as ss
activities = ss.list_activities()
Class-based interface:
from sweatstack import Client
client = Client()
activities = client.list_activities()
Although both interfaces are feature-equivalent, they serve different purposes:
- The singleton interface is the default and recommended interface. It is intended for most use cases and is the easiest to use.
- The class-based interface is intended for more advanced use cases, such as when you need to authenticate multiple users at the same time or in multi-threaded applications.
Streamlit integration
The sweatstack.streamlit module provides a Streamlit integration for SweatStack. This requires the optional streamlit dependency that can be installed with:
uv pip install 'sweatstack[streamlit]'
The StreamlitAuth class is a Streamlit component that handles the OAuth2 authentication flow. It provides a st.authenticate() function that can be used to authenticate the user.
Example usage:
from sweatstack.streamlit import StreamlitAuth
auth = StreamlitAuth()
with st.sidebar:
st.authenticate()
if not auth.is_authenticated():
st.write("User is not authenticated")
st.stop()
st.write("User is authenticated")
auth.client.get_latest_activity()
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file sweatstack-0.16.0.tar.gz.
File metadata
- Download URL: sweatstack-0.16.0.tar.gz
- Upload date:
- Size: 84.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
84aac4dbe00ecdc390ab983f7ce9e024a7911b1b5f27a64e2dd281ff8c72fe78
|
|
| MD5 |
1736455b6b4d5962038685c1002bdf93
|
|
| BLAKE2b-256 |
9054f7942e10b8103fb198c3f7297cf74dca0b59c9123f07a2e7d89b2ea587a0
|
File details
Details for the file sweatstack-0.16.0-py3-none-any.whl.
File metadata
- Download URL: sweatstack-0.16.0-py3-none-any.whl
- Upload date:
- Size: 14.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8488dd4bb421172123e59878f32dbb9cfd6b91c4bd2dad3f1a0a52f104ce5536
|
|
| MD5 |
cc5bb51aadebbfa9722082351771961e
|
|
| BLAKE2b-256 |
b77c5d6c46e691a684b0ce55bddead0def50437f0cf663ce09f02cbf8a37974c
|