Kingdomly Docs
Search
K

Token Gate

(POST)
The Kingdomly Token Gate endpoint "https://www.kingdomly.app/api/kingdomlyTokenGate" allows developers to check the ownership of tokens stored in multiple collections on the Ethereum blockchain. The endpoint requires users to make a POST request with a payload that includes the collection addresses, wallet address, and the chain they want to check on.

Making a Request

The request body must contain three keys: body.collectionAddresses, body.walletAddress, and body.chain.
  1. 1.
    collectionAddresses: An array of the contract addresses of the collections you want to check for token ownership.
  2. 2.
    walletAddress: The wallet address of the user you want to check for token ownership.
  3. 3.
    chain: The blockchain you want to check on. Currently, the only supported chain is Ethereum, which is represented by "ETH".
Example of a request body:
{
"collectionAddresses": [
"0x123456789abcdef",
"0x9876543210fedcba"
],
"walletAddress": "0x1111111111111111",
"chain": "ETH"
}

Making the API Call

Once you have constructed the request body, you can make a POST request to the API to retrieve the ownership information of the tokens. You can use any HTTP client library or tool (such as curl, Postman, or the HTTP client in your programming language) to make the API request.
Example of a POST request using curl:
curl -X POST \
https://www.kingdomly.app/api/kingdomlyTokenGate \
-H 'Content-Type: application/json' \
-d '{
"collectionAddresses": [
"0x123456789abcdef",
"0x9876543210fedcba"
],
"walletAddress": "0x1111111111111111",
"chain": "ETH"
}'
Example of a POST request using JavaScript:
const options = {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
"collectionAddresses": [
"0x123456789abcdef",
"0x9876543210fedcba"
],
"walletAddress": "0x1111111111111111",
"chain": "ETH"
})
};
fetch('https://www.kingdomly.app/api/kingdomlyTokenGate', options)
.then(response => response.json())
.then(response => console.log(response))
.catch(err => console.error(err));

Parsing the Response

The API will respond with a JSON object that contains an array of objects. Each object in the array represents the pairing of a collection address and the token IDs that are owned by the wallet address. If the wallet is not the owner of any tokens from the inputted collections, the API will return an empty array.
Example response:
{
ownedNFTs: [
{
collectionAddress: '0x32BB5a147b5371Fd901Aa4a72B7F82c58A87e36d',
tokenId: '1362'
},
{
collectionAddress: '0x32BB5a147b5371Fd901Aa4a72B7F82c58A87e36d',
tokenId: '791'
},
{
collectionAddress: '0x32BB5a147b5371Fd901Aa4a72B7F82c58A87e36d',
tokenId: '293'
}
]
}