subzeroid / instagrapi

🔥 The fastest and powerful Python library for Instagram Private API 2024
https://hikerapi.com/p/bkXQlaVe
MIT License
4.37k stars 684 forks source link

Block and report users #742

Open adw0rd opened 2 years ago

adw0rd commented 2 years ago

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.
88um commented 2 years ago

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")
adw0rd commented 2 years ago

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