How do ban a user on NFT

Ban a user using API's

The process of banning a user with NFT.Kred using the API takes on the same approach as banning it using our no-code application. Problematic users can be banned from a feed by its creator using /nft/ban API.

curl --request POST \
     --url 'https://api.nft.kred/nft/ban?token=YourTokenValue&user=YourUserId&nft=99999' \
     --header 'Accept: application/json' \
     --header 'Authorization: Basic am9obndvb2R5OTg1MkBnbWFpbC5jb206QWRtaW5AMTI=='

Unban a user using API's

Like banning a user from a message stream, anyone can also unban that user by calling nft/unban API.

curl --request POST \
     --url 'https://api.nft.kred/nft/unban?token=YourTokenValue&user=YourUserId&nft=99999' \
     --header 'Accept: application/json' \
     --header 'Authorization: Basic am9obndvb2R5OTg1MkBnbWFpbC5jb206QWRtaW5AMTI=='

Ban/unban a user using Python SDK

Banning a user using Python-SDK is simple. This Python SDK bridges the gap between your applications and NFT.Kred APIs. Full-scale NFT solutions can be built in hours - instead of months. You can use NFT.Kred functionality via this python package and interact with the NFT.Kred APIs directly in your app.

Installation & Usage
We have created a tutorial on how you can install the Python SDK on your machine. Read our step-by-step guide on “How to install Python SDK” for more details. After importing the python SDK, please follow the below steps to ban a user using Python SDK.

Step 1: Import SDK Files
Create a python file and import the below necessary library files by adding the following code.

from kred import services
from kred import models

Step 2: Define ban API method on your python file
Now we need to create a method that will call the "ban a user" functionality on your code. Right now, we want to ban a user on NFT under SocialActions so we will use a "ban" method. we can check which method we should use by following the available examples related to the SocialActions, please have a look at the Example References documentation section, where all the available examples are given. You can copy those methods in your file and build your app.

def ban(token, user=None, nft=None, uuid=None, symbol=None, sequence=None, grab=None, text=None):
    """Ban a user from a message stream
    """

    # service class
    service = services.SocialClient(token)
    model = models.SocialActionModels()

    # parameters
    model.nft = nft # The NFT ID
    model.uuid = uuid # The NFT UUID
    model.symbol = symbol # The batch symbol
    model.sequence = sequence # The batch sequence
    model.grab = grab # The grab ID
    model.text = text # Optional text message
    user = user # The user ID

    # Service API calling
    response = service.ban(model, user)

Like banning a user from a message stream method we can also unban a user from a message stream by calling nft/unban API.

def unban(token, user=None, nft=None, uuid=None, symbol=None, sequence=None, grab=None, text=None):
    """Unban a user from a message stream
    """

    # service class
    service = services.SocialClient(token)
    model = models.SocialActionModels()

    # parameters
    model.nft = nft # The NFT ID
    model.uuid = uuid # The NFT UUID
    model.symbol = symbol # The batch symbol
    model.sequence = sequence # The batch sequence
    model.grab = grab # The grab ID
    model.text = text # Optional text message
    user = user # The user ID

    # Service API calling
    response = service.unban(model, user)

Step 3: Call your Defined method to ban a user on NFTs
From the above step, we have created a python file and defined a "ban" method to ban a user on NFT. Now we will call that method and pass the required parameter. We may have a look at the required parameter list by following this ban API endpoint.

# Define your token here
token = "token value"

# Call define method with values
unban(token, user, nft, uuid, symbol, sequence, grab, text)

We can also call the unban method and pass the required parameter to unban a user by following this unban API endpoint.

# Define your token here
token = "token value"

# Call define method with values
ban(token, user, nft, uuid, symbol, sequence, grab, text)

That's it, now, you can ban/unban a user from a message stream with ease using API and Python SDK.