Skip to content

Instantly share code, notes, and snippets.

@NorthIsUp
Last active October 12, 2015 01:18
Show Gist options
  • Save NorthIsUp/3949465 to your computer and use it in GitHub Desktop.
Save NorthIsUp/3949465 to your computer and use it in GitHub Desktop.
Reverse engineering of the nike fuel api to get your fuel
"""
Author: [email protected]
to run you will need to install the following:
pip install requests
pip install simplejson
get the auth token and device id by sniffing the nike app syncing
with api.nike.com with charles
How to get teh device id and auth token:
1) Set up the proxy settings for api.nike.com
- open the proxy settings
- click 'SSL'
- add api.nike.com to the locations list.
2) Plug in you nike plus watch
3) In the sequence view search for "api.nike.com"
- there should be a few urls here
- you want /v1.0/me/sync/lasttimestamp
- the device id will be in the query parameters
"""
# blog post explaining all of this coming soon.
import requests
from pprint import pprint
try:
import simplejson as json
except ImportError:
import json
APPLICATION_JSON = 'application/json'
# when to start getting fuel data from
start_date = '011011'
# when to get data through
end_date = '290815'
# how many buckets to get the data in
fidelity = 24 * 60
headers = {
'Accept': APPLICATION_JSON,
'appid': 'fuelband'
}
params = {
'access_token': 'YOUR AUTH TOKEN',
'deviceId': 'YOUR DEVICE ID',
'endDate': end_date,
'fidelity': fidelity,
}
d = {
'protocol': 'https',
'domain': 'api.nike.com',
'version': 'v1.0',
'path': 'me/activities/summary/%s' % start_date,
}
url = '{protocol}://{domain}/{version}/{path}'.format(**d)
print url
print 'I solemnly swear that I am up to no good.'
r = requests.get(
url,
params=params,
headers=headers,
)
# Dump the raw data
f = open('fueldump_raw.json', 'w')
f.write(r.text)
f.close()
# write it out formatted nicely
f = open('fueldump_format.json', 'w')
json.dump(json.loads(r.text), f, indent=2)
f.close()
print 'Mischief managed'
# Uncomment to print the data, it is a lot of data...
# for activity in loaded['daily']:
# print activity['activityIds']
# print [x['fuel'] for x in activity['history']]
# summary = activity['summary']
# print summary['activeTime']
# print summary['calories']
# print summary['distance']
# print summary['startDate']
# print summary['totalFuel']
@aliou
Copy link

aliou commented Dec 3, 2012

Hey, any pointer on how to get the auth token and the device id? charles keeps crashing on me.

@NorthIsUp
Copy link
Author

How to get teh device id and auth token:

  1. Set up the proxy settings for api.nike.com
  • open the proxy settings
  • click 'SSL'
  • add api.nike.com to the locations list.
  1. Plug in you nike plus watch

  2. In the sequence view search for "api.nike.com"

  • there should be a few urls here
  • you want /v1.0/me/sync/lasttimestamp
  • the device id will be in the query parameters

@csteinlehner
Copy link

hi, thanks for providing this! I wonder in what format the date in the response is? it doesn't seems that it's unix timecode.

EDIT / ANSWER: sorry, of course it's unix timestamp * 1000

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment