API Usage
Last updated
Was this helpful?
Last updated
Was this helpful?
Now we've set up the GraphQL client and authentication, let's explore the app and its use of the Niftory API surface to build these core capabilities:
User Profile: Get the Profile of the user (name, email, image, and etc). Performed via the . A deep dive on these queries is available in .
NFTs: Get all of NFTs that are available through your application, and all of the NFTs that belong to a user using the and queries respectively.
Wallets: for a new user, or query the user's wallet via the query.
With your GraphQL client set up, every request you make to the Niftory API service will automatically contain the logged-in user's authentication token, and your app's API key. This allows the API service to implicitly infer the context of the caller.
For example, to get the AppUser
object representing the currently logged-in user, you simply have to run the query, without any arguments!
Now for the fun part! Let's get some NFTs to display and transfer:
The sample app wraps all these queries in React Hooks; we'd recommend you to do the same to easily use these objects throughout your application.
We recommend wrapping your GraphQL queries in . For example, the above query can be part of a hook, so you can easily get the user context anywhere in your application.
Note that to actually create NFT content, use the -- the same place you got your API keys from. You can create your NFT collection there.
In order to display the NFT content available through your app, use the API. This query returns all the 's
that you have marked as Available in the Admin Portal.
Recall that an NFTModel is basically a blueprint for an NFT -- it contains all the content and metadata that would get minted. You can limit the supply of NFTs for an NFTModel by setting its quantity
appropriately (using the Admin Portal ).
While the query works without any arguments, you can optionally specify a (e.g. get only NFTs belonging to a particular )
Use the query to get NFT's
belonging to the currently logged-in user. Like the nftModels
query, you can also this query as needed (by particular NFTModel
's, for example).
To get the currently logged-in user's Wallet
simply call the query without any arguments:
The guide explains in detail how to setup a user's wallet, but the high level idea is this:
Call mutation to associate a Wallet address with an AppUser.
Call with a signed verification code (the verification code is returned by the registerWallet
mutation).
Finally, call to mark the Wallet as initialized for your application.