Update NFT Information
NFT API
update NFT metadata
put https://api.dappportal.io/api/b2b-v1/nfts/{chain}/{contract_address}/{token_id}/metadata To ensure the security of your secret key, this API should be called from a secure server environment rather than directly than from webpage(FrontEnd).
Parameters
chain *required string (path)
chain name : "kairos", "kaia"
contract_address *required string (path)
contract address of NFT
token_id *required string (path)
token id of NFT
X-Auth-Signature *required string (header)
HMAC (clientId + method + path + timestamp + salt) key={secret} You can find the code example below.
X-Auth-ClientId *required string (header)
client id obtained from support team
X-Auth-Timestamp *required string (header)
Timestamp used in the X-Auth-Signature (request time) This parameter is included to protect against replay attacks.
X-Auth-Salt *required string (header)
Salt used in the X-Auth-Signature (a unique random value provided by the client for each request) (Length: 36 characters, UUID v4 format)
HMAC Signature Generation Example (Node.js)
Example code to generate X-Auth-Signature
header for secure API calls.
const crypto = require('crypto');
/**
* Generates an HMAC signature for API authentication.
* @param {string} secret - Shared secret key used for HMAC.
* @param {string} clientId - Public client identifier.
* @param {string} method - HTTP method (e.g., GET, POST).
* @param {string} path - Request path (e.g., /api/v1/resource).
* @param {string} timestamp - UNIX timestamp (in seconds).
* @param {string} salt - Random value (e.g., UUID or random bytes).
* @returns {string} - Base64-encoded HMAC signature.
*/
function generateHmacSignature(secret, clientId, method, path, timestamp, salt) {
const message = `${clientId}|${method.toUpperCase()}|${path}|${timestamp}|${salt}`;
const hmac = crypto.createHmac('sha256', secret);
hmac.update(message);
return hmac.digest('base64');
}
const secret = 'your-secret-key';
const clientId = 'client-abc-123';
const method = 'POST';
const path = '/api/v1/order';
const timestamp = Math.floor(Date.now() / 1000).toString();
const salt = crypto.randomUUID();
const signature = generateHmacSignature(secret, clientId, method, path, timestamp, salt);
// debug code
console.log('X-Client-Id:', clientId);
console.log('X-Timestamp:', timestamp);
console.log('X-Salt:', salt);
console.log('X-Auth-Signature:', signature);
Request Body
{
"name": "title1",
"image": "https://data.dappportal.io/nft/N6788dcf821089d16387aac02/e9856c3c-7a74-4545-b75b-2df5b49fd41f/image/1.png",
"cached_image": "https://obs.line-scdn.net:443/0h5TZGDWSkantnPnuVeJwVLD1rZAoLT3NuHgh4Axp7YBdUXHYsHiRMeh9sQg4BXltRECdTXBxsViABb0tsHSd9dkNfUkoWW0gsEjN6fhxtfxZKZUskEApubQRFaBFCcl0",
"description": "description1",
"attributes": [
{
"trait_type": "Color",
"value": "Green"
},
{
"trait_type": "Level",
"value": "5 level"
},
{
"trait_type": "Birthday",
"value": "2024.12.5"
}
]
}
{
name: string,
description: string,
image: string,
attributes: [Atribute {
trait_type: string,
value: string
}]
}
Responses
200
null
400
{
"code": "UNAUTHENTICATED"
}
400
{
"code": "INVALID_PARAMS"
}
400
{
"code": "NOT_MODIFIABLE_COLLECTION"
}
429
{
"code": "TOO_MANY_REQUESTS"
}
500
{
"code": "LOCK_ACQUISITION_FAILED"
}
500
{
"code": "UNKNOWN_ERROR"
}
Code Example (python)
import datetime
import hmac
import uuid
import base64
import json
import requests
secret_key = "your-secret-key"
client_id = "your-client-id"
method = "PUT"
chain = "kairos" //test chain
contract_address = "contract-address"
token_id = "1"
path = f"/api/b2b-v1/nfts/{chain}/{contract_address}/{token_id}/metadata"
timestamp = str(int(datetime.datetime.now().timestamp()))
salt = str(uuid.uuid4())
plain_text = f"{client_id}|{method.upper()}|{path}|{timestamp}|{salt}"
print(f"plain_text: {plain_text}")
# Generate HMAC SHA256 Signature
hmac_obj = hmac.new(secret_key.encode('utf-8'), plain_text.encode('utf-8'), digestmod='sha256')
signature = base64.b64encode(hmac_obj.digest()).decode('utf-8')
host="https://api-dapp-portal.line-apps-beta.com"
url = f"{host}{path}"
headers = {
"Content-Type": "application/json",
"X-Auth-Client-Id": client_id,
"X-Auth-Signature": f"{signature}",
"X-Auth-Timestamp": timestamp,
"X-Auth-Salt": f"{salt}",
}
body = {
"name": "Hello",
"uploadImageUrl": "https://line-objects-dev.com/dapp-portal-item/nft/N687e0c575d1ae92019138c5f/5734cbaa-5d49-4702-abaa-a3074808373f/image/9.jpg",
"attributes": [
{
"trait_type": "color",
"value": "red"
},
{
"trait_type": "level",
"value": "11 level"
}
],
}
print("=====[request]=====")
print(f"request_url: {url}")
print(f"request_header: {headers}")
print(f"request_body: {body}")
response = requests.put(url, headers=headers, data=json.dumps(body))
print(f"HTTP Status: {response.status_code}")
print(f"Response Body: {response.text}")
Request Timeout
Read Timeout: Must be at least 10 seconds
The server may take several seconds to respond depending on load and metadata processing time.
Please ensure your HTTP client is configured to wait at least 10 seconds for a response.
Last updated