Skip to main content

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:

  1. Browser-based OAuth2 (ss.login())
  2. Direct API key via Client constructor
  3. SWEATSTACK_API_KEY environment 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

sweatstack-0.14.1.tar.gz (83.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sweatstack-0.14.1-py3-none-any.whl (13.7 kB view details)

Uploaded Python 3

File details

Details for the file sweatstack-0.14.1.tar.gz.

File metadata

  • Download URL: sweatstack-0.14.1.tar.gz
  • Upload date:
  • Size: 83.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.5

File hashes

Hashes for sweatstack-0.14.1.tar.gz
Algorithm Hash digest
SHA256 9e6e75fc0888603006af591ccff54db4a6f3d4d63e39d11e8597033a3dccd59e
MD5 4cd9d8f0f60d46abbf42db7d501ccafe
BLAKE2b-256 c56dca2fa1eeb393b9b5ac1ea2e21cb3689101ade36aafcbe8628701df875907

See more details on using hashes here.

File details

Details for the file sweatstack-0.14.1-py3-none-any.whl.

File metadata

  • Download URL: sweatstack-0.14.1-py3-none-any.whl
  • Upload date:
  • Size: 13.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.5

File hashes

Hashes for sweatstack-0.14.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b0b67e7f76f3ce480d222a353b6d0db3d660014a5f8c356bfbc9d6c660ea5e37
MD5 28c3a42a251aeed4021450302b4525a2
BLAKE2b-256 7b8e9cd1c69204a95d89f8ca3fd31a43e55ce403131836999d9816b63a89c0fb

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page