@poprank/sdk
Version:
PopRank API client and types
109 lines (108 loc) • 5.29 kB
TypeScript
import { AxiosInstance, AxiosRequestConfig } from 'axios';
import { CollectionWithSeen, GetNftOptions, GetNftsOptions, Nft, Pair, RoundDir, RoundWithUrls, TraitOverview, UserLeaderboard } from './types';
/** The PopRank API client. */
export declare class PopRankClient {
client: AxiosInstance;
constructor(config?: AxiosRequestConfig);
/**
* Get all `Collection` objects. If `slug` is provided, then the collection
* is updated on the server, before the response is sent.
* @summary Get all collections.
* @param slug The collection identifier used in the PopRank collection page URL.
* If provided, the traits object is included in the response.
* @param player A player's wallet address .
*/
getCollections(slug?: string, player?: string): Promise<CollectionWithSeen[]>;
/**
* Get the `Collection` object that corresponds with the provided `slug`. The
* collection is updated on PopRank's server before response, so this method
* effectively doubles as a data refresh.
* @summary Get a collection.
* @param slug The collection identifier used in the PopRank collection page URL.
* * If provided, the traits object is included in the response.
*/
getCollection(slug: string): Promise<CollectionWithSeen>;
/**
* Get the specified collection's Overview tab data.
* @summary Get collection overview.
* @param slug The collection identifier used in the PopRank collection page URL.
*/
getCollectionOverview(slug: string): Promise<Record<string, TraitOverview[]>>;
/**
* Get the number of unique owners for `slug`.
* @summary Get number of unique owners.
* @param slug The collection identifier used in the PopRank collection page URL.
*/
getNumOwners(slug: string): Promise<number>;
/**
* Get ranking data for numerous assets.
* @summary Get a collection's NFTs.
* @param slug The collection identifier used in the PopRank collection page URL.
* @param options Optional object to paginate and filter response.
*/
getNfts(slug: string, options?: GetNftsOptions): Promise<Nft[]>;
/**
* Gets the ranking data for a single asset.
* @summary Get an NFT.
* @param slug The collection identifier used in the PopRank collection page URL.
* @param id The NFT's token ID.
* @param options Optional object to include more data in the response.
*/
getNft(slug: string, id: string, options?: GetNftOptions): Promise<Nft>;
/**
* Gets a random pair of NFTs to rank.
* @summary Get NFT pair.
* @param slug The collection identifier used in the PopRank collection page URL.
* @param player Although optional, required to validate the round.
*/
getNftPair(slug: string, player?: string): Promise<Pair>;
/**
* Get the total number of rounds played (valid and invalid).
* @summary Get global rounds.
*/
getGlobalRounds(): Promise<number | null>;
/**
* Get the number of rounds played by `player` for a specific collection, identified by `slug`.
* @summary Get collection rounds.
* @param slug The collection identifier used in the PopRank collection page URL.
* @param player The player's wallet address.
*/
getCollectionRounds(slug: string, player: string): Promise<number>;
/**
* Get up to last 5 rounds for an NFT.
* @summary Get NFT rounds.
* @param slug The collection identifier used in the PopRank collection page URL.
* @param id The NFT's token ID.
*/
getNftRounds(slug: string, id: string): Promise<RoundWithUrls[]>;
/**
* Send HTTP PUT request containing the round's `winner` and `loser`.
* @summary Send ranking game result.
* @param winner The winning NFT contestant
* @param loser The losing NFT contestant
* @param player The player's wallet address
* @param dir The direction selected by the player
*/
postRound(winner: Nft, loser: Nft, player?: string, dir?: RoundDir): Promise<void>;
/**
* Get the top global player leaderboard.
* @summary Get global player leaderboard.
* @param playerAddresses If not already in the top limit players, include the player at the end.
* @param limit Limits the number of players returned in the response. Must be between 1-200, inclusive. Defaults to 50.
*/
getGlobalPlayerLeaderboard(playerAddresses?: string, limit?: number): Promise<UserLeaderboard[]>;
/**
* Get the top player leaderboard for a collection.
* @summary Get collection player leaderboard.
* @param slug collection identifier used in the PopRank collection page URL.
* @param playerAddresses If not already in the top limit players, include the player at the end.
* @param limit Limits the number of players returned in the response. Must be between 1-200, inclusive. Defaults to 50.
*/
getCollectionPlayerLeaderboard(slug: string, playerAddresses?: string, limit?: number): Promise<UserLeaderboard[]>;
/**
* Get the Discord username of a Discord user with given `id`.
* @summary Get Discord username.
* @param id The Discord ID.
*/
getDiscordUsername(id: string): Promise<string>;
}