SweatStack Console¶
SweatStack Console is an in-browser Python REPL (Read-Eval-Print Loop) that allows you to interact with the SweatStack API directly from your browser that is automatically authenticated with your SweatStack account. It's a great way to explore the API and Python library, test ideas, and prototype solutions without having to set up a local development environment.
SweatStack Console is inspired by and based on pyodide.org/en/stable/console.html.
Features¶
- Instant Access: No installation required - just open in your browser
- Pre-authenticated: Already connected to your SweatStack account
- Autocomplete: Intelligent code suggestions as you type
- Documentation: Built-in help and documentation
Getting Started¶
- Navigate to console.sweatstack.no
- Start coding!
Prefill Code¶
SweatStack Console accepts an optional prefill
parameter, which is a url encoded string of code that will be prefilled at the prompt when the console starts.
For security reasons, the prefilled code is not automatically executed.
Let's say you want to prefill this code in the console:
for i in range(10):
print(i)
The url encoded version of the prefill code would be:
for%20i%20in%20range%2810%29%3A%0A%20%20%20%20print%28i%29
So the full url would be:
https://console.sweatstack.no/?prefill=for%20i%20in%20range%2810%29%3A%0A%20%20%20%20print%28i%29
URL Encode Python Code
This is a great website if you want url encode some Python code: https://www.urlencoder.org/
Plotting¶
SweatStack Console has very basic plotting support using the matplotlib
library.
Example:
import matplotlib.pyplot as plt
import sweatstack as ss
data = ss.get_latest_activity_data()
data["heart_rate"].plot()
plt.show()
Plot are rendered at the bottom of the console (you might have to scroll down to see it).