Skip to content

Build a Streamlit App in Minutes

Getting your Streamlit app connected to SweatStack is quick and easy. This guide will walk you through creating a simple but functional Streamlit application that authenticates with SweatStack and displays activity data.

Get API Credentials

Before building your app, you'll need API credentials:

  1. Go to app.sweatstack.no/settings/api
  2. Click the "Create Application" button at the bottom of the page and fill out the details of your application
  3. After saving, create a secret for your application. Important: Treat this secret as a password and keep it safe.
  4. Copy and paste your client_id and client_secret into the code below.

Quick Example

Here's a complete working example of a Streamlit app that authenticates with SweatStack and displays the user's latest activity.

app.py
import streamlit as st
from sweatstack.streamlit import StreamlitAuth


auth = StreamlitAuth(
    client_id="{your_client_id}",
    client_secret="{your_client_secret}",
    redirect_uri="http://localhost:8501",
)

with st.sidebar:
    auth.authenticate()

if not auth.is_authenticated():
    st.stop()

st.write("# Welcome to SweatStack!")

latest_activity = auth.client.get_latest_activity()

st.write(latest_activity)

Run your app with:

uv run --with "sweatstack[streamlit]" streamlit run app.py

Further Building

Here are some quick ways to enhance your SweatStack Streamlit app:

Warning

Remember, when using Streamlit with SweatStack, always use the auth.client instance for making API calls instead of the global methods, as explained in the Streamlit integration documentation.