First your need plotly npm package, and a plotly account.
npm install plotly
export PLOTLY_USERNAME=<plotly-username>
export PLOTLY_APIKEY=<plotly-apikey>
export MAPBOX_ACCESS_TOKEN=<your-mapbox-token>
To generate a image:
curl --silent "https://api.mapbox.com/analytics/v1/accounts/?period=2016-01-01,2016-04-29&access_token=$MAPBOX_ACCESS_TOKEN" | ./render-image.js > chart.png