opensea-js 6.1.5 → 6.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/api/api.d.ts CHANGED
@@ -1,14 +1,18 @@
1
1
  import { ethers } from "ethers";
2
- import { BuildOfferResponse, Offer, ListNFTsResponse, GetNFTResponse, ListCollectionOffersResponse } from "./types";
3
- import { FulfillmentDataResponse, OrderAPIOptions, OrderSide, OrdersQueryOptions, OrderV2, ProtocolData, QueryCursors } from "../orders/types";
4
- import { Chain, OpenSeaAPIConfig, OpenSeaAsset, OpenSeaAssetBundle, OpenSeaAssetBundleQuery, OpenSeaAssetQuery, OpenSeaCollection, OpenSeaFungibleToken, OpenSeaFungibleTokenQuery } from "../types";
2
+ import { BuildOfferResponse, Offer, ListNFTsResponse, GetNFTResponse, ListCollectionOffersResponse, GetAssetsResponse, GetOrdersResponse, GetPaymentTokensResponse, GetBundlesResponse } from "./types";
3
+ import { FulfillmentDataResponse, OrderAPIOptions, OrderSide, OrdersQueryOptions, OrderV2, ProtocolData } from "../orders/types";
4
+ import { Chain, OpenSeaAPIConfig, OpenSeaAsset, OpenSeaAssetBundle, OpenSeaAssetBundleQuery, OpenSeaAssetQuery, OpenSeaCollection, OpenSeaFungibleTokenQuery } from "../types";
5
+ /**
6
+ * The API class for the OpenSea SDK.
7
+ * @category Main Classes
8
+ */
5
9
  export declare class OpenSeaAPI {
6
10
  /**
7
11
  * Base url for the API
8
12
  */
9
13
  readonly apiBaseUrl: string;
10
14
  /**
11
- * Page size to use for fetching orders
15
+ * Default size to use for fetching orders
12
16
  */
13
17
  pageSize: number;
14
18
  /**
@@ -25,150 +29,197 @@ export declare class OpenSeaAPI {
25
29
  */
26
30
  constructor(config: OpenSeaAPIConfig, logger?: (arg: string) => void);
27
31
  /**
28
- * Gets an order from API based on query options. Throws when no order is found.
32
+ * Gets an order from API based on query options.
33
+ * @param options
34
+ * @param options.side The side of the order (buy or sell
35
+ * @param options.protocol The protocol, typically seaport, to query orders for
36
+ * @param options.orderDirection The direction to sort the orders
37
+ * @param options.orderBy The field to sort the orders by
38
+ * @param options.limit The number of orders to retrieve
39
+ * @param options.makerAddress Fitler by the wallet addres of the order maker
40
+ * @param options.takerAddress Filter by wallet address of the order taker
41
+ * @param options.asset_contract_address Address of the NFT's contract
42
+ * @param options.token_ids String array of token IDs to filter by.
43
+ * @param options.listed_after Filter by orders listed after the Unix epoch timestamp in seconds
44
+ * @param options.listed_before Filter by orders listed before the Unix epoch timestamp in seconds
45
+ * @returns The first {@link OrderV2} returned by the API
46
+ *
47
+ * @throws An error if there are no matching orders.
29
48
  */
30
49
  getOrder({ side, protocol, orderDirection, orderBy, ...restOptions }: Omit<OrdersQueryOptions, "limit">): Promise<OrderV2>;
31
50
  /**
32
- * Gets a list of orders from API based on query options and returns orders
33
- * with next and previous cursors.
34
- */
35
- getOrders({ side, protocol, orderDirection, orderBy, ...restOptions }: Omit<OrdersQueryOptions, "limit">): Promise<QueryCursors & {
36
- orders: OrderV2[];
37
- }>;
38
- /**
39
- * Generate the data needed to fulfill a listing or an offer
51
+ * Gets a list of orders from API based on query options.
52
+ * @param options
53
+ * @param options.side The side of the order (buy or sell)
54
+ * @param options.protocol The protocol, typically seaport, to query orders for
55
+ * @param options.orderDirection The direction to sort the orders
56
+ * @param options.orderBy The field to sort the orders by
57
+ * @param options.limit The number of orders to retrieve
58
+ * @param options.makerAddress Fitler by the wallet addres of the order maker
59
+ * @param options.takerAddress Filter by wallet address of the order taker
60
+ * @param options.asset_contract_address Address of the NFT's contract
61
+ * @param options.token_ids String array of token IDs to filter by.
62
+ * @param options.listed_after Filter by orders listed after the Unix epoch timestamp in seconds
63
+ * @param options.listed_before Filter by orders listed before the Unix epoch timestamp in seconds
64
+ * @returns The {@link GetOrdersResponse} returned by the API.
65
+ */
66
+ getOrders({ side, protocol, orderDirection, orderBy, ...restOptions }: Omit<OrdersQueryOptions, "limit">): Promise<GetOrdersResponse>;
67
+ /**
68
+ * Generate the data needed to fulfill a listing or an offer onchain.
69
+ * @param fulfillerAddress The wallet address which will be used to fulfill the order
70
+ * @param orderHash The hash of the order to fulfill
71
+ * @param protocolAddress The address of the seaport contract
72
+ * @side The side of the order (buy or sell)
73
+ * @returns The {@link FulfillmentDataResponse}
40
74
  */
41
75
  generateFulfillmentData(fulfillerAddress: string, orderHash: string, protocolAddress: string, side: OrderSide): Promise<FulfillmentDataResponse>;
42
76
  /**
43
- * Send an order to be posted. Throws when the order is invalid.
77
+ * Post an order to OpenSea.
78
+ * @param order The order to post
79
+ * @param apiOptions
80
+ * @param apiOptions.protocol The protocol, typically seaport, to post the order to.
81
+ * @param apiOptions.side The side of the order (buy or sell).
82
+ * @param apiOptions.protocolAddress The address of the seaport contract.
83
+ * @param options
84
+ * @param options.retries Number of times to retry if the service is unavailable for any reason.
85
+ * @returns The {@link OrderV2} posted to the API.
44
86
  */
45
87
  postOrder(order: ProtocolData, apiOptions: OrderAPIOptions, { retries }?: {
46
88
  retries?: number;
47
89
  }): Promise<OrderV2>;
48
90
  /**
49
- * Build an offer
91
+ * Build a OpenSea collection offer.
92
+ * @param offererAddress The wallet address which is creating the offer.
93
+ * @param quantity The number of NFTs requested in the offer.
94
+ * @param collectionSlug The slug (identifier) of the collection to build the offer for.
95
+ * @returns The {@link BuildOfferResponse} returned by the API.
50
96
  */
51
97
  buildOffer(offererAddress: string, quantity: number, collectionSlug: string): Promise<BuildOfferResponse>;
52
98
  /**
53
- * Get collection offers for a given slug in the API
54
- *
55
- * @param slug The collection you would like to list offers for
56
- * @param retries Number of times to retry if the service is unavailable for any reason
57
- *
58
- * @returns {@link ListCollectionOffersResponse}
99
+ * Get a list collection offers for a given slug.
100
+ * @param slug The slug (identifier) of the collection to list offers for
101
+ * @param retries Number of times to retry if the service is unavailable for any reason.
102
+ * @returns The {@link ListCollectionOffersResponse} returned by the API.
59
103
  */
60
104
  getCollectionOffers(slug: string, retries?: number): Promise<ListCollectionOffersResponse | null>;
61
105
  /**
62
- * Post a collection offer to the API
63
- *
64
- * @param order The order to post
65
- * @param slug The collection you would like to post an offer for
66
- * @param retries Number of times to retry if the service is unavailable for any reason
67
- *
68
- * @returns {@link Offer}
106
+ * Post a collection offer to OpenSea.
107
+ * @param order The collection offer to post.
108
+ * @param slug The slug (identifier) of the collection to post the offer for.
109
+ * @param retries Number of times to retry if the service is unavailable for any reason.
110
+ * @returns The {@link Offer} returned to the API.
69
111
  */
70
112
  postCollectionOffer(order: ProtocolData, slug: string, retries?: number): Promise<Offer | null>;
71
113
  /**
72
- * Fetch an asset from the API, throwing if none is found
73
- *
74
- * @deprecated Please use `getNFT()` for multichain capabilities.
75
- *
76
- * @param tokenAddress Address of the asset's contract
77
- * @param tokenId The asset's token ID, or null if ERC-20
114
+ * Fetch an asset.
115
+ * @deprecated Use {@link getNFT} for multichain capabilities.
116
+ * @param options
117
+ * @param options.tokenAddress The asset's contract address.
118
+ * @param options.tokenId The asset's token ID, or null if ERC-20
78
119
  * @param retries Number of times to retry if the service is unavailable for any reason
120
+ * @returns The {@link OpenSeaAsset} returned by the API.
121
+ * @throws An error if the function is called on an unsupported chain.
79
122
  */
80
123
  getAsset({ tokenAddress, tokenId, }: {
81
124
  tokenAddress: string;
82
125
  tokenId: string | number | null;
83
126
  }, retries?: number): Promise<OpenSeaAsset>;
84
127
  /**
85
- * Fetch multiple NFTs for a collection from the API
86
- * @param slug The collection you would like to list NFTs for
128
+ * Fetch multiple NFTs for a collection.
129
+ * @param slug The slug (identifier) of the collection
87
130
  * @param limit The number of NFTs to retrieve. Must be greater than 0 and less than 51.
88
131
  * @param next Cursor to retrieve the next page of NFTs
89
- * @param retries Number of times to retry if the service is unavailable for any reason
132
+ * @param retries Number of times to retry if the service is unavailable for any reason.
133
+ * @returns The {@link ListNFTsResponse} returned by the API.
90
134
  */
91
135
  getNFTsByCollection(slug: string, limit?: number | undefined, next?: string | undefined, retries?: number): Promise<ListNFTsResponse>;
92
136
  /**
93
- * Fetch multiple NFTs for a contract from the API
94
- * @param chain chain the contract is deployed to
95
- * @param address address of the smart contract
137
+ * Fetch multiple NFTs for a contract.
138
+ * @param chain The NFT's chain.
139
+ * @param address The NFT's contract address.
96
140
  * @param limit The number of NFTs to retrieve. Must be greater than 0 and less than 51.
97
- * @param next Cursor to retrieve the next page of NFTs
98
- * @param retries Number of times to retry if the service is unavailable for any reason
141
+ * @param next Cursor to retrieve the next page of NFTs.
142
+ * @param retries Number of times to retry if the service is unavailable for any reason.
143
+ * @returns The {@link ListNFTsResponse} returned by the API.
99
144
  */
100
145
  getNFTsByContract(chain: Chain, address: string, limit?: number | undefined, next?: string | undefined, retries?: number): Promise<ListNFTsResponse>;
101
146
  /**
102
- * Fetch metadata, traits, ownership information, and rarity for an NFT from the API
103
- * @param chain chain the contract is deployed to
104
- * @param address address of the smart contract
105
- * @param identifierthe identifier of the NFT (i.e. token_id)
147
+ * Fetch metadata, traits, ownership information, and rarity for a single NFT.
148
+ * @param chain The NFT's chain.
149
+ * @param address The NFT's contract address.
150
+ * @param identifier the identifier of the NFT (i.e. Token ID)
106
151
  * @param retries Number of times to retry if the service is unavailable for any reason
152
+ * @returns The {@link GetNFTResponse} returned by the API.
107
153
  */
108
154
  getNFT(chain: Chain, address: string, identifier: string, retries?: number): Promise<GetNFTResponse>;
109
155
  /**
110
- * Fetch list of assets from the API, returning the page of assets and the count of total assets
111
- *
112
- * @deprecated Please use `getNFTsByContract()` or `getNFTsByCollection()` for multichain capabilities.
113
- *
114
- * @param query Query to use for getting orders. A subset of parameters on the `OpenSeaAssetJSON` type is supported
115
- */
116
- getAssets(query?: OpenSeaAssetQuery): Promise<{
117
- assets: OpenSeaAsset[];
118
- estimatedCount: number;
119
- next: string | undefined;
120
- previous: string | undefined;
121
- }>;
122
- /**
123
- * Fetch a collection through the API
156
+ * Fetch a list of assets.
157
+ * @deprecated Use {@link getNFTsByContract} or {@link getNFTsByCollection} for multichain capabilities.
158
+ * @param query Options to filter the list returned.
159
+ * @param query.owner The wallet address of the owner of the assets.
160
+ * @param query.asset_contract_address The Asset's contract address.
161
+ * @param query.token_ids String array of token IDs to filter by.
162
+ * @param query.order_by The field to order the list by.
163
+ * @param query.order_direction The direction to order the list.
164
+ * @param query.limit The number of assets to retrieve. Must be greater than 0 and less than 201.
165
+ * @param query.cursor Cursor to retrieve the next page of assets.
166
+ * @throws An error if the function is called on an unsupported chain.
167
+ * @returns The {@link GetAssetsResponse} returned by the API.
168
+ */
169
+ getAssets(query?: OpenSeaAssetQuery): Promise<GetAssetsResponse>;
170
+ /**
171
+ * Fetch an OpenSea collection.
172
+ * @param slug The slug (identifier) of the collection.
173
+ * @returns The {@link OpenSeaCollection} returned by the API.
124
174
  */
125
175
  getCollection(slug: string): Promise<OpenSeaCollection>;
126
176
  /**
127
- * Fetch list of fungible tokens from the API matching parameters
128
- * @param query Query to use for getting orders. A subset of parameters on the `OpenSeaAssetJSON` type is supported
129
- * @param page Page number, defaults to 1. Can be overridden by
130
- * `limit` and `offset` attributes from OpenSeaFungibleTokenQuery
131
- * @param retries Number of times to retry if the service is unavailable for any reason
177
+ * Fetch list of fungible tokens.
178
+ * @param query Query to use for getting tokens. See {@link OpenSeaFungibleTokenQuery}.
179
+ * @param page Page number to fetch. Defaults to 1.
180
+ * @param retries Number of times to retry if the service is unavailable for any reason.
181
+ * @throws An error if the function is called on an unsupported chain.
182
+ * @returns The {@link GetPaymentTokensResponse} returned by the API.
132
183
  */
133
- getPaymentTokens(query?: OpenSeaFungibleTokenQuery, page?: number, retries?: number): Promise<{
134
- tokens: OpenSeaFungibleToken[];
135
- }>;
184
+ getPaymentTokens(query?: OpenSeaFungibleTokenQuery, page?: number, retries?: number): Promise<GetPaymentTokensResponse>;
136
185
  /**
137
- * Fetch a bundle from the API, return null if it isn't found
138
- * @param slug The bundle's identifier
186
+ * Fetch a bundle from the API.
187
+ * @param options
188
+ * @param options.slug The bundle's identifier
189
+ * @returns The {@link OpenSeaAssetBundle} returned by the API. If not found, returns null.
139
190
  */
140
191
  getBundle({ slug, }: {
141
192
  slug: string;
142
193
  }): Promise<OpenSeaAssetBundle | null>;
143
194
  /**
144
- * Fetch list of bundles from the API, returning the page of bundles and the count of total bundles
145
- * @param query Query to use for getting orders. A subset of parameters on the `OpenSeaAssetBundleJSON` type is supported
146
- * @param page Page number, defaults to 1. Can be overridden by
147
- * `limit` and `offset` attributes from OpenSeaAssetBundleQuery
195
+ * Fetch list of bundles from the API.
196
+ * @param query Query to use for getting bunldes. See {@link OpenSeaAssetBundleQuery}.
197
+ * @param page Page number to fetch. Defaults to 1.
198
+ * @returns The {@link GetBundlesResponse} returned by the API.
148
199
  */
149
- getBundles(query?: OpenSeaAssetBundleQuery, page?: number): Promise<{
150
- bundles: OpenSeaAssetBundle[];
151
- estimatedCount: number;
152
- }>;
200
+ getBundles(query?: OpenSeaAssetBundleQuery, page?: number): Promise<GetBundlesResponse>;
153
201
  /**
154
- * Used to force refresh the metadata for an NFT from the API
155
- * @param chain chain the contract is deployed to
156
- * @param address address of the smart contract
157
- * @param identifierthe identifier of the NFT (i.e. token_id)
158
- * @param retries Number of times to retry if the service is unavailable for any reason
202
+ * Force refresh the metadata for an NFT.
203
+ * @param chain The chain where the NFT is located.
204
+ * @param address The address of the NFT's contract.
205
+ * @param identifier The identifier of the NFT.
206
+ * @param retries Number of times to retry if the service is unavailable for any reason.
207
+ * @returns The response from the API.
159
208
  */
160
- refreshNFTMetadata(chain: Chain, address: string, identifier: string, retries?: number): Promise<unknown>;
209
+ refreshNFTMetadata(chain: Chain, address: string, identifier: string, retries?: number): Promise<Response>;
161
210
  /**
162
- * Get JSON data from API, sending auth token in headers
211
+ * Generic fetch method for any API endpoint
163
212
  * @param apiPath Path to URL endpoint under API
164
- * @param query Data to send. Will be stringified using QueryString
213
+ * @param query URL query params. Will be used to create a URLSearchParams object.
214
+ * @returns @typeParam T The response from the API.
165
215
  */
166
216
  get<T>(apiPath: string, query?: object): Promise<T>;
167
217
  /**
168
- * POST JSON data to API, sending auth token in headers
218
+ * Generic post methd for any API endpoint.
169
219
  * @param apiPath Path to URL endpoint under API
170
- * @param body Data to send. Will be JSON.stringified
220
+ * @param body Data to send.
171
221
  * @param opts ethers ConnectionInfo, similar to Fetch API.
222
+ * @returns @typeParam T The response from the API.
172
223
  */
173
224
  post<T>(apiPath: string, body?: object, opts?: ethers.utils.ConnectionInfo): Promise<T>;
174
225
  private objectToSearchParams;