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
Live URL | https://bc-api.qpyou.cn/core/v1/asset |
---|---|
Sandbox URL | https://sandbox-bc-api.qpyou.cn/core/v1/asset |
HTTP Method | POST |
Content-Type | application/json |
Header Parameters
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
1 2 3 4 5 6 |
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
1 2 3 4 5 6 7 8 9 |
{ "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
Live URL | https://bc-api.qpyou.cn/core/v1/asset-by-url |
---|---|
Sandbox URL | https://sandbox-bc-api.qpyou.cn/core/v1/asset-by-url |
HTTP Method | POST |
Content-Type | application/json |
Header Parameters
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
1 2 3 4 5 6 7 8 |
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
1 2 3 4 5 6 7 8 9 |
{ "code": 0, "message": "success", "data": { "contentType": "image/gif", "uri": "ipfs://QmV7GWnGgQU3szBBDQz1MmigtUjddmuAt7SjrWZeXP6cVF", "gatewayUrl": "https://sandbox-bc-file.qpyou.cn/ipfs/QmV7GWnGgQU3szBBDQz1MmigtUjddmuAt7SjrWZeXP6cVF" } } |
Get Asset Information
Gets the asset URL, open to public, via the content identifier (cid
).
Request URL
Live URL | https://bc-api.qpyou.cn/core/v1/asset/{cid} |
---|---|
Sandbox URL | https://sandbox-bc-api.qpyou.cn/core/v1/asset/{cid} |
HTTP Method | GET |
Content-Type | application/json |
Header Parameters
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
1 2 3 4 |
curl -X 'GET' \ 'https://sandbox-bc-api.qpyou.cn/core/v1/asset/QmV7GWnGgQU3szBBDQz1MmigtUjddmuAt7SjrWZeXP6cVF' \ -H 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJrZXlObyI6MSwiaWQiOiJwbGF0Zm9ybSIsImNvbXBhbnkiO' \ -H 'accept: application/json' |
Response Sample
1 2 3 4 5 6 7 |
{ "code": 0, "message": "success", "data": { "assetUri": "https://sandbox-bc-file.qpyou.cn/ipfs/QmV7GWnGgQU3szBBDQz1MmigtUjddmuAt7SjrWZeXP6cVF" } } |