Introduction #
Backend API refresh allows external systems (ETL schedulers, data pipelines) to notify SmartChart to refresh specified dashboard data caches after data is ready. More precise and resource-efficient than frontend scheduled refresh, ideal for “refresh after ETL completion” scenarios.
Use Cases #
- ETL workflow: wait for backend data refresh, then trigger dashboard refresh
- Time-consuming queries: pre-refresh to ensure fast first load
- Users need consistently fast page load experiences
Recommended: Set dataset cache time longer (e.g., 2 days / 2880 minutes)
Backend Refresh API (Pro Edition) #
- Set API_TOKEN in settings.py:
API_TOKEN = 'xxxxxxxx'
-
Find your dashboard code (type id) from the dashboard URL
-
Call the API:
http://ip:port/echart/refresh_ds/?type=your_report_id&token=your_API_TOKEN
Scheduled Refresh #
Use Linux crontab for scheduled refresh:
Create a shell script:
vim refresh_smartchart.sh
echo start refresh $(date "+%Y-%m-%d %H:%M:%S")
curl http://ip:port/echart/?type=report_id1&token=your_API_TOKEN
curl http://ip:port/echart/?type=report_id2&token=your_API_TOKEN
echo end refresh $(date "+%Y-%m-%d %H:%M:%S")
Make executable and schedule:
chmod 775 refresh_smartchart.sh
crontab -e
# Run daily at 5:10 AM
10 5 * * * /data/smartchart/refresh_smartchart.sh >>/data/smartchart/log.txt 2>&1