Skip to content

Instantly share code, notes, and snippets.

@benfoxall
Last active April 20, 2018 20:47
Show Gist options
  • Save benfoxall/be1b1827978a64b7b40d to your computer and use it in GitHub Desktop.
Save benfoxall/be1b1827978a64b7b40d to your computer and use it in GitHub Desktop.
A bash script for exporting runkeeper data.
# Requires:
# a) `jq` to be installed
# b) A Bearer token (you can grab this from the healthgraph debug console)
export BEARER=MY_TOKEN_FROM_THE_CONSOLE
curl https://api.runkeeper.com/fitnessActivities?pageSize=100 -H "Authorization: Bearer $BEARER" > page1.json
curl https://api.runkeeper.com/fitnessActivities?pageSize=100&page=2 -H "Authorization: Bearer $BEARER" > page2.json
curl https://api.runkeeper.com/fitnessActivities?pageSize=100&page=3 -H "Authorization: Bearer $BEARER" > page3.json
curl https://api.runkeeper.com/fitnessActivities?pageSize=100&page=4 -H "Authorization: Bearer $BEARER" > page4.json
curl https://api.runkeeper.com/fitnessActivities?pageSize=100&page=5 -H "Authorization: Bearer $BEARER" > page5.json
# add more if you have more pages of data
# Find all activity urls
jq '.items' page*.json | grep uri | sed 's/^.*"\///g' | sed 's/"//g' > urls.txt
# Download json data
mkdir fitnessActivities
while read p; do
curl https://api.runkeeper.com/$p -H "Authorization: Bearer $BEARER" > $p.json
done < urls.txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment