Answer the question
In order to leave comments, you need to log in
How to get instagram user details via api using python?
I need to get data about the user having his login. The documentation says this:
https://api.instagram.com/v1/users/self/?access_token=ACCESS-TOKEN
. But this method returns my own data and I need another user's data. Found this solution on google.get('https://api.instagram.com/v1/users/search?q=' + login + '/?access_token=' + api_key, verify=True).json()
. When run, the method returns a 400 error: {'meta': {'code': 400, 'error_type': 'OAuthAccessTokenException', 'error_message': 'The access_token provided is invalid.'}}. Is it possible to solve my problem? If yes please tell me how.
Answer the question
In order to leave comments, you need to log in
You are passing an invalid API access token, which is reported to you in the response from the server: "The access_token provided is invalid." You need to pass a valid token for your application.
To start:
/users/self - points to itself. therefore, you will get nothing but yourself here.
In what you found, there is already a different url.
I would do like this:
import requests
token = 'MY_TOKEN'
def get_user(user):
params = {
'access_token': token,
'q': user
}
url = 'https://api.instagram.com/v1/users/search'
try:
r = requests.get(url, params=params)
result = r.json()
return result
except:
return Exception
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question