Test the public API endpoint with your share codes
// Simple fetch
const shareCode = 'ABC12345';
const response = await fetch(`https://stamina-api.onrender.com/${shareCode}`);
const data = await response.json();
console.log(`Stamina: ${data.stamina_score}%`);
console.log(`Color: ${data.color}`);
console.log(`Update interval: ${data.update_interval_seconds}s`);
console.log(`Realtime: ${data.realtime}`);
// With ETag caching for efficient polling
let etag = null;
async function pollStamina() {
const headers = etag ? { 'If-None-Match': etag } : {};
const response = await fetch(`https://stamina-api.onrender.com/${shareCode}`, { headers });
if (response.status === 304) {
console.log('Data unchanged (304) - watch hasn\'t sent new data yet');
return;
}
etag = response.headers.get('etag');
const data = await response.json();
updateUI(data);
}
// IMPORTANT: Poll at update_interval_seconds rate
// This matches how often the watch app sends data (e.g., 3s, 10s, 30s)
const data = await fetch(`https://stamina-api.onrender.com/${shareCode}`).then(r => r.json());
setInterval(pollStamina, data.update_interval_seconds * 1000);
// Example: If user is monitored with 3s interval, polls every 3s
// If user is free tier (300s), polls every 5 minutes# Fetch JSON data
curl https://stamina-api.onrender.com/ABC12345
# With headers
curl -i https://stamina-api.onrender.com/ABC12345
# With ETag (conditional request)
curl -H "If-None-Match: W/\"abc123\"" https://stamina-api.onrender.com/ABC12345
# Download SVG badge
curl https://stamina-api.onrender.com/ABC12345?format=svg -o badge.svgimport requests
import time
share_code = "ABC12345"
api_url = f"https://stamina-api.onrender.com/{share_code}"
etag = None
def fetch_stamina():
global etag
headers = {'If-None-Match': etag} if etag else {}
response = requests.get(api_url, headers=headers)
if response.status_code == 304:
print("Data unchanged (304)")
return None
etag = response.headers.get('ETag')
data = response.json()
print(f"Stamina: {data['stamina_score']}%")
print(f"Color: {data['color']}")
print(f"Timestamp: {data['timestamp_cst']}")
return data
# Fetch once
data = fetch_stamina()
# Poll based on update interval
if data:
while True:
time.sleep(data['update_interval_seconds'])
fetch_stamina()<!-- HTML -->
<img src="https://stamina-api.onrender.com/ABC12345?format=svg"
alt="IRL Health Bar"
style="max-width: 100%;">
<!-- Markdown -->

<!-- Auto-refresh every 10 seconds -->
<img id="healthBadge"
src="https://stamina-api.onrender.com/ABC12345?format=svg"
alt="IRL Health Bar">
<script>
setInterval(() => {
const img = document.getElementById('healthBadge');
const timestamp = new Date().getTime();
img.src = `https://stamina-api.onrender.com/ABC12345?format=svg&t=${timestamp}`;
}, 10000);
</script>Live Badge Preview (updates with your share code)