<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://johnwick.cc/index.php?action=history&amp;feed=atom&amp;title=Advanced_Dashboard_Interactivity_with_Streamlit_%2B_APIs</id>
	<title>Advanced Dashboard Interactivity with Streamlit + APIs - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://johnwick.cc/index.php?action=history&amp;feed=atom&amp;title=Advanced_Dashboard_Interactivity_with_Streamlit_%2B_APIs"/>
	<link rel="alternate" type="text/html" href="https://johnwick.cc/index.php?title=Advanced_Dashboard_Interactivity_with_Streamlit_%2B_APIs&amp;action=history"/>
	<updated>2026-05-07T02:35:04Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.44.1</generator>
	<entry>
		<id>https://johnwick.cc/index.php?title=Advanced_Dashboard_Interactivity_with_Streamlit_%2B_APIs&amp;diff=3156&amp;oldid=prev</id>
		<title>PC: Created page with &quot;650px  Learn how to build advanced interactive dashboards using Streamlit + APIs. From live data to user actions, make dashboards feel like SaaS apps.    Hook: The Problem with “Static Dashboards” Dashboards are everywhere. From startup founders showing KPIs to ML engineers monitoring models, everyone loves a clean Streamlit dashboard. But let’s be real: most dashboards are static. You pull data, render a chart, and...&quot;</title>
		<link rel="alternate" type="text/html" href="https://johnwick.cc/index.php?title=Advanced_Dashboard_Interactivity_with_Streamlit_%2B_APIs&amp;diff=3156&amp;oldid=prev"/>
		<updated>2025-12-13T22:31:31Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;&lt;a href=&quot;/index.php?title=File:Advanced_Dashboard_Interactivity.jpg&quot; title=&quot;File:Advanced Dashboard Interactivity.jpg&quot;&gt;650px&lt;/a&gt;  Learn how to build advanced interactive dashboards using Streamlit + APIs. From live data to user actions, make dashboards feel like SaaS apps.    Hook: The Problem with “Static Dashboards” Dashboards are everywhere. From startup founders showing KPIs to ML engineers monitoring models, everyone loves a clean Streamlit dashboard. But let’s be real: most dashboards are static. You pull data, render a chart, and...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;[[file:Advanced_Dashboard_Interactivity.jpg|650px]]&lt;br /&gt;
&lt;br /&gt;
Learn how to build advanced interactive dashboards using Streamlit + APIs. From live data to user actions, make dashboards feel like SaaS apps.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Hook: The Problem with “Static Dashboards”&lt;br /&gt;
Dashboards are everywhere. From startup founders showing KPIs to ML engineers monitoring models, everyone loves a clean Streamlit dashboard.&lt;br /&gt;
But let’s be real: most dashboards are static. You pull data, render a chart, and call it a day. Nice for a demo, useless for real-time decision-making.&lt;br /&gt;
The future isn’t static dashboards. It’s interactive dashboards powered by APIs — dashboards that fetch live data, trigger backend workflows, and even act like lightweight SaaS products.&lt;br /&gt;
And Streamlit in 2025 makes this easier than ever.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Why Streamlit + APIs Is a Game-Changer&lt;br /&gt;
On its own, Streamlit is great for prototyping. But when you pair it with APIs, you get dashboards that:&lt;br /&gt;
* 		Fetch real-time stock prices, weather, IoT feeds&lt;br /&gt;
* 		Trigger long-running jobs (model retraining, ETL, report generation)&lt;br /&gt;
* 		Act as a frontend for microservices&lt;br /&gt;
* 		Feel more like a SaaS app than a “data notebook with charts”&lt;br /&gt;
Let’s walk through concrete patterns — and yes, lots of code.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Pattern 1: Pulling Live Data via REST API&lt;br /&gt;
Suppose you want a dashboard for cryptocurrency prices.&lt;br /&gt;
Here’s the boring version: load a CSV. Here’s the real version: pull from a live API.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
import streamlit as st&lt;br /&gt;
import requests&lt;br /&gt;
import pandas as pd&lt;br /&gt;
&lt;br /&gt;
st.title(&amp;quot;📈 Live Crypto Dashboard&amp;quot;)&lt;br /&gt;
# Simple REST API call&lt;br /&gt;
def fetch_prices(symbol=&amp;quot;BTCUSDT&amp;quot;):&lt;br /&gt;
    url = f&amp;quot;https://api.binance.com/api/v3/ticker/24hr?symbol={symbol}&amp;quot;&lt;br /&gt;
    resp = requests.get(url)&lt;br /&gt;
    return resp.json()&lt;br /&gt;
symbol = st.selectbox(&amp;quot;Choose a crypto&amp;quot;, [&amp;quot;BTCUSDT&amp;quot;, &amp;quot;ETHUSDT&amp;quot;, &amp;quot;BNBUSDT&amp;quot;])&lt;br /&gt;
data = fetch_prices(symbol)&lt;br /&gt;
st.metric(&amp;quot;Price&amp;quot;, f&amp;quot;${data[&amp;#039;lastPrice&amp;#039;]}&amp;quot;)&lt;br /&gt;
st.metric(&amp;quot;24h Change&amp;quot;, f&amp;quot;{data[&amp;#039;priceChangePercent&amp;#039;]}%&amp;quot;)&lt;br /&gt;
st.metric(&amp;quot;Volume&amp;quot;, data[&amp;#039;volume&amp;#039;])&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now every time a user selects a symbol, the dashboard makes a live API call. That tiny trick makes your dashboard feel alive.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Pattern 2: Background Jobs with Async APIs&lt;br /&gt;
But what if the job takes time — say you’re retraining a model? You don’t want the dashboard freezing while users wait.&lt;br /&gt;
Enter async APIs.&lt;br /&gt;
&lt;br /&gt;
Imagine a FastAPI backend that kicks off a job:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# backend.py (FastAPI)&lt;br /&gt;
from fastapi import FastAPI, BackgroundTasks&lt;br /&gt;
import time&lt;br /&gt;
&lt;br /&gt;
app = FastAPI()&lt;br /&gt;
def train_model():&lt;br /&gt;
    time.sleep(10)  # fake long job&lt;br /&gt;
    with open(&amp;quot;status.txt&amp;quot;, &amp;quot;w&amp;quot;) as f:&lt;br /&gt;
        f.write(&amp;quot;done&amp;quot;)&lt;br /&gt;
@app.post(&amp;quot;/train&amp;quot;)&lt;br /&gt;
def trigger_training(background_tasks: BackgroundTasks):&lt;br /&gt;
    background_tasks.add_task(train_model)&lt;br /&gt;
    return {&amp;quot;status&amp;quot;: &amp;quot;started&amp;quot;}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then in Streamlit:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
import streamlit as st&lt;br /&gt;
import requests&lt;br /&gt;
import time&lt;br /&gt;
&lt;br /&gt;
st.title(&amp;quot;⚡ Trigger Model Training&amp;quot;)&lt;br /&gt;
if st.button(&amp;quot;Train Model&amp;quot;):&lt;br /&gt;
    resp = requests.post(&amp;quot;http://localhost:8000/train&amp;quot;)&lt;br /&gt;
    st.success(&amp;quot;Training started... check status below&amp;quot;)&lt;br /&gt;
# Poll for status&lt;br /&gt;
if st.button(&amp;quot;Check Status&amp;quot;):&lt;br /&gt;
    with open(&amp;quot;status.txt&amp;quot;) as f:&lt;br /&gt;
        st.info(f&amp;quot;Training Status: {f.read()}&amp;quot;)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This pattern turns a dashboard into a control panel for workflows.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Pattern 3: Streaming Data into Charts&lt;br /&gt;
Static charts are old news. Streaming charts? That’s next-level.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
import streamlit as st&lt;br /&gt;
import requests&lt;br /&gt;
import time&lt;br /&gt;
import pandas as pd&lt;br /&gt;
&lt;br /&gt;
st.title(&amp;quot;📡 Live IoT Sensor Data&amp;quot;)&lt;br /&gt;
chart = st.line_chart([])&lt;br /&gt;
for i in range(50):  # simulate stream&lt;br /&gt;
    resp = requests.get(&amp;quot;https://api.coindesk.com/v1/bpi/currentprice.json&amp;quot;)&lt;br /&gt;
    price = resp.json()[&amp;quot;bpi&amp;quot;][&amp;quot;USD&amp;quot;][&amp;quot;rate_float&amp;quot;]&lt;br /&gt;
    new_data = pd.DataFrame({&amp;quot;price&amp;quot;: [price]})&lt;br /&gt;
    chart.add_rows(new_data)&lt;br /&gt;
    time.sleep(2)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now your dashboard looks like a Bloomberg terminal.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Pattern 4: Secure APIs with Auth&lt;br /&gt;
Public dashboards are fun until you realize you’re exposing sensitive endpoints. Enter authentication.&lt;br /&gt;
Here’s a Streamlit login gate:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
import streamlit as st&lt;br /&gt;
import requests&lt;br /&gt;
&lt;br /&gt;
st.title(&amp;quot;🔐 Secure Dashboard&amp;quot;)&lt;br /&gt;
API_URL = &amp;quot;http://localhost:8000/protected&amp;quot;&lt;br /&gt;
username = st.text_input(&amp;quot;Username&amp;quot;)&lt;br /&gt;
password = st.text_input(&amp;quot;Password&amp;quot;, type=&amp;quot;password&amp;quot;)&lt;br /&gt;
if st.button(&amp;quot;Login&amp;quot;):&lt;br /&gt;
    resp = requests.post(&amp;quot;http://localhost:8000/login&amp;quot;, json={&amp;quot;username&amp;quot;: username, &amp;quot;password&amp;quot;: password})&lt;br /&gt;
    if resp.status_code == 200:&lt;br /&gt;
        token = resp.json()[&amp;quot;access_token&amp;quot;]&lt;br /&gt;
        st.session_state[&amp;quot;token&amp;quot;] = token&lt;br /&gt;
        st.success(&amp;quot;Logged in!&amp;quot;)&lt;br /&gt;
    else:&lt;br /&gt;
        st.error(&amp;quot;Invalid credentials&amp;quot;)&lt;br /&gt;
# Protected call&lt;br /&gt;
if &amp;quot;token&amp;quot; in st.session_state:&lt;br /&gt;
    headers = {&amp;quot;Authorization&amp;quot;: f&amp;quot;Bearer {st.session_state[&amp;#039;token&amp;#039;]}&amp;quot;}&lt;br /&gt;
    resp = requests.get(API_URL, headers=headers)&lt;br /&gt;
    st.write(resp.json())&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Suddenly your Streamlit app looks like a mini SaaS app with login + API calls.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Pattern 5: Two-Way Dashboards (APIs Write Back)&lt;br /&gt;
Most dashboards are read-only. But the real world requires write-backs:&lt;br /&gt;
* 		Add a user to CRM&lt;br /&gt;
* 		Update a config&lt;br /&gt;
* 		Send a Slack notification&lt;br /&gt;
Example: sending a Slack message from a Streamlit dashboard.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
import streamlit as st&lt;br /&gt;
import requests&lt;br /&gt;
&lt;br /&gt;
st.title(&amp;quot;💬 Send Slack Message&amp;quot;)&lt;br /&gt;
message = st.text_area(&amp;quot;Message to send&amp;quot;)&lt;br /&gt;
if st.button(&amp;quot;Send&amp;quot;):&lt;br /&gt;
    webhook_url = &amp;quot;https://hooks.slack.com/services/xxx/yyy/zzz&amp;quot;&lt;br /&gt;
    payload = {&amp;quot;text&amp;quot;: message}&lt;br /&gt;
    resp = requests.post(webhook_url, json=payload)&lt;br /&gt;
    if resp.status_code == 200:&lt;br /&gt;
        st.success(&amp;quot;Message sent to Slack ✅&amp;quot;)&lt;br /&gt;
    else:&lt;br /&gt;
        st.error(&amp;quot;Failed to send&amp;quot;)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This moves dashboards from viewer-only to action-triggering control panels.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Case Study: Turning a Notebook into a SaaS-Like Dashboard&lt;br /&gt;
I once built a sales forecasting model in a Jupyter notebook. It worked — barely. But the business team didn’t want “run this cell and hope it works.” They wanted a tool.&lt;br /&gt;
&lt;br /&gt;
So I wrapped the model in a FastAPI service and built a Streamlit dashboard that:&lt;br /&gt;
* 		Pulled live sales data from an API&lt;br /&gt;
* 		Let users upload CSVs&lt;br /&gt;
* 		Triggered retraining jobs&lt;br /&gt;
* 		Displayed forecasts in interactive charts&lt;br /&gt;
Here’s a simplified slice:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
import streamlit as st&lt;br /&gt;
import requests&lt;br /&gt;
import pandas as pd&lt;br /&gt;
&lt;br /&gt;
st.title(&amp;quot;📊 Sales Forecast Dashboard&amp;quot;)&lt;br /&gt;
# Upload CSV&lt;br /&gt;
file = st.file_uploader(&amp;quot;Upload Sales Data&amp;quot;, type=[&amp;quot;csv&amp;quot;])&lt;br /&gt;
if file:&lt;br /&gt;
    df = pd.read_csv(file)&lt;br /&gt;
    st.write(&amp;quot;Uploaded Data:&amp;quot;, df.head())&lt;br /&gt;
    if st.button(&amp;quot;Run Forecast&amp;quot;):&lt;br /&gt;
        resp = requests.post(&amp;quot;http://localhost:8000/forecast&amp;quot;, json=df.to_dict(orient=&amp;quot;records&amp;quot;))&lt;br /&gt;
        results = resp.json()&lt;br /&gt;
        st.line_chart(results[&amp;quot;forecast&amp;quot;])&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
What started as a notebook became a tool the sales team used daily.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Extra Tricks for Streamlit + API Power Users&lt;br /&gt;
* 		Caching API calls:&lt;br /&gt;
@st.cache_data(ttl=60) def fetch_data():   &lt;br /&gt;
return requests.get(&amp;quot;https://api.example.com/data&amp;quot;).json()&lt;br /&gt;
* 		WebSockets for real-time: Streamlit now supports async → connect to WebSocket APIs.&lt;br /&gt;
* 		Session state for auth tokens: persist user sessions across tabs.&lt;br /&gt;
* 		Theming + CSS hacks: Make dashboards look like SaaS products, not academic notebooks.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Closing Thoughts&lt;br /&gt;
Streamlit started as a data scientist’s toy. But when you add APIs, it becomes something bigger: A way to build real-time, interactive, SaaS-like apps in hours.&lt;br /&gt;
If you’re still building dashboards that only show static CSVs, you’re missing the future. APIs + Streamlit = dashboards that act, not just display.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Read the full article here: https://medium.com/@hadiyolworld007/advanced-dashboard-interactivity-with-streamlit-apis-f63bead069bf&lt;/div&gt;</summary>
		<author><name>PC</name></author>
	</entry>
</feed>