opensea-js
Advanced tools
Comparing version 7.1.7 to 7.1.8
@@ -1,2 +0,2 @@ | ||
import { BuildOfferResponse, ListNFTsResponse, GetNFTResponse, ListCollectionOffersResponse, GetOrdersResponse, GetBestOfferResponse, GetBestListingResponse, GetOffersResponse, GetListingsResponse, CollectionOffer } from "./types"; | ||
import { BuildOfferResponse, GetCollectionsResponse, ListNFTsResponse, GetNFTResponse, ListCollectionOffersResponse, GetOrdersResponse, GetBestOfferResponse, GetBestListingResponse, GetOffersResponse, GetListingsResponse, CollectionOffer, CollectionOrderByOption, CancelOrderResponse } from "./types"; | ||
import { FulfillmentDataResponse, OrderAPIOptions, OrdersQueryOptions, OrderV2, ProtocolData } from "../orders/types"; | ||
@@ -190,2 +190,13 @@ import { Chain, OpenSeaAPIConfig, OpenSeaAccount, OpenSeaCollection, OpenSeaCollectionStats, OpenSeaPaymentToken, OrderSide } from "../types"; | ||
/** | ||
* Fetch a list of OpenSea collections. | ||
* @param orderBy The order to return the collections in. Default: CREATED_DATE | ||
* @param chain The chain to filter the collections on. Default: all chains | ||
* @param creatorUsername The creator's OpenSea username to filter the collections on. | ||
* @param includeHidden If hidden collections should be returned. Default: false | ||
* @param limit The limit of collections to return. | ||
* @param next The cursor for the next page of results. This is returned from a previous request. | ||
* @returns List of {@link OpenSeaCollection} returned by the API. | ||
*/ | ||
getCollections(orderBy?: CollectionOrderByOption, chain?: Chain, creatorUsername?: string, includeHidden?: boolean, limit?: number, next?: string): Promise<GetCollectionsResponse>; | ||
/** | ||
* Fetch stats for an OpenSea collection. | ||
@@ -219,2 +230,12 @@ * @param slug The slug (identifier) of the collection. | ||
/** | ||
* Offchain cancel an order, offer or listing, by its order hash when protected by the SignedZone. | ||
* Protocol and Chain are required to prevent hash collisions. | ||
* Please note cancellation is only assured if a fulfillment signature was not vended prior to cancellation. | ||
* @param protocolAddress The Seaport address for the order. | ||
* @param orderHash The order hash, or external identifier, of the order. | ||
* @param chain The chain where the order is located. | ||
* @returns The response from the API. | ||
*/ | ||
offchainCancelOrder(protocolAddress: string, orderHash: string, chain?: Chain): Promise<CancelOrderResponse>; | ||
/** | ||
* Generic fetch method for any API endpoint | ||
@@ -221,0 +242,0 @@ * @param apiPath Path to URL endpoint under API |
@@ -6,5 +6,6 @@ "use strict"; | ||
const apiPaths_1 = require("./apiPaths"); | ||
const types_1 = require("./types"); | ||
const constants_1 = require("../constants"); | ||
const utils_1 = require("../orders/utils"); | ||
const types_1 = require("../types"); | ||
const types_2 = require("../types"); | ||
const utils_2 = require("../utils/utils"); | ||
@@ -34,3 +35,3 @@ function stall(duration) { | ||
this.apiKey = config.apiKey; | ||
this.chain = config.chain ?? types_1.Chain.Mainnet; | ||
this.chain = config.chain ?? types_2.Chain.Mainnet; | ||
if (config.apiBaseUrl) { | ||
@@ -177,3 +178,3 @@ this.apiBaseUrl = config.apiBaseUrl; | ||
let payload = null; | ||
if (side === types_1.OrderSide.ASK) { | ||
if (side === types_2.OrderSide.ASK) { | ||
payload = (0, utils_1.getFulfillListingPayload)(fulfillerAddress, orderHash, protocolAddress, this.chain); | ||
@@ -309,2 +310,26 @@ } | ||
/** | ||
* Fetch a list of OpenSea collections. | ||
* @param orderBy The order to return the collections in. Default: CREATED_DATE | ||
* @param chain The chain to filter the collections on. Default: all chains | ||
* @param creatorUsername The creator's OpenSea username to filter the collections on. | ||
* @param includeHidden If hidden collections should be returned. Default: false | ||
* @param limit The limit of collections to return. | ||
* @param next The cursor for the next page of results. This is returned from a previous request. | ||
* @returns List of {@link OpenSeaCollection} returned by the API. | ||
*/ | ||
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.get(path, args); | ||
response.collections = response.collections.map((collection) => (0, utils_2.collectionFromJSON)(collection)); | ||
return response; | ||
} | ||
/** | ||
* Fetch stats for an OpenSea collection. | ||
@@ -351,2 +376,15 @@ * @param slug The slug (identifier) of the collection. | ||
/** | ||
* Offchain cancel an order, offer or listing, by its order hash when protected by the SignedZone. | ||
* Protocol and Chain are required to prevent hash collisions. | ||
* Please note cancellation is only assured if a fulfillment signature was not vended prior to cancellation. | ||
* @param protocolAddress The Seaport address for the order. | ||
* @param orderHash The order hash, or external identifier, of the order. | ||
* @param chain The chain where the order is located. | ||
* @returns The response from the API. | ||
*/ | ||
async offchainCancelOrder(protocolAddress, orderHash, chain = this.chain) { | ||
const response = await this.post((0, apiPaths_1.getCancelOrderPath)(chain, protocolAddress, orderHash), {}); | ||
return response; | ||
} | ||
/** | ||
* Generic fetch method for any API endpoint | ||
@@ -353,0 +391,0 @@ * @param apiPath Path to URL endpoint under API |
@@ -10,2 +10,3 @@ import { OrderProtocol } from "../orders/types"; | ||
export declare const getCollectionPath: (slug: string) => string; | ||
export declare const getCollectionsPath: () => string; | ||
export declare const getCollectionStatsPath: (slug: string) => string; | ||
@@ -22,1 +23,2 @@ export declare const getPaymentTokenPath: (chain: Chain, address: string) => string; | ||
export declare const getRefreshMetadataPath: (chain: Chain, address: string, identifier: string) => string; | ||
export declare const getCancelOrderPath: (chain: Chain, protocolAddress: string, orderHash: string) => string; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getRefreshMetadataPath = exports.getNFTPath = exports.getListNFTsByAccountPath = exports.getListNFTsByContractPath = exports.getListNFTsByCollectionPath = exports.getCollectionOffersPath = exports.getPostCollectionOfferPath = exports.getBuildOfferPath = exports.getAccountPath = exports.getPaymentTokenPath = exports.getCollectionStatsPath = exports.getCollectionPath = exports.getBestListingsAPIPath = exports.getBestListingAPIPath = exports.getBestOfferAPIPath = exports.getAllListingsAPIPath = exports.getAllOffersAPIPath = exports.getOrdersAPIPath = void 0; | ||
exports.getCancelOrderPath = exports.getRefreshMetadataPath = exports.getNFTPath = exports.getListNFTsByAccountPath = exports.getListNFTsByContractPath = exports.getListNFTsByCollectionPath = exports.getCollectionOffersPath = exports.getPostCollectionOfferPath = exports.getBuildOfferPath = exports.getAccountPath = exports.getPaymentTokenPath = exports.getCollectionStatsPath = exports.getCollectionsPath = exports.getCollectionPath = exports.getBestListingsAPIPath = exports.getBestListingAPIPath = exports.getBestOfferAPIPath = exports.getAllListingsAPIPath = exports.getAllOffersAPIPath = exports.getOrdersAPIPath = void 0; | ||
const types_1 = require("../types"); | ||
@@ -34,2 +34,6 @@ const getOrdersAPIPath = (chain, protocol, side) => { | ||
exports.getCollectionPath = getCollectionPath; | ||
const getCollectionsPath = () => { | ||
return "/api/v2/collections"; | ||
}; | ||
exports.getCollectionsPath = getCollectionsPath; | ||
const getCollectionStatsPath = (slug) => { | ||
@@ -79,2 +83,6 @@ return `/api/v2/collections/${slug}/stats`; | ||
exports.getRefreshMetadataPath = getRefreshMetadataPath; | ||
const getCancelOrderPath = (chain, protocolAddress, orderHash) => { | ||
return `/v2/orders/chain/${chain}/protocol/${protocolAddress}/${orderHash}/cancel`; | ||
}; | ||
exports.getCancelOrderPath = getCancelOrderPath; | ||
//# sourceMappingURL=apiPaths.js.map |
@@ -46,2 +46,14 @@ import { ConsiderationItem } from "@opensea/seaport-js/lib/types"; | ||
/** | ||
* Query args for Get Collections | ||
* @category API Query Args | ||
*/ | ||
export interface GetCollectionsArgs { | ||
order_by?: string; | ||
limit?: number; | ||
next?: string; | ||
chain?: string; | ||
creator_username?: string; | ||
include_hidden?: boolean; | ||
} | ||
/** | ||
* Response from OpenSea API for fetching a single collection. | ||
@@ -55,2 +67,18 @@ * @category API Response Types | ||
/** | ||
* Response from OpenSea API for fetching a list of collections. | ||
* @category API Response Types | ||
*/ | ||
export type GetCollectionsResponse = QueryCursorsV2 & { | ||
/** List of collections. See {@link OpenSeaCollection} */ | ||
collections: OpenSeaCollection[]; | ||
}; | ||
export declare enum CollectionOrderByOption { | ||
CREATED_DATE = "created_date", | ||
ONE_DAY_CHANGE = "one_day_change", | ||
SEVEN_DAY_VOLUME = "seven_day_volume", | ||
SEVEN_DAY_CHANGE = "seven_day_change", | ||
NUM_OWNERS = "num_owners", | ||
MARKET_CAP = "market_cap" | ||
} | ||
/** | ||
* Base Order type shared between Listings and Offers. | ||
@@ -169,2 +197,9 @@ * @category API Models | ||
/** | ||
* Response from OpenSea API for offchain canceling an order. | ||
* @category API Response Types | ||
*/ | ||
export type CancelOrderResponse = { | ||
last_signature_issued_valid_until: string | null; | ||
}; | ||
/** | ||
* NFT type returned by OpenSea API. | ||
@@ -171,0 +206,0 @@ * @category API Models |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.TraitDisplayType = void 0; | ||
exports.TraitDisplayType = exports.CollectionOrderByOption = void 0; | ||
var CollectionOrderByOption; | ||
(function (CollectionOrderByOption) { | ||
CollectionOrderByOption["CREATED_DATE"] = "created_date"; | ||
CollectionOrderByOption["ONE_DAY_CHANGE"] = "one_day_change"; | ||
CollectionOrderByOption["SEVEN_DAY_VOLUME"] = "seven_day_volume"; | ||
CollectionOrderByOption["SEVEN_DAY_CHANGE"] = "seven_day_change"; | ||
CollectionOrderByOption["NUM_OWNERS"] = "num_owners"; | ||
CollectionOrderByOption["MARKET_CAP"] = "market_cap"; | ||
})(CollectionOrderByOption || (exports.CollectionOrderByOption = CollectionOrderByOption = {})); | ||
/** | ||
@@ -5,0 +14,0 @@ * Trait display type returned by OpenSea API. |
@@ -229,3 +229,3 @@ import { Seaport } from "@opensea/seaport-js"; | ||
/** | ||
* Cancel an order on-chain, preventing it from ever being fulfilled. | ||
* Cancel an order onchain, preventing it from ever being fulfilled. | ||
* @param options | ||
@@ -245,2 +245,12 @@ * @param options.order The order to cancel | ||
/** | ||
* Offchain cancel an order, offer or listing, by its order hash when protected by the SignedZone. | ||
* Protocol and Chain are required to prevent hash collisions. | ||
* Please note cancellation is only assured if a fulfillment signature was not vended prior to cancellation. | ||
* @param protocolAddress The Seaport address for the order. | ||
* @param orderJash The order hash, or external identifier, of the order. | ||
* @param chain The chain where the order is located. | ||
* @returns The response from the API. | ||
*/ | ||
offchainCancelOrder(protocolAddress: string, orderHash: string, chain?: Chain): Promise<import("./api/types").CancelOrderResponse>; | ||
/** | ||
* Returns whether an order is fulfillable. | ||
@@ -247,0 +257,0 @@ * An order may not be fulfillable if a target item's transfer function |
@@ -505,3 +505,3 @@ "use strict"; | ||
/** | ||
* Cancel an order on-chain, preventing it from ever being fulfilled. | ||
* Cancel an order onchain, preventing it from ever being fulfilled. | ||
* @param options | ||
@@ -530,2 +530,14 @@ * @param options.order The order to cancel | ||
/** | ||
* Offchain cancel an order, offer or listing, by its order hash when protected by the SignedZone. | ||
* Protocol and Chain are required to prevent hash collisions. | ||
* Please note cancellation is only assured if a fulfillment signature was not vended prior to cancellation. | ||
* @param protocolAddress The Seaport address for the order. | ||
* @param orderJash The order hash, or external identifier, of the order. | ||
* @param chain The chain where the order is located. | ||
* @returns The response from the API. | ||
*/ | ||
async offchainCancelOrder(protocolAddress, orderHash, chain = this.chain) { | ||
return this.api.offchainCancelOrder(protocolAddress, orderHash, chain); | ||
} | ||
/** | ||
* Returns whether an order is fulfillable. | ||
@@ -532,0 +544,0 @@ * An order may not be fulfillable if a target item's transfer function |
{ | ||
"name": "opensea-js", | ||
"version": "7.1.7", | ||
"version": "7.1.8", | ||
"description": "TypeScript SDK for the OpenSea marketplace helps developers build new experiences using NFTs and our marketplace data", | ||
@@ -46,3 +46,3 @@ "license": "MIT", | ||
"@typechain/ethers-v6": "^0.5.1", | ||
"@types/chai": "4.3.14", | ||
"@types/chai": "4.3.16", | ||
"@types/chai-as-promised": "^7.1.5", | ||
@@ -72,3 +72,3 @@ "@types/mocha": "^10.0.0", | ||
"typedoc": "^0.25.0", | ||
"typedoc-plugin-markdown": "^3.15.4", | ||
"typedoc-plugin-markdown": "^4.0.0", | ||
"typescript": "^5.1.3" | ||
@@ -75,0 +75,0 @@ }, |
import { ethers } from "ethers"; | ||
import { | ||
getCollectionPath, | ||
getCollectionsPath, | ||
getOrdersAPIPath, | ||
@@ -21,2 +22,3 @@ getPostCollectionOfferPath, | ||
getBestListingsAPIPath, | ||
getCancelOrderPath, | ||
} from "./apiPaths"; | ||
@@ -26,2 +28,3 @@ import { | ||
GetCollectionResponse, | ||
GetCollectionsResponse, | ||
ListNFTsResponse, | ||
@@ -36,2 +39,5 @@ GetNFTResponse, | ||
CollectionOffer, | ||
CollectionOrderByOption, | ||
CancelOrderResponse, | ||
GetCollectionsArgs, | ||
} from "./types"; | ||
@@ -539,2 +545,36 @@ import { API_BASE_MAINNET, API_BASE_TESTNET } from "../constants"; | ||
/** | ||
* Fetch a list of OpenSea collections. | ||
* @param orderBy The order to return the collections in. Default: CREATED_DATE | ||
* @param chain The chain to filter the collections on. Default: all chains | ||
* @param creatorUsername The creator's OpenSea username to filter the collections on. | ||
* @param includeHidden If hidden collections should be returned. Default: false | ||
* @param limit The limit of collections to return. | ||
* @param next The cursor for the next page of results. This is returned from a previous request. | ||
* @returns List of {@link OpenSeaCollection} returned by the API. | ||
*/ | ||
public async getCollections( | ||
orderBy: CollectionOrderByOption = CollectionOrderByOption.CREATED_DATE, | ||
chain?: Chain, | ||
creatorUsername?: string, | ||
includeHidden: boolean = false, | ||
limit?: number, | ||
next?: string, | ||
): Promise<GetCollectionsResponse> { | ||
const path = getCollectionsPath(); | ||
const args: GetCollectionsArgs = { | ||
order_by: orderBy, | ||
chain, | ||
creator_username: creatorUsername, | ||
include_hidden: includeHidden, | ||
limit, | ||
next, | ||
}; | ||
const response = await this.get<GetCollectionsResponse>(path, args); | ||
response.collections = response.collections.map((collection) => | ||
collectionFromJSON(collection), | ||
); | ||
return response; | ||
} | ||
/** | ||
* Fetch stats for an OpenSea collection. | ||
@@ -600,2 +640,23 @@ * @param slug The slug (identifier) of the collection. | ||
/** | ||
* Offchain cancel an order, offer or listing, by its order hash when protected by the SignedZone. | ||
* Protocol and Chain are required to prevent hash collisions. | ||
* Please note cancellation is only assured if a fulfillment signature was not vended prior to cancellation. | ||
* @param protocolAddress The Seaport address for the order. | ||
* @param orderHash The order hash, or external identifier, of the order. | ||
* @param chain The chain where the order is located. | ||
* @returns The response from the API. | ||
*/ | ||
public async offchainCancelOrder( | ||
protocolAddress: string, | ||
orderHash: string, | ||
chain: Chain = this.chain, | ||
): Promise<CancelOrderResponse> { | ||
const response = await this.post<CancelOrderResponse>( | ||
getCancelOrderPath(chain, protocolAddress, orderHash), | ||
{}, | ||
); | ||
return response; | ||
} | ||
/** | ||
* Generic fetch method for any API endpoint | ||
@@ -602,0 +663,0 @@ * @param apiPath Path to URL endpoint under API |
@@ -43,2 +43,6 @@ import { OrderProtocol } from "../orders/types"; | ||
export const getCollectionsPath = () => { | ||
return "/api/v2/collections"; | ||
}; | ||
export const getCollectionStatsPath = (slug: string) => { | ||
@@ -95,1 +99,9 @@ return `/api/v2/collections/${slug}/stats`; | ||
}; | ||
export const getCancelOrderPath = ( | ||
chain: Chain, | ||
protocolAddress: string, | ||
orderHash: string, | ||
) => { | ||
return `/v2/orders/chain/${chain}/protocol/${protocolAddress}/${orderHash}/cancel`; | ||
}; |
@@ -58,2 +58,15 @@ import { ConsiderationItem } from "@opensea/seaport-js/lib/types"; | ||
/** | ||
* Query args for Get Collections | ||
* @category API Query Args | ||
*/ | ||
export interface GetCollectionsArgs { | ||
order_by?: string; | ||
limit?: number; | ||
next?: string; | ||
chain?: string; | ||
creator_username?: string; | ||
include_hidden?: boolean; | ||
} | ||
/** | ||
* Response from OpenSea API for fetching a single collection. | ||
@@ -68,2 +81,20 @@ * @category API Response Types | ||
/** | ||
* Response from OpenSea API for fetching a list of collections. | ||
* @category API Response Types | ||
*/ | ||
export type GetCollectionsResponse = QueryCursorsV2 & { | ||
/** List of collections. See {@link OpenSeaCollection} */ | ||
collections: OpenSeaCollection[]; | ||
}; | ||
export enum CollectionOrderByOption { | ||
CREATED_DATE = "created_date", | ||
ONE_DAY_CHANGE = "one_day_change", | ||
SEVEN_DAY_VOLUME = "seven_day_volume", | ||
SEVEN_DAY_CHANGE = "seven_day_change", | ||
NUM_OWNERS = "num_owners", | ||
MARKET_CAP = "market_cap", | ||
} | ||
/** | ||
* Base Order type shared between Listings and Offers. | ||
@@ -196,2 +227,10 @@ * @category API Models | ||
/** | ||
* Response from OpenSea API for offchain canceling an order. | ||
* @category API Response Types | ||
*/ | ||
export type CancelOrderResponse = { | ||
last_signature_issued_valid_until: string | null; | ||
}; | ||
/** | ||
* NFT type returned by OpenSea API. | ||
@@ -198,0 +237,0 @@ * @category API Models |
@@ -880,3 +880,3 @@ import EventEmitter = require("events"); | ||
/** | ||
* Cancel an order on-chain, preventing it from ever being fulfilled. | ||
* Cancel an order onchain, preventing it from ever being fulfilled. | ||
* @param options | ||
@@ -921,2 +921,19 @@ * @param options.order The order to cancel | ||
/** | ||
* Offchain cancel an order, offer or listing, by its order hash when protected by the SignedZone. | ||
* Protocol and Chain are required to prevent hash collisions. | ||
* Please note cancellation is only assured if a fulfillment signature was not vended prior to cancellation. | ||
* @param protocolAddress The Seaport address for the order. | ||
* @param orderJash The order hash, or external identifier, of the order. | ||
* @param chain The chain where the order is located. | ||
* @returns The response from the API. | ||
*/ | ||
public async offchainCancelOrder( | ||
protocolAddress: string, | ||
orderHash: string, | ||
chain: Chain = this.chain, | ||
) { | ||
return this.api.offchainCancelOrder(protocolAddress, orderHash, chain); | ||
} | ||
/** | ||
* Returns whether an order is fulfillable. | ||
@@ -923,0 +940,0 @@ * An order may not be fulfillable if a target item's transfer function |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
500383
12417