Search code examples
androidinstagraminstagram-api

Instagram API Is there a way of knowing if a user blocked logged user?


I am looking through all endpoints on instagram's api: https://instagram.com/developer/endpoints/#

After I get the authrization token I can do all the operations: like/change relationship/view user detais...

However, I see that some apps on android have this extra feature: see who blocked the currently logged on user. There is no mention on the API for this and when I try to query the details for a user, instead of showing is_private/blocked_you all I get is:

{
        "error_type": "APINotAllowedError",
        "code": 400,
        "error_message": "you cannot view this resource"
    }

Which makes sense, since the user is blocked and no info should be returned. But in this case, how do other apps get this "User has blocked you" info?


Solution

  • I may be wrong, but if Instagram's API is working like Facebook's, I can think about this idea.

    You have API to find your own relation to the an user.

    https://api.instagram.com/v1/users/{user-id}/relationship?
    
    access_token=ACCESS-TOKEN
    {
        "meta": {
            "code": 200
        }, 
        "data": {
            "outgoing_status": "none", 
            "incoming_status": "requested_by"
        }
    }
    

    Relationships are expressed using the following terms:

    outgoing_status: Your relationship to the user. Can be "follows", "requested", "none". incoming_status: A user's relationship to you. Can be "followed_by", "requested_by", "blocked_by_you", "none".

    This means you can't find users that blocked you, but you can find users blocked by you. From this point of view, if you have all your users tokens stored in your own database, you can write simple code that will log in as the user using this tokens, and check relationship to other users from your database. Results you can save to own database, use it, and to do updates, say, any X days, weeks...

    Pay attention, that this will work only if you use Instagram's OAuth API to log in users to your own service. And yes, this is a very slow method.