Skip to content

Instantly share code, notes, and snippets.

@tiefpunkt
Forked from dlo/export_foursquare_checkins.py
Last active October 3, 2016 19:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tiefpunkt/a33b481fb41c8ecec1b506cc6cb4434a to your computer and use it in GitHub Desktop.
Save tiefpunkt/a33b481fb41c8ecec1b506cc6cb4434a to your computer and use it in GitHub Desktop.
Download all your Foursquare checkins with Python.
# pip install requests
import requests
import json
url_template = 'https://api.foursquare.com/v2/users/self/checkins?limit=250&oauth_token={}&v=20131026&offset={}'
# If you navigate to https://developer.foursquare.com/docs/explore, Foursquare
# will generate an OAuth token for you automatically. Cut and paste that token
# below.
oauth_token = ""
offset = 0
data = []
with open("/tmp/checkins.json", 'w') as f:
while True:
response = requests.get(url_template.format(oauth_token, offset))
if len(response.json()['response']['checkins']['items']) == 0:
break
data = data + response.json()['response']['checkins']['items']
offset += 250
f.write(json.dumps(data))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment