0.0.70 β€’ Published 1 year ago

@danny-jin/fetch-nft v0.0.70

Weekly downloads
-
License
ISC
Repository
-
Last release
1 year ago

Installation

# install peer dependencies if not already in your project
npm install @solana/spl-token @solana/web3.js

npm install @danny-jin/fetch-nft

Basic Usage

import { FetchNFTClient } from '@danny-jin/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.

Fetch Client

FetchNFTClient is the primary interface for using the library. When initializing the client, you may optionally pass in configs for the Open Sea and Solana clients used internally.

type OpenSeaClientProps = {
  apiEndpoint?: string
  apiKey?: string
  assetLimit?: number
  eventLimit?: number
}

type SolanaClientProps = {
  rpcEndpoint?: string
}

type FetchNFTClientProps = {
  openSeaConfig?: OpenSeaClientProps,
  solanaConfig?: SolanaClientProps
}

Main Functions

Getting Ethereum collectibles:

FetchNFTClient::getEthereumCollectibles(wallets: string[]) => Promise<CollectibleState>

Getting Solana collectibles:

FetchNFTClient::getSolanaCollectibles(wallets: string[]) => Promise<CollectibleState>

Getting all collectibles:

FetchNFTClient::getCollectibles({
  ethWallets?: string[],
  solWallets?: string[]
}) => Promise<{
  ethCollectibles: CollectibleState
  solCollectibles: CollectibleState
}>

Output Types

Collectible

type Collectible = {
  id: string
  tokenId: string
  name: string | null
  description: string | null
  mediaType: CollectibleMediaType
  frameUrl: string | null
  imageUrl: string | null
  gifUrl: string | null
  videoUrl: string | null
  threeDUrl: string | null
  isOwned: boolean
  dateCreated: string | null
  dateLastTransferred: string | null
  externalLink: string | null
  permaLink: string | null
  assetContractAddress: string | null
  chain: Chain
  wallet: string
}

CollectibleState

type CollectibleState = {
  [wallet: string]: Collectible[]
}

Usage with Configs

import { FetchNFTClient } from '@danny-jin/fetch-nft'

// Open Sea Config
const openSeaConfig = {
    apiEndpoint: '...',
    apiKey: '...',
    assetLimit: 50,
    eventLimit: 300
}

// Solana Config
const solanaConfig = {
    rpcEndpoint: '...'
}

// Initialize fetch client with configs
const fetchClient = new FetchNFTClient({ openSeaConfig, 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 directory

0.0.70

1 year ago

0.0.68

2 years ago

0.0.69

1 year ago

0.0.62

2 years ago

0.0.63

2 years ago

0.0.64

2 years ago

0.0.65

2 years ago

0.0.66

2 years ago

0.0.67

2 years ago

0.0.60

2 years ago

0.0.61

2 years ago

0.0.59

2 years ago

0.0.53

2 years ago

0.0.54

2 years ago

0.0.55

2 years ago

0.0.56

2 years ago

0.0.57

2 years ago

0.0.58

2 years ago

0.0.51

2 years ago

0.0.52

2 years ago

0.0.40

2 years ago

0.0.41

2 years ago

0.0.42

2 years ago

0.0.43

2 years ago

0.0.44

2 years ago

0.0.45

2 years ago

0.0.46

2 years ago

0.0.47

2 years ago

0.0.37

2 years ago

0.0.38

2 years ago

0.0.39

2 years ago

0.0.30

2 years ago

0.0.31

2 years ago

0.0.32

2 years ago

0.0.33

2 years ago

0.0.34

2 years ago

0.0.35

2 years ago

0.0.36

2 years ago

0.0.26

2 years ago

0.0.27

2 years ago

0.0.28

2 years ago

0.0.29

2 years ago

0.0.20

2 years ago

0.0.21

2 years ago

0.0.22

2 years ago

0.0.23

2 years ago

0.0.24

2 years ago

0.0.25

2 years ago

0.0.15

2 years ago

0.0.16

2 years ago

0.0.17

2 years ago

0.0.18

2 years ago

0.0.19

2 years ago

0.0.12

2 years ago

0.0.13

2 years ago

0.0.14

2 years ago

0.0.50

2 years ago

0.0.48

2 years ago

0.0.49

2 years ago

0.0.10

2 years ago

0.0.11

2 years ago

0.0.9

2 years ago

0.0.8

2 years ago

0.0.5

2 years ago

0.0.4

2 years ago

0.0.7

2 years ago

0.0.6

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago