# User NFTs

## How to get user NFTs?

* [ ] Use the [**Request User NFTs** action](#retrieving-user-owned-nfts) to get the number of runs
* [ ] Update your global variable with the response from the [**Get User NFTs** expression](#retrieving-user-owned-nfts)

## Retrieving user-owned NFTs

The **Request User NFTs** action fetches NFTs owned by the user from the NFT API. It makes an API request using optional query parameters provided in a JSON string format. The query parameters can be customized to refine the NFT search based on specific criteria (e.g., token IDs, and contract addresses).

If the request is successful, the retrieved NFT data is stored locally. Response structure:

Triggers the **On User NFTs Received** condition to indicate that the NFTs have been successfully fetched. If the request fails, an error message is logged, and an error handling routine is triggered. The retrieved NFTs can be accessed using the **Get User NFTs** expression, which returns the NFTs as a JSON string.

Example action param:

```
{ 
  'tokens': [ 
    { 
      'contractAddress': '0x3203c9e46ca618c8c1ce5dc67e7e9d75f5da2377', 
      'tokenId': 123 
    } 
  ], 
  
  'skipTokens': [ 
    { 
      'contractAddress': '0x3203c9e46ca618c8c1ce5dc67e7e9d75f5da2377', 
      'tokenId': 124 
    } 
  ], 
  
  'sort': { 
    'sortKey': 'token.creationBlock', 
    'sortDirection': 'desc' 
  }, 
  
  'collections': [ 
    { 
      'createdBy': '0x00', 
      'collectionName': 'MetaDudes' 
    } 
  ], 
  
  'tokenIds': [ 1, 2, 3 ], 
  
  'properties': [ 
    { 
      'name': 'Aqua Power', 
      'values': [ '40' ] 
    } 
  ] 
}
```

Example response:

<pre class="language-json"><code class="lang-json">{
  "results": [
    {
      "_id": "652868f14814e51de37a070e",
      "address": "0x9b71643136e10b22c89bb82b2f29c10bcecf31b11",
      "createdBy": "0x8b7c50d50c6a5af60292a6016ae960b8a47274",
      "contractAddress": "0x9b71643136e10b22c89bb82b2f29c10bcecf31b11",
      "standard": "erc1155",
      "protocol": "metaprotocol",
      "network": "polygon",
      "chainId": 80001,
      "creationBlock": 41138068,
      "version": 0,
      "isListed": false,
<strong>      "isAsset": false,
</strong>      "createdAt": "2023-10-12T21:45:21.341Z",
      "token": {
        "_id": "64878645267ef946a32d8e41",
        "_tokenId": 2,
        "address": "0x9b71643136e10b22c89bb82b2f29c10bcecf31b11",
        "_quantity": 3996,
        "burn": false,
        "createdAt": "2023-10-12T21:06:14.921Z",
        "createdBy": "0x8b7c50d50c6a5af60292a6016ae960b8a47274",
        "creationBlock": 36802650,
        "description": "AuctionTest",
        "textFiles": [],
        "favorites": 1,
        "image": "https://imageio.forbes.com/specials-images/imageserve/61700e18d763b9b95a7fee2b/Sotheby-s-NFT-Natively-Digital-1-2-sale-Bored-Ape-Yacht-Club--8817-by-Yuga-Labs/0x0.png?format=png&#x26;width=960",
        "initialOwner": "0x6cba743401e000eb29d17d6f3406ca0143e38203",
        "minifiedImage": "",
        "owner": "0x6cba743401e000eb29d17d6f3406ca0143e38203",
        "properties": {},
        "tokenName": "Folky nft",
        "transactionHash": "0x3e8995d768d2d9511844932165d9096122a5b3c820bb33dbf2f7c32f13fa",
        "updatedAt": "2023-10-12T21:06:14.921Z",
        "wishes": 0
      }
    }
  ],
  "count": 1
} // Example data
</code></pre>
