Specifications

tensortradepy.tensor.TensorClient

Setup

__init__(api_key, private_key=None, network='devnet')

The constructor sets up the client. It allows you to set your Tensor Trade API key, your wallet private key to perform operations and the Solana network where transactions are set.

Parameters:
  • api_key (str) –

    The Tensor Trade API authentication key.

  • private_key (str, default: None ) –

    Your wallet private key.

  • network (str, default: 'devnet' ) –

    The Solana network to use.

Collections

get_collection_infos(slug)

Retrieve the main information about a collection including buyNowPrice, sellNowPrice and the number of listed elements.

Parameters:
  • slug (str) –

    the collection slug (ID)

Returns:
  • dict

    ex: { "buyNowPrice": 10, "sellNowPrice": 10, "numListed": 100 }

get_collection_floor(slug)

Retrieve the lowest price of the item listed for the given collection.

Parameters:
  • slug (str) –

    the collection slug (ID)

Returns:
  • float

    The floor price (buyNow).

Listing

list_nft(mint, price, wallet_address=None)

List a NFT for sale.

Parameters:
  • mint (str) –

    The mint of the NFT.

  • price (float) –

    The price of the NFT.

  • wallet_address (str, default: None ) –

    The wallet address of the owner. If not specified, the private key of the Solana client will be used.

list_cnft(mint, price, wallet_address=None)

List a CNFT for sale.

Parameters:
  • mint (str) –

    The mint of the CNFT.

  • price (float) –

    The price of the CNFT.

  • wallet_address (str, default: None ) –

    The wallet address of the owner. If not specified, the private key of the Solana client will be used.

edit_nft_listing(mint, price, wallet_address=None)

Edit the price of a NFT listing.

Parameters:
  • mint (str) –

    The mint of the NFT.

  • price (float) –

    The price of the NFT.

  • wallet_address (str, default: None ) –

    The wallet address of the owner. If not specified, the private key of the Solana client will be used.

edit_cnft_listing(mint, price, wallet_address=None)

Edit the price of a CNFT listing.

Parameters:
  • mint (str) –

    The mint of the CNFT.

  • price (float) –

    The price of the CNFT.

  • wallet_address (str, default: None ) –

    The wallet address of the owner. If not specified, the private key of the Solana client will be used.

delist_nft(mint, wallet_address=None)

Delist a NFT.

Parameters:
  • mint (str) –

    The mint of the NFT.

  • wallet_address (str, default: None ) –

    The wallet address of the owner. If not specified, the private key of the Solana client will be used.

delist_cnft(mint, wallet_address=None)

Delist a CNFT.

Parameters:
  • mint (str) –

    The mint of the CNFT.

  • wallet_address (str, default: None ) –

    The wallet address of the owner. If not specified, the private key of the Solana client will be used.

Bidding

set_nft_collection_bid(slug, price, quantity, wallet_address=None)

Set a bid for a NFT collection.

Parameters:
  • slug (str) –

    The slug of the NFT collection.

  • price (float) –

    The price of the NFT bid.

  • quantity (float) –

    The quantity of NFTs to bid for.

set_cnft_collection_bid(slug, price, quantity, wallet_address=None)

Set a bid for a CNFT collection.

Parameters:
  • slug (str) –

    The slug of the CNFT collection.

  • price (float) –

    The price of the cNFT bid.

  • quantity (float) –

    The quantity of CNFTs to bid for.

  • wallet_address (str, default: None ) –

    The wallet address of the bidder. If not specified, the private key of the Solana client will be used.

edit_nft_collection_bid(bid_address, price, quantity)

Edit a bid for a NFT collection.

Parameters:
  • bid_address (str) –

    The address of the bid.

  • price (float) –

    The price of the NFT bid.

  • quantity (float) –

    The quantity of NFTs to bid for.

edit_cnft_collection_bid(bid_address, price, quantity)

Edit a bid for a CNFT collection.

Parameters:
  • bid_address (str) –

    The address of the bid.

  • price (float) –

    The price of the cNFT bid.

  • quantity (float) –

    The quantity of CNFTs to bid for.

cancel_nft_collection_bid(bid_address)

Cancel a bid for a NFT collection.

Parameters:
  • bid_address (str) –

    The address of the bid.

cancel_cnft_collection_bid(bid_address)

Cancel a bid for a CNFT collection.

Parameters:
  • bid_address (str) –

    The address of the bid.

Pools (AMMs, multi-listing, multi-bids)

create_pool(slug, starting_price, pool_type='TRADE', curve_type='LINEAR', delta=1.0, compound_fees=False, fee_bps=None, wallet_address=None)

pool_deposit_nft(pool, mint)

pool_withdraw_nft(pool, mint)

pool_deposit_sols(pool, amount)

pool_withdraw_sols(pool, amount)

close_pool(pool)

Buying

buy_cnft(seller, mint, price, wallet_address=None)

Buy a cNFT from the marketplace.

Parameters:
  • seller (str) –

    The address of the seller.

  • mint (str) –

    The mint of the cNFT.

  • price (float) –

    The price of the cNFT.

  • wallet_address (str, default: None ) –

    The address of the buyer. If not provided, the wallet address of the current keypair will be used.

buy_nft(seller, mint, price, wallet_address=None)

Buy a NFT from the marketplace.

Parameters:
  • seller (str) –

    The address of the seller.

  • mint (str) –

    The mint of the NFT.

  • price (float) –

    The price of the NFT.

  • wallet_address (str, default: None ) –

    The wallet address of the buyer. If not specified, the private key of the Solana client will be used.

tensortradepy.exceptions

Error Handling

WrongAPIKeyException

Bases: Exception

Raised if no working API key is provided (the Tensor server returns 403 errors)

NotListedException

Bases: Exception

Raised if the related NFT is not listed on Tensor Trade. It is raised even if the NFT is listed on another marketplace like Magic Eden.

TransactionFailedException

Bases: Exception

Raised when the Solana transaction fails to execute.