Shyft
Start BuildingSupportWebsite
  • Welcome
    • ๐Ÿ‘‹Introducing Shyft
    • ๐Ÿ—๏ธStart Building
  • Solana Infrastructure
    • ๐ŸšShyft RPCs
  • Yellowstone gRPC Network
    • Decoding gRPC Latency
    • โšกgRPC Docs
      • Introduction
      • Authentication
      • Subscribe Requests
      • FAQ
      • Getting Started
        • Initializing the Yellowstone Client
        • Making a gRPC connection
        • Adding a Reconnection Mechanism
        • ๐Ÿ”ฅReplaying Slots with Solana yellowstone gRPCs
        • Modifying your Subscribe Request
        • Closing a gRPC Connection
      • Subscribing to Transactions
        • All Transactions of an address
        • Subscribing to all transactions of a Liquidity Pool
        • Subscribing to all transactions of multiple addresses
        • Subscribing to all transactions of a Token
      • Subscribing to Accounts
        • Account Updates for a Program
        • Account Updates for an Address
        • Account updates using memcmp
      • Streaming Blocks & BlocksMeta
        • Streaming Block Updates
        • Subscribing to BlocksMeta
      • Modifying & Unsubscribing
  • Solana defi data
    • DeFI APIs
      • Get Pool By Address
      • Get Pools By Token Pair
      • Get All Pools for a Token
      • Get Liquidity Details of a Pool
  • Callbacks
    • โ˜Ž๏ธWhat are Callbacks?
      • Transaction Callbacks
      • Account Callbacks
    • ๐Ÿ“”Callback APIs
      • Response Structure
      • List Callbacks
      • Register callback
      • Remove callback
      • ๐Ÿ”ฅPause a callback
      • ๐Ÿ”ฅResume a callback
      • Update Callbacks
      • Add Addresses
      • Remove addresses
  • Solana Super Indexers
    • ๐ŸŒฉ๏ธGraphQL APIs
      • Getting Started
      • Building Queries
      • Paginating Response
      • Applying Filters
      • Ordering and Sorting Data
    • ๐Ÿ“€Case Studies
      • Tensor
        • Get Active Listings of a Wallet
        • Get Active Bids of a Wallet
        • Get Active Listings of a Collection
        • Get all Bids of a Collection
        • Get all Pools of a Margin Account
        • Get all Pools by Owner
      • Raydium
        • Get Pool By Address
        • Get Pools By Token Address
        • Get Pools Created Between Time
        • Get Pool Burn Percentage
        • Get Liquidity Details of a Pool
        • Get Pool and OpenBook Market Info
        • Get Token Supply Percentage In Pool
      • Orca Whirlpool
        • Get Pool by Address
        • Get Pool by Token Address
        • Get Positions for a Pool
        • Get Positions for a Wallet
        • Get Liquidity Details of a Pool
      • Kamino
        • Get Borrow Details of a Wallet
        • Get Deposit Details of a Wallet
        • Get Reserve Details
      • Cross Marketplace Queries
        • Get active listings across marketplaces for a wallet
        • Get listings for a collection across marketplaces
        • Get floor price of a collection
      • Cross Defi Queries
        • Fetch Liquidity Pools for Token
      • Native Staking
        • Get Stakes for a Wallet
        • Get Stakes For Validator
      • Governance/Realms
        • Get DAO Token Owners
        • Get Proposals For Governing Mint
        • Get All Proposals For DAO
        • Get DAO Treasury Info
        • Get All Active Proposals For Wallet
      • Meteora
        • Get All LB Position Pairs
        • Get Position of a User Wallet
        • Get Pool by Token Addresses
        • Get All Deposits for a User
        • Get All Withdraws for a User
        • Get All Fees Claimed by a User
        • Get All User Positions and Deposits for a Pool
        • Get All User Positions and Withdrawals for a Pool
      • Fluxbeam
        • Get Pool by Address
        • Get Pool by Token Addresses
      • Drift
        • Get User account for Delegate
        • Get User accounts based on authority
        • Get User details based on Referrer
        • Get Borrow/Deposit Amount for an User
        • Get PrepPositions for an User Account
        • Getting OrderId and userOrderId
        • Get OpenOrders for a User Account
      • ๐Ÿ”ฅPumpswap
        • ๐Ÿ”ฅGet Pool by Address
        • ๐Ÿ”ฅGet Pool by Creator Address
        • ๐Ÿ”ฅGet Pools by Token Addresses
      • Raydium Launchpad
        • Get Bonding Curve Details by Pool Address
        • Get All Pools for a Creator
        • Get Pools by Token Addresses
        • Get Migration details of a Pool
  • Solana APIs
    • API Reference
    • Transactions
      • Parsed Transaction Structure
      • Transaction APIs
        • History
        • Parse Signature
        • Parse Multiple Signatures
        • Send
        • Send Multiple
    • NFT
      • ๐Ÿ”ฅCreate Gasless
      • Create
      • Read All
      • Burn
      • ๐Ÿ”ฅBurn Multiple NFTs V2
      • Update
      • ๐Ÿ”ฅCreate NFT from Metadata
      • ๐Ÿ”ฅRead Wallet Nfts
      • ๐Ÿ”ฅRead Selected NFTs
      • ๐Ÿ”ฅGet NFT Owners
      • ๐Ÿ”ฅUpdate NFT Metadata Uri
      • ๐Ÿ”ฅUpdate V2
      • Search
      • Transfer
      • Transfer Multiple NFTs
      • Mint
      • Read
    • Wallet
      • Get Balance
      • Get Token Balance
      • Get All Tokens Balance
      • Get Portfolio
      • Resolve Address
      • Get All Domains
      • Get Stake Accounts
    • Fungible Tokens
      • Create
      • Mint
      • Burn
      • ๐Ÿ”ฅUpdate
      • Get Token Info
      • Transfer
      • Airdrop
Powered by GitBook
On this page
  • Getting marketplace statistics
  • Getting the marketplaceโ€™s treasury balance
  • Withdraw money from the marketplace treasury
  • Getting a walletโ€™s purchase history
  • Resources

Was this helpful?

  1. Dev Guides
  2. Solana
  3. Build NFT Marketplace

Marketplace Stats, Treasury, and other tasks

Get marketplace stats, check and withdraw treasury balance.

Last updated 2 years ago

Was this helpful?

In our previous tutorials about SHYFT's Marketplace APIs, we have seen how we can create and set up a marketplace using custom tokens, Listing NFTs in a marketplace, buying NFTs from a marketplace, and getting active listings from a marketplace. However, SHYFT Marketplace APIs offer a lot more services for having more control and easier management of the marketplace. Let us explore a few of the services which SHYFT's Marketplace APIs have to offer.

This tutorial is a part of a series, please make sure you have gone through the previous parts here

Getting marketplace statistics

SHYFT provides an out-of-the-box stats API for fetching all the relevant marketplace statistics in one call. This removes the requirement of maintaining the marketplace statistics manually using a database, saves time and resources, and makes integration with the front end really easy.

The API endpoint for getting marketplace statistics

GET https://api.shyft.to/sol/v1/marketplace/stats?network=devnet&marketplace_address=54K5BTMj8ynktzEeaD1iGhAJsCN2svBKmD1fTQTonbBB&start_date=2022-09-02&end_date=2022-09-06

Details of the parameter used

Header

  1. x-api-key : The x-api-key is a parameter that is required to use SHYFT APIs. It is used by SHYFT for authorization purposes. You can get your x-api-key for free from the .

Parameters

  1. network (required parameter) : Selects the Solana blockchain network instance, which can be devnet,testnet or mainnet-beta.

  2. marketplace_address (required parameter) : Address of the marketplace whose detailed statistics we want to fetch. In our case, this will be the marketplace we created two tutorials back.

  3. start_date : This field accepts the date as an input in yyyy-mm-dd format. This acts as a filter for fetching all the statistics of a marketplace after a specified date. If empty, returns all the statistics since the day the marketplace was created.

  4. end_date : This field accepts the date as an input in yyyy-mm-dd format. This acts as a filter for fetching all the statistics of a marketplace up to a specified date. If empty, returns all the statistics up to a day before the current date.

start_date and end_date are both optional parameters and they can be used together to fetch statistics between the dates.

Response on successful execution:

{
  "success": true,
  "message": "Marketplace stats fetched successfully",
  "result": {
    "total_sales": 1, // total no. of NFTs sold 
    "sales_volume": 0.1, // total value worth of NFTs sold
    "total_sellers": 1, // no. of unique sellers in the marketplace
    "total_listings": 2, // no. of NFTs listed
    "listed_volume": 0.2 // total value worth of NFTs listed for sale
  }
}

Let's see what information we receive from SHYFT's stats API.

  1. total_sales : This field indicates the total number of NFTs sold in the marketplace.

  2. sales_volume : This field indicates the total amount (in marketplace currency) of sales that has taken place in the marketplace.

  3. total_sellers : This field indicates the number of unique sellers in the marketplace.

  4. total_listings : This field indicates the total number of NFTs listed in the marketplace.

  5. listed_volume : This field indicates the total value (in marketplace currency) of listed NFTs in the marketplace.

Getting the marketplaceโ€™s treasury balance

Whenever an NFT is sold from the marketplace, a small percentage of the cost of the NFT is added to the marketplace treasury. This percentage is set by the marketplace creator when the marketplace is created (by default it is 2%). Let's see how you can check the current marketplace treasury balance.

API for checking the marketplace treasury balance

GET https://api.shyft.to/sol/v1/marketplace/treasury_balance?network=devnet&marketplace_address=54K5BTMj8ynktzEeaD1iGhAJsCN2svBKmD1fTQTonbBB

Details of the parameters used:

  1. network : Selects the Solana blockchain network instance, which can be devnet,testnet or mainnet-beta.

  2. marketplace_address : Address of the marketplace whose treasury balance we are attempting to fetch.

Response:

{
    "success": true,
    "message": "treasury balance fetched successfully",
    "result": {
        "amount": 1.56,
        "symbol": "SOL"
    }
}

The result field should contain the amount which is the treasury_balance and the currency symbol for the marketplace. Now, let's see how we can withdraw this balance from the marketplace treasury.

Withdraw money from the marketplace treasury

API for withdrawing fees from the marketplace treasury:

POST https://api.shyft.to/sol/v1/marketplace/withdraw_fee

The Request Header

{
    "Content_Type": "application/json",
    "x-api-key": "YOUR SHYFT API KEY"
}

The Request Parameters (body)

{
  "network": "devnet",
  "marketplace_address": "5p4Bua5tSsSo1RJ94H1w5DiMSPfWcvMvnMVjPpZ6sJUb",
  "amount": 1,
  "authority_wallet": "Eb3ykuiCtvGcqs4XRCASThFf4EUxrL7k3TZsytWkXTBe"
}

Details of the parameters used:

  1. network : Selects the Solana blockchain network instance, which can be devnet,testnet or mainnet-beta.

  2. marketplace_address : Address of the marketplace from which we want to withdraw the treasury balance from.

  3. amount : The amount of treasury balance that we want to withdraw, this should not be greater than the available balance.

  4. authority_wallet : The wallet which has the authority to withdraw fees from the marketplace. This is set when the marketplace is created.

Here is a sample response from the API.

{
    "success": true,
    "message": "Fee withdrawal transaction created successfully",
    "result": {
        "from": "CRA4Qd6H4tisWLCENT7pzaRbURcKwZTToDnGHTezRxBG",
        "to": "EUUT8hfgak2YKcW41HoNWeiTuARv33fwRPn416enRxsR",
        "amount": 1,
        "encoded_transaction": "AQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAQIyeELoVlWCYLzz5fir3Nbcqf9Gx2d8RF9cFc+TSeDElFHfKaEpfrS4sxhTff+YHEOX/lQ1QNNWX1H25zIx6SthKmgvQV3nsD/OO7+XxS/J6DzL6yyUKOy+3PQUD+AOLz/yDGmfLg6xNhu9NDmNtXnhx0ZrxBqwdoCsUBaP+p1ChgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADNSe+qQqT3GAvPsRINdaFIq6fOJtX7xNNqyXom6lJf9CmWThjy6RhVk6uQTc3IVRusBUckwgna71K0qHDpCEHsG3fbh12Whk9nL4UbO63msHLSF7V9bN5E6jPWFfv8AqaMKy0fh8oHtamtDl4kF1O2PHC5CeU8uf1uHup73YnvsAQYHBQADAgEHBBAApFZMOEgMqgDKmjsAAAAA"
    }
}

Getting a walletโ€™s purchase history

Manually tracking and filtering the purchases of one particular buyer may be troublesome, especially when there is a large volume of marketplace data available. But don't worry, SHYFT has you covered. SHYFT provides its users with an API that can fetch the entire purchase history of one particular user in just one call.

API for fetching the purchase history of one particular user:

GET https://api.shyft.to/sol/v1/marketplace/buy_history?network=devnet&marketplace_address=5p4Bua5tSsSo1RJ94H1w5DiMSPfWcvMvnMVjPpZ6sJUb&buyer_address=AaYFExyZuMasdszjimKyQBAH1yfA9sKTxSzBc6Nr5X4s

The Request Header

{
    "Content_Type": "application/json",
    "x-api-key": "YOUR SHYFT API KEY"
}

Details of the Request Parameters

  1. network : Selects the Solana blockchain network instance, can be devnet,testnet or mainnet-beta.

  2. marketplace_address : Address of the marketplace from which they purchased the NFTs.

  3. buyer_address : Wallet Address of the buyer whose order history we are attempting to fetch.

Once successfully executed, the response will return a list containing details of all the transactions done by that particular user. Here is a sample response.

{
  "success": true,
  "message": "Order history fetched successfully",
  "result": [
    {
      "network": "devnet",
      "marketplace_address": "7b2dSy4F26A6WweKgdmXzyi5FhhN5AqhuXAQHYcaXfqW",
      "seller_address": "PEsSDkh5FsCDWeJfqLsKx7zC9ijkqKpCuYQxh8FYBiTJe",
      "price": 1,
      "nft_address": "DcxcgowdRg2bXasdadsaeppYY7GFquasdadwTVz3L",
      "buyer_address": "AaYFExyZuMasdszjimKyQBAH1yfA9sKTxSzBc6Nr5X4s",
      "created_at": "2022-08-17T04:36:16.094Z"
    },
    {
      "network": "devnet",
      "marketplace_address": "7b2dSy4F26A6WweKgdmXzyi5FhhN5AqhuXAQHYcaXfqW",
      "seller_address": "GE4kh5FsCDasdadx7zC9ijkqKpCuYQxh8FYBiTJe",
      "price": 1,
      "nft_address": "AfsdsaowdRg2basdadeppYY7GFquNhbZ5RwTVz3L",
      "buyer_address": "AaYFExyZuMasdszjimKyQBAH1yfA9sKTxSzBc6Nr5X4s",
      "created_at": "2022-08-15T02:31:16.096Z"
    }
  ]
}

Please note that all responses shown in this series are sample responses and not real data. Actual values may differ, but the field names will be the same.

Enjoyed this tutorial series? Feel free to check out our other tutorials on

Stay tuned for more such tutorials and series on SHYFT. Happy Hacking!

Resources

We have learned how we can view (or fetch) our marketplace treasury balance. Now letโ€™s see how we can withdraw money from our marketplace treasury. Please note that only the wallet which was set as the fee_recipient during has the authority to withdraw money from the marketplace treasury.

Once the request has been successfully executed, the response received should contain an encoded_transaction which needs to be signed using the usersโ€™ wallet, in this case, the authority_wallet. Find out how to sign transactions on Solana

These are some of the many operations you can do with SHYFT APIs. There are a lot more things you can do with SHYFT's Marketplace APIs, check out the full list of marketplace APIs over

So, thatโ€™s pretty much all about this series, feel free to check out our marketplace sample project which we have built using SHYFT APIs .

Join our .

If you liked this, you can also read our tutorials on or .

๐Ÿ“˜
Build Your First NFT Marketplace
List and buy NFTs in your marketplace
SHYFT Website
here.
here.
Build NFT Gated Dapp
Mint and reward users with edition NFTs
here
SHYFT API Documentation
Shyft Website
Get API Key
GitHub
Tool for Signing Transaction on Solana
Discord
How to get your user's token balances?
How to sign transactions on Solana
marketplace creation
Sample NFT Marketplace Built with SHYFT APIs