Skip to content

Instantly share code, notes, and snippets.

@rootulp
Forked from dlo/export_foursquare_checkins.py
Last active June 13, 2020 01:38
Show Gist options
  • Save rootulp/8c57bffd539bf238f4c4812dcabc6677 to your computer and use it in GitHub Desktop.
Save rootulp/8c57bffd539bf238f4c4812dcabc6677 to your computer and use it in GitHub Desktop.
Download all your Foursquare checkins with Python.
# Before running this script execut the following command:
# $ pip install requests
# To run this script execute:
# $ python export_foursquare_checkins.py
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. Copy and paste that token
# below.
oauth_token = ""
offset = 0
data = []
# This will save your foursquare_checkins to a file in the same directory as
# this script.
with open("foursquare_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.append(response.json())
offset += 250
f.write(json.dumps(data, sort_keys=True, indent=4, separators=(',', ': ')))
@skywinder
Copy link

As I can see, link developer.foursquare.com/docs/explore doesn't work anymore (got 404).

Is any updates, how to process rrequest with new API?
https://foursquare.com/developers/apps/

There is option to get app id and secret.

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