Skip to content

Instantly share code, notes, and snippets.

@nealtz
Created April 28, 2014 18:36
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save nealtz/11380295 to your computer and use it in GitHub Desktop.
Save nealtz/11380295 to your computer and use it in GitHub Desktop.
Moves Data to Day One
# Moves Data to Day One
# This is NOT a nice programmed working script. It is some code I created
# with the iOS Pythonista App to get data from the Moves App into the Day One App.
# You need to get a Moves Api token before you can use this script
import requests, json, datetime
def MovesHistory(callDate):
print 'callDate is ', callDate
access_token = 'XXX'
mytoken = '?access_token=' + access_token
api_url = 'https://api.moves-app.com/api/1.1'
output = ''
# Start Session to get Moves Data
with requests.Session() as s:
iurl = 'https://api.moves-app.com/oauth/v1/tokeninfo' + mytoken
i = s.get(iurl)
status = i.json()
callDateApi = callDate.strftime('%Y%m%d')
lurl = api_url + '/user/places/daily/' + callDateApi + '?access_token=' + access_token
l = s.get(lurl)
places = json.loads(l.text)
placesDict = places[0]
segments = placesDict['segments']
for i in segments:
segmentPlace = i
PlacePlace = segmentPlace['place']
if PlacePlace['type'] != 'unknown':
startTimeTmp = segmentPlace['startTime']
startTimeTime = datetime.datetime.strptime(startTimeTmp[:15], '%Y%m%dT%H%M%S')
endTimeTmp = segmentPlace['endTime']
endTimeTime = datetime.datetime.strptime(endTimeTmp[:15], '%Y%m%dT%H%M%S')
startTime = startTimeTime.strftime('%Y-%m-%d %H:%M')
endTime = endTimeTime.strftime('%H:%M')
location = startTime + '-' + endTime + ' ' + PlacePlace['name']
output = output + location + '\n'
return output
if __name__ == "__main__":
# change (days=0) to get data from earlyer days
choosenDate = datetime.datetime.now() - datetime.timedelta(days=0)
output = MovesHistory(choosenDate)
print choosenDate.strftime('%A, %d.%m.%Y') + ':'
print output
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment