Skip to content

Instantly share code, notes, and snippets.

@mizvol
Created April 21, 2017 10:51
Show Gist options
  • Save mizvol/ce96d0217516dcd1aca9a39bce55e6e5 to your computer and use it in GitHub Desktop.
Save mizvol/ce96d0217516dcd1aca9a39bce55e6e5 to your computer and use it in GitHub Desktop.
from requests import get, Session, adapters
def getInstaPosts(latitude, longitude, distance, minTimestamp, maxTimestamp, count):
params = {
'lat': latitude,
'lng': longitude,
'distance': distance, # radius of requested area
'min_timestamp': str(minTimestamp), #start date
'max_timestamp': str(maxTimestamp), #end date
'count': COUNT, # number of posts(100 max)
'access_token': INSTAGRAM_ACCESS_TOKEN #your access token
}
session = Session()
session.mount("https://", adapters.HTTPAdapter(max_retries=10))
response = session.get("https://api.instagram.com/v1/media/search", params=params, verify=True)
return response.json()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment