Get NFT owner by token
If you’re interested in buying or selling an NFT from a specific owner, you can use Chainbase API Get NFT owner by token to get the current owner address of an NFT. What you need to prepare as an input is the contract address of the NFT collection and the token id of the NFT that you want to query with. With the owner information returned by Chainbase, you can contact them directly or make an offer through a marketplace platform.
Overview - Tools you need to work with Chainbase
- A free account at Chainbase with an API key.
- An IDE. Our examples are shown in JavaScript, you can use VS Code as your IDE for example.
- The contract address of a known NFT collection and the token id of that specific NFT as your input.
Step 1: Set up a free account at Chainbase
To better leverage the ability that Chainbase provides, you can register here for a free account and access to different APIs and data cloud.
After logging into Chainbase, visit the dashboard to get an overview. Create a new project in the console and get an API key.
Step 2: Write script using Chainbase API
- Using
fetch
in JavaScript.
- Using
axios
in JavaScript. You need to installaxios
usingnpm install axios --save
in the terminal first.
Step 3: Print the owner of the NFT
Chainbase API Get NFT owner by token takes the chain id, NFT contract address and NFT token id as parameters, and returns the owner address.
To get data printed, run command node <filename>.js
in the terminal. In this case, the address of 0xC8967D1537F7B995607A1DEa2B0C06E18A9756a2
is returned as the owner of the input NFT.
API Reference
If you want to know more details on the endpoint and optional parameters, check out:
Support
If you meet any trouble following the tutorial, feel free to reach out to us in our Discord to get 24/7 community support.