Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/audiusproject/fetch-nft
πΌππ A utility to fetch and easily display Ethereum & Solana NFTs in a common format given any wallet
https://github.com/audiusproject/fetch-nft
blockchain ethereum metaplex nft opensea solana web3
Last synced: about 3 hours ago
JSON representation
πΌππ A utility to fetch and easily display Ethereum & Solana NFTs in a common format given any wallet
- Host: GitHub
- URL: https://github.com/audiusproject/fetch-nft
- Owner: AudiusProject
- License: other
- Created: 2021-10-19T20:19:58.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2024-07-24T02:24:11.000Z (4 months ago)
- Last Synced: 2024-10-28T23:33:13.508Z (19 days ago)
- Topics: blockchain, ethereum, metaplex, nft, opensea, solana, web3
- Language: TypeScript
- Homepage: https://fetch-nft.audius.org
- Size: 579 KB
- Stars: 118
- Watchers: 12
- Forks: 39
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
@audius/fetch-nft
πΌππ
A utility to fetch and easily display Ethereum & Solana NFTs in a common format given any wallet.
built with β€οΈ from the team @Audius.
# Installation
```bash
# install peer dependencies if not already in your project
npm install @solana/spl-token @solana/web3.jsnpm install @audius/fetch-nft
```# Basic Usage
```ts
import { FetchNFTClient } from "@audius/fetch-nft";// Initialize fetch client
const fetchClient = new FetchNFTClient();// Fetching all collectibles for the given wallets
fetchClient
.getCollectibles({
ethWallets: ["0x5A8443f456f490dceeAD0922B0Cc89AFd598cec9"],
solWallets: ["GrWNH9qfwrvoCEoTm65hmnSh4z3CD96SfhtfQY6ZKUfY"],
})
.then((res) => console.log(res));
```By default, fetch-nft uses the public Opensea API and the Solana mainnet RPC endpoint. To configure API keys and endpoints, see [Usage With Configs](#usage-with-configs).
# Fetch Client
FetchNFTClient is the primary interface for using the library. When initializing the client, you may optionally pass in configs for the OpenSea and Helius clients used internally.
```ts
type OpenSeaConfig = {
apiEndpoint?: string;
apiKey?: string;
assetLimit?: number;
eventLimit?: number;
};type HeliusConfig = {
apiEndpoint?: string;
apiKey?: string;
limit?: number;
};type FetchNFTClientProps = {
openSeaConfig?: OpenSeaConfig;
heliusConfig?: HeliusConfig;
solanaConfig?: {
rpcEndpoint?: string;
metadataProgramId?: string;
};
};
```# Main Functions
Getting Ethereum collectibles:
```ts
FetchNFTClient::getEthereumCollectibles(wallets: string[]) => Promise
```Getting Solana collectibles:
```ts
FetchNFTClient::getSolanaCollectibles(wallets: string[]) => Promise
```Getting all collectibles:
```ts
FetchNFTClient::getCollectibles({
ethWallets?: string[],
solWallets?: string[]
}) => Promise<{
ethCollectibles: CollectibleState
solCollectibles: CollectibleState
}>
```# Output Types
### Collectible
```ts
type Collectible = {
id: string;
tokenId: string;
name: Nullable;
description: Nullable;
mediaType: CollectibleMediaType;
frameUrl: Nullable;
imageUrl: Nullable;
gifUrl: Nullable;
videoUrl: Nullable;
threeDUrl: Nullable;
animationUrl: Nullable;
hasAudio: boolean;
isOwned: boolean;
dateCreated: Nullable;
dateLastTransferred: Nullable;
externalLink: Nullable;
permaLink: Nullable;
chain: Chain;
wallet: string;
duration?: number;// ethereum nfts
assetContractAddress: Nullable;
standard: Nullable;
collectionSlug: Nullable;
collectionName: Nullable;
collectionImageUrl: Nullable;// solana nfts
solanaChainMetadata?: Nullable;
heliusCollection?: Nullable;
};
```### CollectibleState
```ts
type CollectibleState = {
[wallet: string]: Collectible[];
};
```# Usage with Configs
```ts
import { FetchNFTClient } from '@audius/fetch-nft'// OpenSea Config
const openSeaConfig = {
apiEndpoint: '...',
apiKey: '...',
assetLimit: 10,
eventLimit: 10
}// Helius Config
const heliusConfig = {
apiEndpoint: '...';
apiKey: '...',
limit: 10
}const solanaConfig = {
rpcEndpoint: '...',
metadataProgramId: '...'
};// Initialize fetch client with configs
const fetchClient = new FetchNFTClient({ openSeaConfig, heliusConfig, solanaConfig })// Fetching Ethereum collectibles for the given wallets
fetchClient.getEthereumCollectibles([...]).then(res => console.log(res))// Fetching Solana collectibles for the given wallets
fetchClient.getSolanaCollectibles([...]).then(res => console.log(res))
```For more examples, see the [/examples](/examples) directory