2.4.0 • Published 10 months ago

@zoralabs/zdk v2.4.0

Weekly downloads
429
License
GPL-3.0
Repository
github
Last release
10 months ago

ZDK 2.0

If you're looking for 1.0 branch use v1-archive

Getting started

yarn add @zoralabs/zdk
import { ZDK, ZDKChain, ZDKNetwork } from '@zoralabs/zdk';

// assuming you set API_ENDPOINT to https://api.zora.co/graphql
const API_ENDPOINT = process.env.API_ENDPOINT;

const zdk = new ZDK({
  endpoint: API_ENDPOINT,
  networks: [
    {
      chain: ZDKChain.Mainnet,
      network: ZDKNetwork.Ethereum,
    },
  ],
  apiKey: API_KEY // optional!
);

ZDK

ZDK Main Interface class

Kind: global class

Examples Here

zdk.tokens(where, filter, pagination, networks, sort, includeFullDetails, includeSalesDetails) ⇒

Gets data on a group of tokens based on query parameters.

Returns: Promise of response from tokens of type TokensQuery

ParamDescription
whereArguments to filter tokens by, required.
where.collectionAddressesList of collection addresses to filter by
where.ownerAddressesList of owner addresses to filter by
where.tokens:Tuple of token and id to filter by an exact match as a list
filterFilter query parameters after the where query
paginationSettings for pagination
networksNetworks to query on
sortSorting information for tokens
includeFullDetailsinclude entire token details (full uris, history etc.)
includeSalesDetailsinclude full token sale details for the last 10 sales

zdk.token(args) ⇒ Promise.<TokenQuery>

Gets data on a single NFT give a contract address and tokenId.

Returns: Promise.<TokenQuery> - Token graphql response

ParamTypeDescription
argsarguemnts for query object
args.tokenToken parameters
args.token.addressstringaddress of the token (req'd)
args.token.tokenIdstringstring ID of the token (req'd)
args.networkthe network to use to retrieve the token
args.network.chainChainChain to use (default ETHEREUM)
args.network.networkNetworkNetwork on the given chain to use (default MAINNET)
args.includeFullDetailsboolshould full details be added to the response

zdk.events(where, filter, pagination, networks, sort) ⇒

Gets all the events associated with a collection, token, or owner address e.g. Transfers, Mints, Sales, Approvals

Returns: Promise.<EventsQuery> - Events graphql response

ParamDescriptionType
whereArguments to filter tokens by, required.
where.collectionAddressesList of collection addresses to filter by
where.tokens:Tuple of token and id to filter by an exact match as a list
filterFilter query parameters after the where query
filter.bidderAddressesA string array of addresses that have bid on this NFT
filter.eventTypesAn array of EventTypes
filter.recipientAddressesA string array of addresses that have received this NFT
filter.sellerAddressesA string array of addresses that have sold this NFT
filter.senderAddressesA string array of addresses that have sent this NFT
filter.timeFilterAn input of type TimeFilter for time partitioned event responses.
paginationSettings for pagination
pagination.afterA string specifying which record to begin pagination
pagination.limitAn int setting the number of event records per page
networksNetwork info to query on as an array of enums
networks.chainChain to query on (currently only MAINNET)
networks.networkNetwork to query on (currently only ETHEREUM)
sortSorting information for tokens
sort.directionAn enum value specifying the direction of resultsASC, DESC
sort.sortKeyAn enum value specifying the value to sort results byChainTokenPrice, Created, NativePrice, None, TimeSaleEnding

zdk.markets(where, filter, pagination, networks, sort, includeFullDetails) ⇒

Gets NFTs that are active on the Zora markets e.g. Buy Now, Offers, Auctions

Returns: Promise.<MarketsQuery> - Markets graphql response

ParamDescriptionType
whereArguments to filter tokens by, required.
where.collectionAddressesList of collection addresses to filter by
where.tokens:Tuple of token and id to filter by an exact match as a list
filterFilter query parameters after the where query
filter.marketQueryFilterArguments for filtering market info expectations
marketQueryFilter.bidderAddressesA string array of addresses that have bid for this NFT
marketQueryFilter.marketTypeAn enum specifying the version of Zora the order is made onV1Ask, V1BidShare, V1Offer, V2Auction, V3Ask
marketQueryFilter.statusesAn enum specifying status of orders being returnedActive, Canceled, Completed
filter.priceFilterArguments for filtering price ranges
priceFilter.currencyAddressA string specifying the currency being used for the market transaction to be returned
priceFilter.maximumChainTokenPriceA string specifying the maximum price of the native chain token (ETH, MATIC, etc) to return
priceFilter.maximumNativePriceA string specifying the minimum price of the native chain token (ETH in our case) to return
priceFilter.minimumChainTokenPriceA string specifying the minimum price of the native chain token (ETH, MATIC, etc) to return
priceFilter.minimumNativePriceA string specifying the minimum price of the native chain token (ETH in our case) to return
sortSorting information for tokens
sort.sortDirectionAn enum value specifying the direction of resultsASC, DESC
sort.sortKeyAn enum value specifying the value to sort results byChainTokenPrice, Created, NativePrice, None, TimeSaleEnding
networksArgument for chain to query as an array of enums
networks.chainChain to query on (currently only MAINNET)
networks.networkNetwork to query on (currently only ETHEREUM)
includeFullDetailsinclude entire token details (full uris, history etc.)

zdk.mints(where, filter, pagination, networks, sort, includeFullDetails, includeMarkets) ⇒

Gets historic minting data for any NFT or any group of NFTs.

Returns: Promise.<MintsQuery> - Mints graphql response

ParamDescriptionType
whereArguments to filter tokens by, required.
where.collectionAddressesList of collection addresses to filter by
where.minterAddresses:List of minter addresses to filter by
where.recipientAddressesList of receiver addresses to filter by
where.tokens:Tuple of token and id to filter by an exact match as a list
filterFilter query parameters after the where query
filter.timeFilterAn input of type TimeFilter for time partitioned event responses.
timeFilter.endDateA date string specifying when to stop collecting mint data
timeFilter.lookbackHoursA string specifying how many hours to look back from an end date
timeFilter.startDateA date string specifying when to start collecting mint data
filter.priceFilterArguments for filtering price ranges
priceFilter.currencyAddressA string specifying the currency being used for the market transaction to be returned
priceFilter.maximumChainTokenPriceA string specifying the maximum price of the native chain token (ETH, MATIC, etc) to return
priceFilter.maximumNativePriceA string specifying the minimum price of the native chain token (ETH in our case) to return
priceFilter.minimumChainTokenPriceA string specifying the minimum price of the native chain token (ETH, MATIC, etc) to return
priceFilter.minimumNativePriceA string specifying the minimum price of the native chain token (ETH in our case) to return
paginationSettings for pagination
pagination.afterA string specifying which record to begin pagination
pagination.limitAn int setting the number of event records per page
sortSorting information for tokens
sort.sortDirectionAn enum value specifying the direction of resultsASC, DESC
sort.sortKeyAn enum value specifying the value to sort results byChainTokenPrice, Created, NativePrice, None, TimeSaleEnding
networksArgument for chain to query as an array of enums
networks.chainChain to query on (currently only MAINNET)
networks.networkNetwork to query on (currently only ETHEREUM)
includeFullDetailsinclude entire token details (full uris, history etc.)
includeMarketsinclude entire market details for these contracts

zdk.sales(where, filter, pagination, networks, sort, includeFullDetails) ⇒

Gets sales data for any NFT or collection across multiple marketplaces e.g. Zora, OpenSea, LooksRare, Foundation, etc.

Returns: Promise.<SalesQuery> - Sales graphql response

ParamDescriptionType
whereArguments to filter tokens by, required.
where.buyerAddresses:List of minter addresses to filter by
where.collectionAddressesList of collection addresses to filter by
where.sellerAddressesList of receiver addresses to filter by
where.tokens:Tuple of token and id to filter by an exact match as a list
filter.timeFilterAn input of type TimeFilter for time partitioned event responses.
timeFilter.endDateA date string specifying when to stop collecting mint data
timeFilter.lookbackHoursA string specifying how many hours to look back from an end date
timeFilter.startDateA date string specifying when to start collecting mint data
filter.priceFilterArguments for filtering price ranges
priceFilter.currencyAddressA string specifying the currency being used for the market transaction to be returned
priceFilter.maximumChainTokenPriceA string specifying the maximum price of the native chain token (ETH, MATIC, etc) to return
priceFilter.maximumNativePriceA string specifying the minimum price of the native chain token (ETH in our case) to return
priceFilter.minimumChainTokenPriceA string specifying the minimum price of the native chain token (ETH, MATIC, etc) to return
priceFilter.minimumNativePriceA string specifying the minimum price of the native chain token (ETH in our case) to return
sortSorting information for tokens
sort.sortDirectionAn enum value specifying the direction of resultsASC, DESC
sort.sortKeyAn enum value specifying the value to sort results byChainTokenPrice, Created, NativePrice, None, TimeSaleEnding
networksArgument for chain to query as an array of enums
networks.chainChain to query on (currently only MAINNET)
networks.networkNetwork to query on (currently only ETHEREUM)
includeFullDetailsinclude entire token details (full uris, history etc.)
includeMarketsinclude entire market details for these contracts

zdk.collections(where, pagination, networks, sort, includeFullDetails) ⇒

Gets data for a group of NFT collections.

Returns: Promise.<CollectionsQuery> - Collections graphql response

ParamDescriptionType
whereArguments to filter tokens by, required.
where.collectionAddressesList of collection addresses to filter by
paginationSettings for pagination
pagination.afterA string specifying which record to begin pagination
pagination.limitAn int setting the number of event records per page
networksArgument for chain to query as an array of enums
networks.chainChain to query on (currently only MAINNET)
networks.networkNetwork to query on (currently only ETHEREUM)
sortSorting information for tokens
sort.sortDirectionAn enum value specifying the direction of resultsASC, DESC
sort.sortKeyAn enum value specifying the value to sort results byChainTokenPrice, Created, NativePrice, None, TimeSaleEnding
includeFullDetailsinclude entire token details (full uris, history etc.)

zdk.collectionStatsAggregate(collectionAddress, network) ⇒

Gets statistics for a specific collection such as the total supply, number of owners and sales volume.

Returns: Promise.<CollectionStatsAggregateQuery> - Collection stats graphql response

ParamDescriptionType
collectionAddressesList of collection addresses to filter by
networkArgument for chain to query as an array of enums
network.chainChain to query on (currently only MAINNET)
network.networkNetwork to query on (currently only ETHEREUM)

zdk.collection(address, network) ⇒

Gets data for a specific NFT collection based on an address.

Returns: Promise.<CollectionQuery> - Collection graphql response

ParamDescriptionType
addressString of collection address to filter by
networkArgument for chain to query as an array of enums
network.chainChain to query on (currently only MAINNET)
network.networkNetwork to query on (currently only ETHEREUM)

zdk.ownersByCount(where, pagination, networks) ⇒

Gets the number of NFTs held be certain owner addresses e.g. Top holders of a collection.

Returns: Promise.<OwnersByCountQuery> - Owners by count graphql response

ParamDescriptionType
whereArguments to filter tokens by, required.
where.attributesAn array of the CollectionAttributes
attributes.traitTypeA string to set the trait type to return by
attributes.valueA string of a trait's possible value(s) to return by
where.collectionAddressesList of collection addresses to filter by
paginationSettings for pagination
pagination.afterA string specifying which record to begin pagination
pagination.limitAn int setting the number of event records per page
networksArgument for chain to query as an array of enums
network.chainsChain to query on (currently only MAINNET)
network.networksNetwork to query on (currently only ETHEREUM)

zdk.aggregateAttributes(where, networks) ⇒

Gets statistics on all the attributes for a collection.

Returns: Promise.<AggregateAttributesQuery> - Aggregate attributes graphql response

ParamDescriptionType
whereArguments to filter tokens by, required.
where.collectionAddressesList of collection addresses to filter by
where.ownerAddressesList of owner addresses to filter by
where.tokens:Tuple of token and id to filter by an exact match as a list
tokens.addressA string for the contract address to return a token for
tokens.tokenIdA string for the tokenId to return a token for
networksArgument for chain to query as an array of enums
network.chainChain to query on (currently only MAINNET)
network.networkNetwork to query on (currently only ETHEREUM)

zdk.salesVolume(where, networks, timeFilter) ⇒

Gets the total sales volume for a collection across all marketplaces.

Returns: Promise.<SalesVolumeQuery> - Sales volume graphql response

ParamDescriptionType
whereArguments to filter tokens by, required.
where.attributesAn array of the CollectionAttributes
attributes.traitTypeA string to set the trait type to return by
attributes.valueA string of a trait's possible value(s) to return by
where.collectionAddressesList of collection addresses to filter by
networksArgument for chain to query as an array of enums
network.chainsChain to query on (currently only MAINNET)
network.networksNetwork to query on (currently only ETHEREUM)
timeFilterNetwork to query on (currently only ETHEREUM)
timeFilter.endDateA string array of addresses that have bid for this NFT
timeFilter.lookbackHoursAn enum specifying the version of Zora the order is made onV1Ask, V1BidShare, V1Offer, V2Auction, V3Ask
timeFilter.startDateAn enum specifying status of orders being returnedActive, Canceled, Completed

zdk.ownerCount(where, networks) ⇒

Gets the number of NFTs held be certain owner addresses e.g. Top holders of a collection.

Returns: Promise.<OwnerCountQuery> - Owner count graphql response

ParamDescriptionType
whereArguments to filter tokens by, required.
where.attributesAn array of the CollectionAttributes
attributes.traitTypeA string to set the trait type to return by
attributes.valueA string of a trait's possible value(s) to return by
where.collectionAddressesList of collection addresses to filter by
networksArgument for chain to query as an array of enums
network.chainsChain to query on (currently only MAINNET)
network.networksNetwork to query on (currently only ETHEREUM)

zdk.floorPrice(where, networks) ⇒

Gets data on the cheapest available NFT across all Zora marketplaces.

Returns: Promise.<FloorPriceQuery> - Floor price graphql response

ParamDescriptionType
whereArguments to filter tokens by, required.
where.attributesAn array of the CollectionAttributes
attributes.traitTypeA string to set the trait type to return by
attributes.valueA string of a trait's possible value(s) to return by
where.collectionAddressesList of collection addresses to filter by
networksArgument for chain to query as an array of enums
network.chainsChain to query on (currently only MAINNET)
network.networksNetwork to query on (currently only ETHEREUM)

zdk.nftCount(where, networks) ⇒

Gets data on the total supply of NFTs in a collection.

Returns: Promise.<NftCountQuery> - NFT count graphql response

ParamDescriptionType
whereArguments to filter tokens by, required.
where.attributesAn array of the CollectionAttributes
attributes.traitTypeA string to set the trait type to return by
attributes.valueA string of a trait's possible value(s) to return by
where.collectionAddressesList of collection addresses to filter by
where.ownerAddressesList of owner addresses to filter by
networksArgument for chain to query as an array of enums
network.chainsChain to query on (currently only MAINNET)
network.networksNetwork to query on (currently only ETHEREUM)

zdk.search(pagination, query, filter) ⇒

Searchs for an NFT or collection based on a string input.

Returns: Promise.<SearchQuery> - Search query graphql response

ParamDescriptionType
paginationSettings for pagination
pagination.afterA string specifying which record to begin pagination
pagination.limitAn int setting the number of event records per page
queryA text string to query with
filterParameters for setting query filter
filter.collectionAddressesAn array of string addresses to query with
filter.entityTypeAn enum specifying the entity type being queriedCOLLECTION, TOKEN
2.3.0

10 months ago

2.4.0

10 months ago

2.2.1

1 year ago

2.1.2

2 years ago

2.2.0

2 years ago

2.1.1

2 years ago

2.1.4

2 years ago

2.1.3

2 years ago

2.1.6

2 years ago

2.1.5

2 years ago

2.1.8

2 years ago

2.1.7

2 years ago

2.1.0

2 years ago

2.0.1

2 years ago

2.0.0

2 years ago

2.1.9

2 years ago

1.2.6

3 years ago

1.2.5

3 years ago

1.2.4

3 years ago

1.2.3

3 years ago

1.2.2

3 years ago

1.2.0

3 years ago

1.1.1

3 years ago

1.1.0

3 years ago

1.2.1

3 years ago

1.0.8

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago

1.0.0-rc0

3 years ago

0.2.2

3 years ago

0.2.1

3 years ago

0.2.0

3 years ago

0.1.6

3 years ago

0.1.3

3 years ago

0.1.2

3 years ago

0.1.1

3 years ago

0.1.0

3 years ago