iOS.Lover
iOS.Lover

Reputation: 6051

Get the specific username data with Instagram API

I am trying to search and get datas (Profile picture and username )from the exact or specific username with Instagram API. The problem is if I search for example starwars it won't show me the official page it shows me this username : starwars_viii !!! Here is my code :

https://api.instagram.com/v1/users/search?q=[USERNAME]&client_id=[CLIENT ID]&count=1

I have to say I am getting datas without authentication.

Upvotes: 1

Views: 1128

Answers (2)

iOS.Lover
iOS.Lover

Reputation: 6051

I fix this issue by count = 10 and then filter it with the exact username

Upvotes: 0

phi
phi

Reputation: 10733

Are you sure it's enough to provide the client id only? According to their docs, you should provide an access_token:

https://api.instagram.com/v1/users/search?q=jack&access_token=ACCESS-TOKEN

Response:

{
    "data": [{
        "username": "jack",
        "first_name": "Jack",
        "profile_picture": "http://distillery.s3.amazonaws.com/profiles/profile_66_75sq.jpg",
        "id": "66",
        "last_name": "Dorsey"
    },
    {
        "username": "sammyjack",
        "first_name": "Sammy",
        "profile_picture": "http://distillery.s3.amazonaws.com/profiles/profile_29648_75sq_1294520029.jpg",
        "id": "29648",
        "last_name": "Jack"
    },
    {
        "username": "jacktiddy",
        "first_name": "Jack",
        "profile_picture": "http://distillery.s3.amazonaws.com/profiles/profile_13096_75sq_1286441317.jpg",
        "id": "13096",
        "last_name": "Tiddy"
    }]
}

And as you can see in the response, the first result is the exact username "jack".

Upvotes: 1

Related Questions