Skip to content

Instantly share code, notes, and snippets.

@Chandler
Last active December 20, 2018 09:06
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 Chandler/c8278e94d2c0037daea7797b2bb131fb to your computer and use it in GitHub Desktop.
Save Chandler/c8278e94d2c0037daea7797b2bb131fb to your computer and use it in GitHub Desktop.
Download Swarm Data
# pip install requests
import requests
import json
url_template = 'https://api.foursquare.com/v2/users/self/checkins?limit=250&oauth_token={}&v=20131026&offset={}'
# to find your oauth token you need to visit the swarm webapp and inspect your network requests, it will be attached
# to XHR requests once you scroll and it starts fetching timeline activity.
# https://www.swarmapp.com/activity
oauth_token = ""
offset = 0
data = []
with open("data.json", 'w') as f:
while True:
response = requests.get(url_template.format(oauth_token, offset))
if len(response.json()['response']['checkins']['items']) == 0:
break
print response.json()
data.append(response.json())
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