NFT API Quickstart

This quickstart shows how to make a first NFT API request over HTTPS using JSON-RPC 2.0.

Prerequisites

Before you start, make sure you have:

  • A W3api project with Advanced API access.
  • A project API key copied from the W3api platform.
  • A terminal with curl.

Keep your API key private. Do not commit it to source control or expose it in frontend code.


Set Your Endpoint

NFT API requests use the Advanced API multichain endpoint:

$https://rpc.ankr.com/multichain/<apiKey>

Replace <apiKey> with your project API key. In the examples below, store the full URL as YOUR_ADVANCED_API_ENDPOINT.


Make a Request with curl

Use ankr_getNFTsByOwner to request NFTs owned by a wallet address:

$curl -X POST YOUR_ADVANCED_API_ENDPOINT \
> -H "Content-Type: application/json" \
> -d '{
> "jsonrpc": "2.0",
> "method": "ankr_getNFTsByOwner",
> "params": {
> "blockchain": "eth",
> "walletAddress": "YOUR_WALLET_ADDRESS"
> },
> "id": 1
> }'

A successful response returns a JSON-RPC result object with NFT ownership data for the requested wallet:

1{
2 "jsonrpc": "2.0",
3 "id": 1,
4 "result": {
5 "owner": "YOUR_WALLET_ADDRESS",
6 "assets": [
7 {
8 "blockchain": "eth",
9 "contractAddress": "0x03a1e037df88001bf867e3bcffa7e48bab0cf5a6",
10 "contractType": "ERC721",
11 "collectionName": "Cool Oliens",
12 "name": "Cool Oliens #117",
13 "symbol": "COOLIEN",
14 "tokenId": "116",
15 "imageUrl": "https://ipfs.io/ipfs/QmTzuLQSn78keGt3n36b3tNNs7B3WMjo2SNJUF9rRshPjA/116.png"
16 }
17 ],
18 "nextPageToken": "NEXT_PAGE_TOKEN"
19 }
20}