Alchemy
object returned by initializeAlchemy()
provides access to the Alchemy API. An optional config object can be passed in when initializing to set your API key, change the network, or specify the max number of retries.getNftsForOwner()
or getAssetTransfers()
. The current supported functions using this pattern are the Alchemy NFT API endpoints and Alchemy Enhanced APIs.Alchemy.getProvider()
function configures the Ethers.js AlchemyProvider and returns it. This allows you to perform core JSON-RPC calls with an Alchemy provider, just as you normally would with Ethers. If you are already using Ethers, you can simply use the provider from alchemy-sdk
and the rest of your code should just work:Alchemy.getWebsocketProvider()
function configures the Alchemy AlchemyWebSocketProvider and returns it. This can be used like the standard Ethers.js Websocket provider to add listeners for Alchemy events:alchemy-sdk
automatically handles these failures with no configuration necessary. The main benefits are:getNftMetadata()
: Gets the NFT metadata for a contract address and tokenId.getNftsForOwner()
: Get NFTs for an owner address.getNftsForOwnerIterator()
: Get NFTs for an owner address as an async iterator (handles paging automatically).getNftsForCollection()
: Gets all NFTs for a contract address.getNftForCollectionIterator()
: Gets all NFTs for a contract address as an async iterator (handles paging automatically).getOwnersForNft()
: Get all the owners for a given NFT contract address and token ID.checkNftOwnership()
: Checks that the provided owner address owns one or more of the provided NFT contract addresses.findContractDeployer()
: Finds the contract deployer and block number for a given NFT contract address.refreshNftMetadata()
: Refreshes the cached NFT metadata for a contract address and tokenId.BaseNft
and Nft
classes to represent NFTs returned by the Alchemy. The BaseNft
object does not hold any metadata information and only contains the NFT contract and token ID. The Nft
object additionally contains the NFT metadata, token URI information, and media.Nft
object. You can optionally choose to fetch the BaseNft
object instead by setting the omitMetadata
parameter to true
. The SDK documentation describes the different parameter and response interfaces in more detail.pageKey
returned by the previous call. To simplify paginating through all results, the SDK provides the getNftsIterator()
and getNftsForCollectionIterator()
functions that automatically paginate through all NFTs and yields them via an AsyncIterable
.getNftsForOwner()
is alchemy_getNfts
, getOwnersForNft()
is alchemy_getOwnersForToken
).omitMetadata
parameter (vs. withMetadata
).pageKey
parameter for pagination (vs. nextToken
/startToken
)TokenUri
fields are omitted.BaseNft
and Nft
.Nft
object.Nft
object are named differently than the REST response.tsdoc
comments in the source code. The generated types and documentation are included when using an IDE. To browse the documentation separately, you can view the generated API interfaces in the GitHub repository.