Subgraph Sample Request

Requesting data from the NFTX Subgraph.

The NFTX app is powered by a combination of Web3 calls for realtime data (token prices, connected wallet holdings etc) and calls to The Graph for the data that can't easily be requested from the blockchain.

Below are some common requests that you can make to the NFTX V2 subgraph to retrieve data about the vaults and their holdings.

NFTX V2 Subgraph Endpoint

You can make POST requests to the following endpoint.

https://gateway.thegraph.com/api/{api-key}/subgraphs/id/Epp6gJotEJKAsJYdk7bDEURtGWWeZVXwZds2Pgw8eG51

Global Fees

This request returns the global fees (default fees) that are applied to all vaults. The vaults have their own fees also applied to them so check what the usesFactoryFees is set to. If it is set to true then the global fees are used, if it is set to false then the fees defined on the vault are used.

{
  globals {
    fees {
      mintFee
      randomRedeemFee
      targetRedeemFee
      randomSwapFee
      targetSwapFee
    }
  }
}

Retrieve first 10 Published Vaults with Holdings

This request returns the first 10 vaults that have been finalised and have more than 0 NFTs in the holdings. To get all vaults change the first: 10 to first: 1000 .

{
  vaults(
    first: 10
    where: { vaultId_gte: 0, isFinalized: true, totalHoldings_gt: 0 }
  ) {
    vaultId
    token {
      id
      name
      symbol
    }
  }
}

Single Vault Details

If you want all the details for a single vault you can pass across the vaultId as an argument

{
  vaults(
    first: 1000
    where: { vaultId: 0 }
  ) {
    vaultId
    id
    is1155
    isFinalized
    totalHoldings
    totalMints
    totalRedeems
    totalFees
    totalSwaps
    createdAt
    holdings(first: 1000, orderBy: tokenId, orderDirection: asc) {
      id
      tokenId
      amount
      dateAdded
    }
    token {
      id
      name
      symbol
    }
    fees {
      mintFee
      randomRedeemFee
      targetRedeemFee
      randomSwapFee
      targetSwapFee
    }
    usesFactoryFees
    asset {
      id
      name
      symbol
    }
    manager {
      id
    }
    createdBy {
      id
    }
    eligibilityModule {
      id
      eligibleIds
      eligibleRange
    }
    features {
      enableMint
      enableRandomRedeem
      enableTargetRedeem
      enableRandomSwap
      enableTargetSwap
    }
    inventoryStakingPool {
      id
      dividendToken {
        symbol
      }
    }
    lpStakingPool {
      id
      stakingToken {
        id
      }
    }
  }
}

NFTX App Request

While there are a number of requests made to the subgraph to run the NFTX site the main request most integrations require is to retrieve all current vaults with the available NFTs available for purchase, and the facility to calculate the price.

This uses a combination of all the requests listed above.

{
  globals {
    fees {
      mintFee
      randomRedeemFee
      targetRedeemFee
      randomSwapFee
      targetSwapFee
    }
  }
  vaults(
    first: 1000
    where: { vaultId_gte: 0, isFinalized: true, totalHoldings_gt: 0 }
  ) {
    vaultId
    id
    is1155
    isFinalized
    totalHoldings
    totalMints
    totalRedeems
    totalFees
    totalSwaps
    createdAt
    holdings(first: 1000, orderBy: tokenId, orderDirection: asc) {
      id
      tokenId
      amount
      dateAdded
    }
    token {
      id
      name
      symbol
    }
    fees {
      mintFee
      randomRedeemFee
      targetRedeemFee
      randomSwapFee
      targetSwapFee
    }
    usesFactoryFees
    asset {
      id
      name
      symbol
    }
    manager {
      id
    }
    createdBy {
      id
    }
    eligibilityModule {
      id
      eligibleIds
      eligibleRange
    }
    features {
      enableMint
      enableRandomRedeem
      enableTargetRedeem
      enableRandomSwap
      enableTargetSwap
    }
    inventoryStakingPool {
      id
      dividendToken {
        symbol
      }
    }
    lpStakingPool {
      id
      stakingToken {
        id
      }
    }
  }
}

Last updated