Asset API offers registering and retrieving information about assets like media files.
Upload asset Uploads assets (the media files like jpg, png, gif, etc.) to the public IPFS (InterPlanetary File System). It offers the address (uri
) of the uploaded asset IPFS and the gateway address (gatewayUrl
) that can be accessed via HTTP.
Request URL Field Name Description Type Required Authorization Authentication token required to call the API string Y
Request body Field Name Description Type Required asset the binary information about the media file to be uploaded string Y
Responses Field Name Description Type code api request result code, 0: success number message the result message String data API response data json data.contentType the contents type string data.uri the IPFS address to which the asset was uploaded string data.gatewayUrl the gateway address where the asset can be found string
Request sample curl -X 'POST'
'https://sandbox-bc-api.qpyou.cn/core/v1/asset'
-H 'accept: application/json'
-H 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJrZXlObyI6MSwiaWQiOiJwbGF0Zm9ybSIsImNvbXBhbnkiO'
-H 'Content-Type: multipart/form-data'
-F 'asset=@cw20.code'
Response sample {
"code" : 0 ,
"message" : "success" ,
"data" : {
"contentType" : "application/octet-stream" ,
"uri" : "ipfs://QmPStJZ7o4kSQH2R64sRWq8YpJ9VgDb1QoHjAmyhCmekTi" ,
"gatewayUrl" : "https://sandbox-bc-file.qpyou.cn/ipfs/QmPStJZ7o4kSQH2R64sRWq8YpJ9VgDb1QoHjAmyhCmekTi"
}
}
Upload asset with public URL Uploads assets (the media files like jpg, png, gif, etc.) to the public IPFS. Instead of uploading the files directly, upload them via the public URL. It offers the address (uri
) of the uploaded asset IPFS and the gateway address (gatewayUrl
) that can be accessed via HTTP.
Request URL Field Name Description Type Required Authorization Authentication token required to call the API string Y
Request body Field Name Description Type Required url the public URL to which the asset will be uploaded string Y
Responses Field Name Description Type code api request result code, 0: success number message the result message String data API response data json data.contentType the contents type string data.uri the IPFS address to which the asset was uploaded string data.gatewayUrl the gateway address where the asset can be found string
Request sample curl -X 'POST'
'https://sandbox-bc-api.qpyou.cn/core/v1/asset-by-url'
-H 'accept: application/json'
-H 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJrZXlObyI6MSwiaWQiOiJwbGF0Zm9ybSIsImNvbXBhbnkiO'
-H 'Content-Type: application/json'
-d '{
"url": "https://image01.c2x.world/equip_92053030.gif"
}'
Response sample {
"code" : 0 ,
"message" : "success" ,
"data" : {
"contentType" : "image/gif" ,
"uri" : "ipfs://QmV7GWnGgQU3szBBDQz1MmigtUjddmuAt7SjrWZeXP6cVF" ,
"gatewayUrl" : "https://sandbox-bc-file.qpyou.cn/ipfs/QmV7GWnGgQU3szBBDQz1MmigtUjddmuAt7SjrWZeXP6cVF"
}
}
Gets the asset URL, open to public, via the content identifier (cid
).
Request URL Field Name Description Type Required Authorization Authentication token required to call the API string Y
Path parameters Field Name Description Type Required cid This is the IPFS contents identifier. This is the hash value that is used to identifies the data in IPFS, and it can be found in uri
(ipfs://{CID} ) or gatewayUrl
(https://{GATEWAY_URL}/ipfs/{CID} ). string Y
Responses Field Name Description Type code api request result code, 0: success number message the result message String data API response data json data.assetUri the gateway address where the asset can be found string
Request sample curl -X 'GET'
'https://sandbox-bc-api.qpyou.cn/core/v1/asset/QmV7GWnGgQU3szBBDQz1MmigtUjddmuAt7SjrWZeXP6cVF'
-H 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJrZXlObyI6MSwiaWQiOiJwbGF0Zm9ybSIsImNvbXBhbnkiO'
-H 'accept: application/json'
Response sample {
"code" : 0 ,
"message" : "success" ,
"data" : {
"assetUri" : "https://sandbox-bc-file.qpyou.cn/ipfs/QmV7GWnGgQU3szBBDQz1MmigtUjddmuAt7SjrWZeXP6cVF"
}
}