Search NFTs API
Search for NFTs using available filters through the `/v1/cl2c/nfts/search` endpoint.
The POST /v1/cl2c/nfts/search
endpoint allows you to search for NFTs using various filters and pagination options.
Endpoint
POST
/v1/cl2c/nfts/search
Search for NFTs based on specified criteria.
Parameters
Name | Type | Location | Required | Description |
---|---|---|---|---|
tenant | string | Header | Yes | Tenant ID for accessing this API. |
X-API-Key | string | Header | Yes | API Key ID for accessing this API. |
Request Body
Content Type: application/json
Example Request Body
{
"advancedSearch": {
"fields": [
"name",
"description"
],
"keyword": "art"
},
"keyword": "sample",
"advancedFilter": {
"logic": "AND",
"filters": [
"field1",
"field2"
],
"field": "status",
"operator": "equals",
"value": "active"
},
"pageNumber": 1,
"pageSize": 10,
"orderBy": [
"createdDate"
],
"smartContractId": "3fa85f64-5717-4562-b3fc-2c963f66afa6"
}
Responses
Success (200)
Content Type: application/json
The response includes a list of NFTs that match the search criteria along with pagination information.
Example Response
{
"data": [
{
"id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"name": "Art NFT",
"description": "A beautiful piece of art.",
"externalUrl": "https://example.com/nft/3fa85f64-5717-4562-b3fc-2c963f66afa6",
"imagePath": "https://example.com/image.png",
"smartContractId": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"smartContractName": "Art Smart Contract",
"minted": true,
"mintTransactionHash": "0xabc123...",
"mintLogs": "Mint logs here...",
"tokenId": 1,
"tokenUri": "https://example.com/token/1",
"tokenOwner": "0xownerAddress...",
"copyrighted": true,
"copyrightMetadata": "Copyright details here...",
"copyrightedAt": "2024-11-05T19:52:30.472Z",
"licence": "Standard License",
"signature": "Signature data here..."
}
],
"currentPage": 1,
"totalPages": 5,
"totalCount": 50,
"pageSize": 10,
"hasPreviousPage": true,
"hasNextPage": true
}
Error Responses
400 Bad Request
Content Type: application/json
Indicates that the request was invalid due to missing or incorrect parameters.
Example Response
{
"type": "string",
"title": "Invalid Request",
"status": 400,
"detail": "The search criteria provided is invalid.",
"instance": "https://api.example.com/v1/cl2c/nfts/search",
"errors": {
"keyword": [
"Keyword must be at least 3 characters long."
]
}
}
Default Error Response
Content Type: application/json
May include general error information.
Example Response
{
"messages": [
"An unexpected error occurred."
],
"source": "NFT Service",
"exception": "NullReferenceException",
"errorId": "error-5678",
"supportMessage": "Contact support for assistance.",
"statusCode": 500
}
Code Samples
Usage in Different Frameworks
Node.js Example
const axios = require('axios');
const requestBody = {
advancedSearch: {
fields: ['name', 'description'],
keyword: 'art'
},
keyword: 'sample',
advancedFilter: {
logic: 'AND',
filters: ['field1', 'field2'],
field: 'status',
operator: 'equals',
value: 'active'
},
pageNumber: 1,
pageSize: 10,
orderBy: ['createdDate'],
smartContractId: '3fa85f64-5717-4562-b3fc-2c963f66afa6'
};
axios.post('https://api.example.com/v1/cl2c/nfts/search', requestBody, {
headers: {
'tenant': 'your-tenant-id',
'X-API-Key': 'your-api-key'
}
})
.then(response => console.log(response.data))
.catch(error => console.error(error.response.data));