The Indexer Aptos Market SDK is a Typescript SDK which enables the ability to execute any Aptos NFT marketplace transaction across any marketplace. Each method in the SDK returns the payload you need to pass into aptosSignAndSendTransaction().

Getting Started

The Aptos Market SDK is built on top of the Indexer GraphQL API, so you’ll need an Indexer API Key and API User to use the SDK. You can explore the GraphQL API here: https://www.indexer.xyz/api-explorer

Getting Started with the Indexer GraphQL API

Initialize the Client

You need to pass in your API Key and API User to create an instance of the AptosMarketClient. The SDK uses these headers to fetch necessary data from our GraphQL API in order to create the payload for the transaction.

import { AptosMarketClient } from '@indexer-xyz/aptos'

const aptosMarketClient = new AptosMarketClient({
	apiKey: YOUR_API_KEY,
  apiUser: YOUR_API_USER
})

Calling Methods

const payload = await aptosMarketClient.buyListings({ 
	listingIds: ["5381c4a4-5c42-424e-a10e-80d24fc411c2"] 
})
await aptosSignAndSendTransaction(payload)

Note that the methods return a payload that you need to pass into the wallet signing method with whichever client library you are using. In this example, the aptosSignAndSendTransaction() method is coming from the useWallet() hook from @aptos-labs/wallet-adapter-react

The listing ids in the example above (and the nft ids and bid ids in future examples below) come from the Indexer GraphQL API.

Available Methods

buyListings()

const payload = await aptosMarketClient.buyListings({ 
	listingIds: [listing1.id, listing2.id] 
})
await aptosSignAndSendTransaction(payload)

Pass in one or multiple listing ids listing1.id and listing2.id are uuids from the GraphQL API listings entity Note that the listing could be on any Aptos marketplace.

listNfts()

List an NFT. If NFT is already listed, it will relist it.

const payload = await aptosMarketClient.listNfts({
  nfts: [
    {
      id: nft.id,
      listPrice: 10,
    },
  ],
})
await aptosSignAndSendTransaction(payload)

Pass in one or multiple nfts nft.id is a uuid from the GraphQL API nfts entity listPrice: The list price in APT