opensea-js
Version:
TypeScript SDK for the OpenSea marketplace helps developers build new experiences using NFTs and our marketplace data
57 lines • 1.95 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.CollectionsAPI = void 0;
const apiPaths_1 = require("./apiPaths");
const types_1 = require("./types");
const converters_1 = require("../utils/converters");
/**
* Collection-related API operations
*/
class CollectionsAPI {
constructor(fetcher) {
this.fetcher = fetcher;
}
/**
* Fetch an OpenSea collection.
*/
async getCollection(slug) {
const path = (0, apiPaths_1.getCollectionPath)(slug);
const response = await this.fetcher.get(path);
return (0, converters_1.collectionFromJSON)(response);
}
/**
* Fetch a list of OpenSea collections.
*/
async getCollections(orderBy = types_1.CollectionOrderByOption.CREATED_DATE, chain, creatorUsername, includeHidden = false, limit, next) {
const path = (0, apiPaths_1.getCollectionsPath)();
const args = {
order_by: orderBy,
chain,
creator_username: creatorUsername,
include_hidden: includeHidden,
limit,
next,
};
const response = await this.fetcher.get(path, args);
response.collections = response.collections.map((collection) => (0, converters_1.collectionFromJSON)(collection));
return response;
}
/**
* Fetch stats for an OpenSea collection.
*/
async getCollectionStats(slug) {
const path = (0, apiPaths_1.getCollectionStatsPath)(slug);
const response = await this.fetcher.get(path);
return response;
}
/**
* Fetch all traits for a collection with their possible values and counts.
*/
async getTraits(collectionSlug) {
const path = (0, apiPaths_1.getTraitsPath)(collectionSlug);
const response = await this.fetcher.get(path);
return response;
}
}
exports.CollectionsAPI = CollectionsAPI;
//# sourceMappingURL=collections.js.map