instagrapi icon indicating copy to clipboard operation
instagrapi copied to clipboard

Block and report users

Open adw0rd opened this issue 3 years ago • 2 comments

Discussed in https://github.com/adw0rd/instagrapi/discussions/740

Originally posted by chrishsr June 23, 2022 I'm fighting Bot accounts on my page, and an API endpoint to Block and report these users would make my life a lot easier. Thanks in advance.

adw0rd avatar Jun 23 '22 14:06 adw0rd

def unblock(self, user_id : str) -> bool:
    """
    Unblock an Instagram user

    Parameters
    ----------
    user_id: str
        User ID

    Returns
    -------
    bool
        A boolean value
    """
    data = {"surface":"profile","is_auto_block_enabled":"true","user_id":user_id,"_uid":self.user_id,"_uuid":self.uuid}
    response = self.private_request(f"friendships/unblock/{user_id}/",data=data)
    return response.get("friendship_status",{}).get("blocking") == False

def block(self, user_id : str) -> bool:
    """
    Block an Instagram user

    Parameters
    ----------
    user_id: str
        User ID

    Returns
    -------
    bool
        A boolean value
    """
    data = {"surface":"profile","is_auto_block_enabled":"true","user_id":user_id,"_uid":self.user_id,"_uuid":self.uuid}
    response = self.private_request(f"friendships/unblock/{user_id}/",data=data)
    return response.get("friendship_status",{}).get("blocking")

88um avatar Aug 02 '22 05:08 88um

@88um great! Can you send me a PR?

adw0rd avatar Aug 07 '22 05:08 adw0rd