2. Get Data

Overview

This guide provides information on how to obtain data from the Zecrey NFT Marketplace. In most cases, this data is about the current status of the NFT marketplace (i.e. asset ownership and asset status). Most forms of data available are read-only, so user authentication is not required to update the Zecrey NFT marketplace status. This section describes the method to directly call the SDK package.

Examples of obtained data types commonly include:

  • Detailed information on assets or a specific asset, including obtaining account information, categories, collections, your own NFTs, tradable offers, etc.

  • Information of a specific user in the NFT marketplace

Account

Get account details by account name

  • Get information on the account by accountName

📚SDK REFERENCE

Example

  • Get account information with the name "Alice"

package main

import (
   "fmt"
   "github.com/Zecrey-Labs/zecrey-marketplace-go-sdk/sdk"
)

func main() {
   accountName := "Alice"
   accountInfo, err := sdk.GetAccountByAccountName(accountName)
   if err != nil { panic(err) }
   
   data, _:= json.Marshal(accountInfo)
   fmt.Println(string(data))
}

Example result

{
  account:
    {
        "id":17,
        "account_index":14,
        "account_name":"Alice",    
        "bio":"name:Alice age:18 city:New York ",
        "email":"aliceaccountemail@gmail.com",
        "external_link":"https://alice.xyz",
        "twitter_link":"https://twitter.com/alice",
        "instagram_link":"https://www.instagram.com/alice/",
        "profile_image":"https://res.cloudinary.com/zecrey/image/upload/collection/ahykviwc0suhoyzusb5q.jpg",
        "profile_thumb":"https://res.cloudinary.com/zecrey/image/upload/collection/ioy2wcqupbgnuqvdtjfx.jpg",
        "banner_image":"https://res.cloudinary.com/zecrey/image/upload/collection/ljvwvjho9ucs5gpwmlkf.jpg",
        "banner_thumb":"https://res.cloudinary.com/zecrey/image/upload/collection/lo3vtlrcslcr1n7tgiuh.jpg",
        "created_at":1667835867
    }
}

Get assets by account name

  • Query the user's asset information

    Token

    Token ID

    BNB

    0

    LEG

    1

    REY

    2

Example

  • Get asset information with the name "Alice"

package main

import (
   "fmt"
   "github.com/Zecrey-Labs/zecrey-marketplace-go-sdk/sdk"
)


func main() {
   accountName := "Alice"
   result, err := sdk.GetAccountAssetsInfoByAccountName(accountName)
   if err != nil { panic(err) }
   
   data, _ := json.Marshal(accountInfo)
   fmt.Println(string(data))
}

Example result

[{"asset_id":0,"balance":"69516961736982000000","lp_amount":"1141481984833460000","offer_canceled_or_finalized":"170141183617213717799641663991588061916"},{"asset_id":1,"balance":"212085509760300000000","lp_amount":"412765957420000000","offer_canceled_or_finalized":"16438259186243607965933629081649153"},{"asset_id":2,"balance":"244530497503355100600","lp_amount":"5180165258600000000","offer_canceled_or_finalized":"0"}]

Get assets information

  • Query user asset information

  • Token information

    Token

    Token ID

    BNB

    0

    LEG

    1

    REY

    2

📚SDK REFERENCE

Example

  • Query token information

package main

import (
   "fmt"
   "github.com/Zecrey-Labs/zecrey-marketplace-go-sdk/sdk"
)


func main() {
   result, err := sdk.GetAssetsList()
   if err != nil { panic(err) }
   
   data, _ := json.Marshal(accountInfo)
   fmt.Println(string(data))
}

Example result

{"assets":[{"asset_id":0,"asset_name":"BNB","asset_decimals":18,"asset_symbol":"BNB","asset_address":"0x00","is_gas_asset":1},{"asset_id":1,"asset_name":"LEG","asset_decimals":18,"asset_symbol":"LEG","asset_address":"0x364Ed72f329f1BD56AE84b941D1c6E4E260cE152","is_gas_asset":0},{"asset_id":2,"asset_name":"REY","asset_decimals":18,"asset_symbol":"REY","asset_address":"0x9f4c0B11D9cAC63351fd002Cd09812138C6055cb","is_gas_asset":0}]}

Get account index

  • Query accountIndex

📚SDK REFERENCE

Example

  • Query the account index of the name "Alice"

package main

import (
   "fmt"
   "github.com/Zecrey-Labs/zecrey-marketplace-go-sdk/sdk"
)


func main() {
   accountName := "Alice"
   result, err := sdk.GetAccountIndex(accountName)
   if err != nil { panic(err) }
   
   data,_:= json.Marshal(result)    
   fmt.Println("accountIndex:",result.AccountIndex)
}

Example result

accountIndex: 4Example
- Query the account index of the name "Alice"
import { SDK } from "@zecrey/zecrey-legend-js-sdk";

const sdk = new SDK();
await sdk.initial();

const account_name = "Alice.zec";
const res = await sdk.getAccountIndex(account_name);

console.log("accountIndex:", res);
Example result
accountIndex: 4Example
- Query the account index of the name "Alice"
import { SDK } from "@zecrey/zecrey-legend-js-sdk";

const sdk = new SDK();
await sdk.initial();

const account_name = "Alice.zec";
const res = await sdk.getAccountIndex(account_name);

console.log("accountIndex:", res);
Example result
accountIndex: 4

Get account registration status

  • Query whether the accountName has been registered

📚SDK REFERENCE

Example

  • Query if the account name "Alice" is already registered

package main

import (
   "fmt"
   "github.com/Zecrey-Labs/zecrey-marketplace-go-sdk/sdk"
)


func main() {
   accountName := "Alice"
   result, err := sdk.IfAccountRegistered(accountName)
   if err != nil { panic(err) }
   
   data,_:= json.Marshal(result) 
   fmt.Println("GetAccountIsRegistered:",string(data))
}

Example result

GetAccountIsRegistered: true

Category

Get NFT categories

  • Get all NFT categories

📚SDK REFERENCE

Example

package main

import (
   "fmt"
   "github.com/Zecrey-Labs/zecrey-marketplace-go-sdk/sdk"
)

func main() {
   result, err := sdk.GetCategories()
   if err != nil { panic(err) }
   
   data,_:= json.Marshal(result)
   fmt.Println(string(data))
}

Example result

{
    "categories":[
        {
            "id":1,
            "name":"Art"
        },
        {
            "id":2,
            "name":"Collection"
        },
        {
            "id":3,
            "name":"domain name"
        },
        {
            "id":4,
            "name":"music"
        },
        {
            "id":5,
            "name":"photography"
        },
        {
            "id":6,
            "name":"physical education"
        },
        {
            "id":7,
            "name":"trading card"
        },
        {
            "id":8,
            "name":"Practical"
        },
        {
            "id":9,
            "name":"virtual reality"
        },
        {
            "id":10,
            "name":"default"
        }
    ]
}on

Collections

  • In the returned details about a collection, there will be a status attribute indicating its status (pending, created, expired, invalid, etc.).

  • The status of collections can be one of the following:

Status

CodeNumber

PENDING

0

CREATED

1

EXPIRED

2

INVALID

10

Get collections of an account by account index

  • Get the collections belonging to this account through accountIndex

  • The results returned include:

    • confirmedCollectionIdList: The collections that have been confirmed by Zecrey and exist in the form of an array id. And the details can be obtained through GetCollectionById.

    • pendingCollections: Collections under the pending status are waiting to be confirmed by Zecrey and cannot be used.

Example

  • Get collections created by the account name "Alice"

    • Query the accountIndex of Alice

    • Obtain the collections created by this account

package main

import (
   "fmt"
   "github.com/Zecrey-Labs/zecrey-marketplace-go-sdk/sdk"
)


func main() {
   accountName := "Alice"

   accountIndex,err:= sdk.GetAccountIndex(accountName)
   if err != nil { panic(err) }
   
   result, err := sdk.GetCollectionsByAccountIndex(accountIndex)
   if err != nil { panic(err) }
   
   data,_:= json.Marshal(result)
   fmt.Println(string(data))

}

Example result

{
    "sdkCollections":[
        {
            "id": 4,
            "l2_collection_id":4,
            "account_name":"Alice",
            "name":"Alice`s space 4",
            "short_name":"Alice`s space 4",
            "description":"AliceCollection4 description",
            "category_id":1,
            "collection_url":"https://res.cloudinary.com/zecrey/image/upload/collection/ahykviwc0suhoyzusb5q.jpg",
            "external_link":"https://alice.xyz",
            "twitter_link":"https://twitter.com/alice",
            "instagram_link":"https://www.instagram.com/alice/",
            "telegram_link":"https://tgstat.com/channel/@alice",
            "discord_link":"https://discord.com/api/v10/applications/<aliceid>/commands",
            "logo_image":"https://res.cloudinary.com/zecrey/image/upload/collection/lc02mjan85horu8650td",
            "logo_thumb":"https://res.cloudinary.com/zecrey/image/upload/collection/dekkg5j1ptccq9ttliui",
            "featured_image":"https://res.cloudinary.com/zecrey/image/upload/collection/ahykviwc0suhoyzusb5q",
            "featured_Thumb":"https://res.cloudinary.com/zecrey/image/upload/collection/ioy2wcqupbgnuqvdtjfx",
            "banner_image":"https://res.cloudinary.com/zecrey/image/upload/collection/ljvwvjho9ucs5gpwmlkf",
            "banner_thumb":"https://res.cloudinary.com/zecrey/image/upload/collection/lo3vtlrcslcr1n7tgiuh",
            "creator_earning_rate":1000,
            "status":"PENDING",
            "expired_at":1668083576082,
            "created_at":1667910776,
            "item_count":3,
            "browse_count":6,
            "floor_price":2,
            "one_day_trade_volume":8.7,
            "total_trade_volume":58.7
        }
    ]
}

Get collection details by ID

  • Get the collection information through collectionID

📚SDK REFERENCE

Example

  • Get the collection information withcollectionID =3

package main

import (
   "fmt"
   "github.com/Zecrey-Labs/zecrey-marketplace-go-sdk/sdk"
)


func main() { 
   var collectionId int64 = 3
   result, err := sdk.GetCollectionById(collectionId)
   data,_:= json.Marshal(result)
   fmt.Println(string(data))
}

Example result

{
    "id": 3,
    "l2_collection_id":3,
    "account_name":"Alice",
    "name":"Alice`s space 3",
    "short_name":"Alice`s space 3",
    "description":"AliceCollection3 description",
    "category_id":1,
    "collection_url":"https://res.cloudinary.com/zecrey/image/upload/collection/ljvwvjho9ucs5gpwmlkf.jpg",
    "external_link":"https://alice.xyz",
    "twitter_link":"https://twitter.com/alice",
    "instagram_link":"https://www.instagram.com/alice/",
    "telegram_link":"https://tgstat.com/channel/@alice",
    "discord_link":"https://discord.com/api/v10/applications/<aliceid>/commands",
    "logo_image":"https://res.cloudinary.com/zecrey/image/upload/collection/lc02mjan85horu8650td",
    "logo_thumb":"https://res.cloudinary.com/zecrey/image/upload/collection/dekkg5j1ptccq9ttliui",
    "featured_image":"https://res.cloudinary.com/zecrey/image/upload/collection/ahykviwc0suhoyzusb5q",
    "featured_Thumb":"https://res.cloudinary.com/zecrey/image/upload/collection/ioy2wcqupbgnuqvdtjfx",
    "banner_image":"https://res.cloudinary.com/zecrey/image/upload/collection/ljvwvjho9ucs5gpwmlkf",
    "banner_thumb":"https://res.cloudinary.com/zecrey/image/upload/collection/lo3vtlrcslcr1n7tgiuh",
    "creator_earning_rate":0,
    "status":"CREATED",
    "expired_at":1668083576082,
    "created_at":1667910776,
    "item_count":3,
    "browse_count":6,
    "floor_price":2,
    "one_day_trade_volume":8.7,
    "total_trade_volume":58.7
}

NFT

  • In the returned details about an NFT, there will be a status attribute indicating its status (pending, created, expired, invalid, etc.).

  • The NFT status can be one of the following:

    Status

    CodeNumber

    PENDING

    0

    CREATED

    1

    EXPIRED

    2

    INVALID

    10

Get NFTs of an account

  • Get the NFTs belonging to this account through the accountIndex or accountName

  • The results returned include:

    • ConfirmedAssetIdList: NFTs that have been confirmed by Zecrey and exist in the form of an array id. And the specific NFT information can be obtained through Get NFT by ID

    • PendingAssets: NFTs that are in pending status and waiting to be confirmed by Zecrey, which cannot be used for the following operations: transfer, withdraw, listOffer, makeOffer

📚SDK REFERENCE

Example

  • Get all the NFT information of one's own account

    • Get the accountIndex

    • Get the NFTs of the accountIndex

package main

import (
   "fmt"
   "github.com/Zecrey-Labs/zecrey-marketplace-go-sdk/sdk"
)


func main() {
   accountName := "Alice"
   
   accountIndex,err:=sdk.GetAccountIndex(accountName)//Get the accountIndex of one's own account
   if err != nil { panic(err) }
   
   result, err := sdk.GetAccountNFTs(accountIndex)//Get all the NFT information of one's own account
   if err != nil { panic(err) } 
   
    data,_:= json.Marshal(result)  
    fmt.Println(string(data))
}

Example result

{
    "sdkAssets":[
        {
            "id":9,
            "account_name":"lockkkxj",
            "nft_index":4,
            "collection_id":21,
            "creator_earning_rate":0,
            "name":"Pxzkkz01 #2",
            "description":"Description information",
            "media":"https://res.cloudinary.com/zecrey/image/upload/collection/czpvywx2piq42lauuous",
            "image_thumb":"https://res.cloudinary.com/zecrey/image/upload/collection/goqywrpyvzjuntaedgas",
            "video_thumb":"https://res.cloudinary.com/zecrey/image/upload/collection/dekkg5j1ptccq9ttliui",
            "audio_thumb":"https://res.cloudinary.com/zecrey/image/upload/collection/abf4wd7ults27bqxiciz",
            "status":"1",//already created
            "content_hash":"faabea2dac2f88a1a87938cdc518f64e2b05dbd5229ca618a9fd579010fff341",
            "nft_url":"https://res.cloudinary.com/zecrey/image/upload/collection/ljvwvjho9ucs5gpwmlkf.jpg",
            "expired_at":1667964122485,
            "created_at":1667877723,
             "properties":[
                 {
                     "name":"Animal",
                      "value":"Snow owl"
                 }
             ],
            "levels":[
                {
                    "name":"Power",
                    "value":10,
                    "maxValue":0
                }
            ],
            "stats":[
               {
                    "name":"blood",
                    "value":10,
                    "maxValue":2
                }

        ]
        }
    ]
}

Get NFT details by ID

  • Get the NFT information through NftId

📚SDK REFERENCE

Example

  • Get the NFT information with NftId = 14

package main

import (
   "fmt"
   "github.com/Zecrey-Labs/zecrey-marketplace-go-sdk/sdk"
)


func main() {
   var nftId int64 = 14
   result, err := sdk.GetNftById(nftId)
   if err != nil { panic(err) }
   
   data, _ := json.Marshal(result)
   fmt.Println(string(data))
}

Example result


{
    "asset":{
        "id":14,
        "account_name":"Alice",
        "nft_index":14,//nftIndez will be used to interact with l2
        "collection_id":3,
        "creator_earning_rate":0,
        "name":"Alice number 14 nft",
        "description":"it·s my number 14 nft",
        "media":"https://res.cloudinary.com/zecrey/image/upload/collection/czpvywx2piq42lauuous",
        "image_thumb":"https://res.cloudinary.com/zecrey/image/upload/collection/czpvywx2piq42lauuous",
        "video_thumb":"https://res.cloudinary.com/zecrey/image/upload/collection/vo6044kd4qjlgbbeqz0h",
        "audio_thumb":"https://res.cloudinary.com/zecrey/image/upload/collection/abf4wd7ults27bqxiciz",
        "status":"1",//already created
        "content_hash":"faabea2dac2f88a1a87938cdc518f64e2b05dbd5229ca618a9fd579010fff341",
        "nft_url":"https://res.cloudinary.com/zecrey/image/upload/collection/ahykviwc0suhoyzusb5q.jpg",
        "expired_at":1667964122485,
        "created_at":1667877723,
          "properties":[
            {
                "name":"Animal",
                "value":"Snow owl"
            }
        ],
        "levels":[
            {
                "name":"Power",
                "value":10,
                "maxValue":0
            }
        ],
        "stats":[
           {
                "name":"blood",
                "value":10,
                "maxValue":2
            }

        ]
    }
}

Offers

  • In the returned details about an offer, there will be a status attribute indicating its status (pending, created, expired, invalid, etc.).

  • The offer status can be one of the following:

Status

CodeNumber

Pending

0

Offer Created

1

matchOffer to be Verified on L2

2

matchOffer Verified on L2

3

Offer Canceled

4

Expired

6

Invalid

10

Get offers of an account

  • Get the offers of this account through accountIndex

📚SDK REFERENCE

Example

  • Get the offers of this account