Answer the question
In order to leave comments, you need to log in
How to properly collect data from Instagram API and Foursquare API?
I need to collect the maximum number of check-ins for a specific city from Foursquare and do the same with Instagram.
The problem is that in addition to the request limits (per hour), the API returns 10-20 results for any request, even if I change the request parameters and increase the number of results. I understand that you can’t collect a lot with one request and you need to run the algorithm several times (already for the locations found), but still it gives out very little.
What do i do?
I would be happy with an example of a request for a specific city.
Answer the question
In order to leave comments, you need to log in
1. Bypass restrictions on one token => you need more tokens, either you fool around and registrate a bunch of accounts in these social networks, or you arm yourself with search engines and search on sites ala pastebin, a link to a search engine for 100+ such resources tyk tyk , there you go to the Documents section - > Custom Pastebins (Meta search). The goal is to find someone's sources from which they forgot to remove the tokens, I once collected about 10 like this, but write yourself a small token checker script in advance, for example:
from requests import get
ig_api_key = 'YOUR INSTAGRAM API KEY'
answer = get('https://api.instagram.com/v1/users/search?q=facebook' + '&access_token=' + ig_api_key, verify=True).json()
print answer
def get_data_from_json(json_text):
answer = list()
for element in json_text['data']:
answer.append(element)
return answer
def get_media(username):
answer = list()
user_id = get_user_id(username)
data = get('https://api.instagram.com/v1/users/' + user_id + '/media/recent/?access_token=' +\
ig_api_key, verify=True).json()
try:
if data[u'meta'][u'code'] == 200:
if data[u'pagination'] == {}:
answer += get_data_from_json(data)
else:
answer += get_data_from_json(data)
while True:
if data[u'pagination'] != {}:
data = get(data[u'pagination'][u'next_url'], verify=True).json()
answer += get_data_from_json(data)
else:
break
else:
answer = list()
except:
answer = list()
return answer
Have you read the documentation? Not? Read.
Maximum Instagram API returns 20 results, then pagination.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question