A bitbar plugin for Strava. Shows you how many miles you've run so far this year.
Last active
August 7, 2018 05:03
-
-
Save tmcw/5b526522c704d8ad4e7a3bdb8063b072 to your computer and use it in GitHub Desktop.
Strava Bitbar plugin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
# coding=utf8 | |
# | |
# <bitbar.author>Tom MacWright</bitbar.author> | |
# <bitbar.author.github>tmcw</bitbar.author.github> | |
# <bitbar.title>Get your mileage from Strava</bitbar.title> | |
# <bitbar.version>1.0</bitbar.version> | |
# <bitbar.desc>Shows this week and this year’s numbers</bitbar.desc> | |
# <bitbar.image>http://i.imgur.com/JtguThL.png</bitbar.image> | |
# <bitbar.dependencies>python</bitbar.dependencies> | |
# <bitbar.abouturl>https://macwright.org/</bitbar.abouturl> | |
import requests | |
from pprint import pprint | |
# Get an access token at https://www.strava.com/settings/api | |
# Get your id as the number at the end of the URL of your Strava profile | |
id = "YOUR_ID" | |
access_token = "YOUR_ACCESS_TOKEN" | |
headers = {"Authorization":"Bearer %s" % access_token} | |
resp = requests.get("https://www.strava.com/api/v3/athletes/%s/stats?page=&per_page=" % id, headers=headers).json() | |
print "{:.0f}mi".format(resp['ytd_run_totals']['distance'] / 1609.34) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment