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()
Metadata
Release files for sweatstack 0.17.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| sweatstack-0.17.0.tar.gz | 84.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| sweatstack-0.17.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 99.1 kB
Release files / sweatstack-0.17.0.tar.gz
| Download URL | sweatstack-0.17.0.tar.gz |
|---|---|
| Size | 84.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e75118f0305fb593816254c01ab9b7ff91675e82fa67c74c380de909e4345bc8
|
|
BLAKE2b-256 checksum How to use checksums |
19902c0fc5cc6b5373225ebdb4887ccc048c1886b781735b5f8fe296ebe02f10
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.5
|
Release files / sweatstack-0.17.0-py3-none-any.whl
| Download URL | sweatstack-0.17.0-py3-none-any.whl |
|---|---|
| Size | 14.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b73e0d77558793dc67c605eb5dc0ea74b4f3ada81b75bfdb67619be0e16c1fb7
|
|
BLAKE2b-256 checksum How to use checksums |
1fadce3aa5cbfcd726df8356a4eaca0ea1fa0af56eec8ec1c3a39eec8f21e59b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.5
|