@opensea/sdk 10.4.0 → 10.5.0
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/accounts.d.ts +29 -1
- package/lib/api/accounts.js +63 -0
- package/lib/api/accounts.js.map +1 -1
- package/lib/api/api.d.ts +102 -1
- package/lib/api/api.js +145 -0
- package/lib/api/api.js.map +1 -1
- package/lib/api/apiPaths.d.ts +22 -0
- package/lib/api/apiPaths.js +97 -1
- package/lib/api/apiPaths.js.map +1 -1
- package/lib/api/assets.d.ts +18 -0
- package/lib/api/assets.js +26 -0
- package/lib/api/assets.js.map +1 -0
- package/lib/api/collections.d.ts +19 -1
- package/lib/api/collections.js +26 -0
- package/lib/api/collections.js.map +1 -1
- package/lib/api/drops.d.ts +12 -1
- package/lib/api/drops.js +14 -0
- package/lib/api/drops.js.map +1 -1
- package/lib/api/listings.d.ts +8 -1
- package/lib/api/listings.js +9 -0
- package/lib/api/listings.js.map +1 -1
- package/lib/api/nfts.d.ts +14 -1
- package/lib/api/nfts.js +19 -0
- package/lib/api/nfts.js.map +1 -1
- package/lib/api/tokens.d.ts +22 -1
- package/lib/api/tokens.js +26 -0
- package/lib/api/tokens.js.map +1 -1
- package/lib/api/types.d.ts +116 -1
- package/lib/api/types.js.map +1 -1
- package/package.json +2 -2
- package/src/api/accounts.ts +130 -0
- package/src/api/api.ts +270 -0
- package/src/api/apiPaths.ts +112 -0
- package/src/api/assets.ts +22 -0
- package/src/api/collections.ts +65 -0
- package/src/api/drops.ts +34 -1
- package/src/api/listings.ts +18 -0
- package/src/api/nfts.ts +44 -0
- package/src/api/tokens.ts +65 -0
- package/src/api/types.ts +162 -0
package/src/api/drops.ts
CHANGED
|
@@ -1,6 +1,16 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { Chain } from "../types"
|
|
2
|
+
import {
|
|
3
|
+
getDeployDropPath,
|
|
4
|
+
getDeployDropReceiptPath,
|
|
5
|
+
getDropMintPath,
|
|
6
|
+
getDropPath,
|
|
7
|
+
getDropsPath,
|
|
8
|
+
} from "./apiPaths"
|
|
2
9
|
import type { Fetcher } from "./fetcher"
|
|
3
10
|
import type {
|
|
11
|
+
DropDeployReceiptResponse,
|
|
12
|
+
DropDeployRequest,
|
|
13
|
+
DropDeployResponse,
|
|
4
14
|
DropMintRequest,
|
|
5
15
|
DropMintResponse,
|
|
6
16
|
GetDropResponse,
|
|
@@ -46,4 +56,27 @@ export class DropsAPI {
|
|
|
46
56
|
)
|
|
47
57
|
return response
|
|
48
58
|
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Builds a deploy-contract transaction for a new drop. Returns
|
|
62
|
+
* ready-to-sign transaction data — caller submits onchain and then polls
|
|
63
|
+
* `getDeployReceipt` until the contract address is available.
|
|
64
|
+
*/
|
|
65
|
+
async deployDropContract(
|
|
66
|
+
request: DropDeployRequest,
|
|
67
|
+
): Promise<DropDeployResponse> {
|
|
68
|
+
return this.fetcher.post<DropDeployResponse>(getDeployDropPath(), request)
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Get the receipt of a previously submitted drop-deploy transaction.
|
|
73
|
+
*/
|
|
74
|
+
async getDeployReceipt(
|
|
75
|
+
chain: Chain,
|
|
76
|
+
txHash: string,
|
|
77
|
+
): Promise<DropDeployReceiptResponse> {
|
|
78
|
+
return this.fetcher.get<DropDeployReceiptResponse>(
|
|
79
|
+
getDeployDropReceiptPath(chain, txHash),
|
|
80
|
+
)
|
|
81
|
+
}
|
|
49
82
|
}
|
package/src/api/listings.ts
CHANGED
|
@@ -2,11 +2,14 @@ import {
|
|
|
2
2
|
getAllListingsAPIPath,
|
|
3
3
|
getBestListingAPIPath,
|
|
4
4
|
getBestListingsAPIPath,
|
|
5
|
+
getCreateListingActionsPath,
|
|
5
6
|
getCrossChainFulfillmentDataPath,
|
|
6
7
|
getSweepListingsPath,
|
|
7
8
|
} from "./apiPaths"
|
|
8
9
|
import type { Fetcher } from "./fetcher"
|
|
9
10
|
import {
|
|
11
|
+
type CreateListingActionsRequest,
|
|
12
|
+
type CreateListingActionsResponse,
|
|
10
13
|
type CrossChainFulfillmentRequest,
|
|
11
14
|
type CrossChainFulfillmentResponse,
|
|
12
15
|
encodeTraitsParam,
|
|
@@ -122,4 +125,19 @@ export class ListingsAPI {
|
|
|
122
125
|
request,
|
|
123
126
|
)
|
|
124
127
|
}
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Get an ordered list of blockchain actions required to create one or more
|
|
131
|
+
* listings — token approvals + a final action containing the Seaport order
|
|
132
|
+
* to sign. Useful for clients that prefer the server to compute the
|
|
133
|
+
* approval graph.
|
|
134
|
+
*/
|
|
135
|
+
async createListingActions(
|
|
136
|
+
request: CreateListingActionsRequest,
|
|
137
|
+
): Promise<CreateListingActionsResponse> {
|
|
138
|
+
return this.fetcher.post<CreateListingActionsResponse>(
|
|
139
|
+
getCreateListingActionsPath(),
|
|
140
|
+
request,
|
|
141
|
+
)
|
|
142
|
+
}
|
|
125
143
|
}
|
package/src/api/nfts.ts
CHANGED
|
@@ -1,24 +1,32 @@
|
|
|
1
1
|
import type { Chain, OpenSeaCollection } from "../types"
|
|
2
2
|
import { collectionFromJSON } from "../utils/converters"
|
|
3
3
|
import {
|
|
4
|
+
getBatchNFTsPath,
|
|
4
5
|
getContractPath,
|
|
5
6
|
getListNFTsByAccountPath,
|
|
6
7
|
getListNFTsByCollectionPath,
|
|
7
8
|
getListNFTsByContractPath,
|
|
9
|
+
getNFTAnalyticsPath,
|
|
8
10
|
getNFTCollectionPath,
|
|
9
11
|
getNFTMetadataPath,
|
|
12
|
+
getNFTOwnersPath,
|
|
10
13
|
getNFTPath,
|
|
11
14
|
getRefreshMetadataPath,
|
|
12
15
|
getValidateMetadataPath,
|
|
13
16
|
} from "./apiPaths"
|
|
14
17
|
import type { Fetcher } from "./fetcher"
|
|
15
18
|
import {
|
|
19
|
+
type BatchNftsRequest,
|
|
16
20
|
encodeTraitsParam,
|
|
17
21
|
type GetCollectionResponse,
|
|
18
22
|
type GetContractResponse,
|
|
19
23
|
type GetNFTMetadataResponse,
|
|
20
24
|
type GetNFTResponse,
|
|
21
25
|
type ListNFTsResponse,
|
|
26
|
+
type NFTOwnersArgs,
|
|
27
|
+
type NftAnalyticsResponse,
|
|
28
|
+
type NftBatchResponse,
|
|
29
|
+
type OwnersPaginatedResponse,
|
|
22
30
|
type TraitFilter,
|
|
23
31
|
type ValidateMetadataResponse,
|
|
24
32
|
} from "./types"
|
|
@@ -178,4 +186,40 @@ export class NFTsAPI {
|
|
|
178
186
|
)
|
|
179
187
|
return response
|
|
180
188
|
}
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* Fetch multiple NFTs in a single request by chain + contract + token id.
|
|
192
|
+
*/
|
|
193
|
+
async getNFTsBatch(request: BatchNftsRequest): Promise<NftBatchResponse> {
|
|
194
|
+
return this.fetcher.post<NftBatchResponse>(getBatchNFTsPath(), request)
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* Fetch owners of an NFT. For ERC-721s this is a single owner; for
|
|
199
|
+
* ERC-1155s it can be a paginated list with per-owner quantities.
|
|
200
|
+
*/
|
|
201
|
+
async getNFTOwners(
|
|
202
|
+
address: string,
|
|
203
|
+
identifier: string,
|
|
204
|
+
chain: Chain = this.chain,
|
|
205
|
+
args?: NFTOwnersArgs,
|
|
206
|
+
): Promise<OwnersPaginatedResponse> {
|
|
207
|
+
return this.fetcher.get<OwnersPaginatedResponse>(
|
|
208
|
+
getNFTOwnersPath(chain, address, identifier),
|
|
209
|
+
args,
|
|
210
|
+
)
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
/**
|
|
214
|
+
* Fetch analytics for an NFT — historical sale points used for charting.
|
|
215
|
+
*/
|
|
216
|
+
async getNFTAnalytics(
|
|
217
|
+
address: string,
|
|
218
|
+
identifier: string,
|
|
219
|
+
chain: Chain = this.chain,
|
|
220
|
+
): Promise<NftAnalyticsResponse> {
|
|
221
|
+
return this.fetcher.get<NftAnalyticsResponse>(
|
|
222
|
+
getNFTAnalyticsPath(chain, address, identifier),
|
|
223
|
+
)
|
|
224
|
+
}
|
|
181
225
|
}
|
package/src/api/tokens.ts
CHANGED
|
@@ -1,14 +1,20 @@
|
|
|
1
|
+
import type { Chain } from "../types"
|
|
1
2
|
import {
|
|
3
|
+
getBatchTokensPath,
|
|
2
4
|
getSwapExecutePath,
|
|
3
5
|
getSwapQuotePath,
|
|
6
|
+
getTokenActivityPath,
|
|
4
7
|
getTokenGroupPath,
|
|
5
8
|
getTokenGroupsPath,
|
|
9
|
+
getTokenOhlcvPath,
|
|
6
10
|
getTokenPath,
|
|
11
|
+
getTokenPriceHistoryPath,
|
|
7
12
|
getTopTokensPath,
|
|
8
13
|
getTrendingTokensPath,
|
|
9
14
|
} from "./apiPaths"
|
|
10
15
|
import type { Fetcher } from "./fetcher"
|
|
11
16
|
import type {
|
|
17
|
+
BatchTokensRequest,
|
|
12
18
|
GetSwapQuoteArgs,
|
|
13
19
|
GetSwapQuoteResponse,
|
|
14
20
|
GetTokenGroupResponse,
|
|
@@ -18,8 +24,14 @@ import type {
|
|
|
18
24
|
GetTokensArgs,
|
|
19
25
|
GetTopTokensResponse,
|
|
20
26
|
GetTrendingTokensResponse,
|
|
27
|
+
OhlcvResponse,
|
|
28
|
+
PriceHistoryResponse,
|
|
21
29
|
SwapExecuteRequest,
|
|
22
30
|
SwapExecuteResponse,
|
|
31
|
+
TokenActivityArgs,
|
|
32
|
+
TokenBatchResponse,
|
|
33
|
+
TokenSwapActivityPaginatedResponse,
|
|
34
|
+
TokenTimeSeriesArgs,
|
|
23
35
|
} from "./types"
|
|
24
36
|
|
|
25
37
|
/**
|
|
@@ -96,4 +108,57 @@ export class TokensAPI {
|
|
|
96
108
|
async getTokenGroup(slug: string): Promise<GetTokenGroupResponse> {
|
|
97
109
|
return this.fetcher.get<GetTokenGroupResponse>(getTokenGroupPath(slug))
|
|
98
110
|
}
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Fetch multiple tokens in a single request by chain + contract address.
|
|
114
|
+
*/
|
|
115
|
+
async getTokensBatch(
|
|
116
|
+
request: BatchTokensRequest,
|
|
117
|
+
): Promise<TokenBatchResponse> {
|
|
118
|
+
return this.fetcher.post<TokenBatchResponse>(getBatchTokensPath(), request)
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Fetch the price history of a token. `start_time` is required and the
|
|
123
|
+
* default `end_time` is "now".
|
|
124
|
+
*/
|
|
125
|
+
async getTokenPriceHistory(
|
|
126
|
+
chain: Chain,
|
|
127
|
+
address: string,
|
|
128
|
+
args: TokenTimeSeriesArgs,
|
|
129
|
+
): Promise<PriceHistoryResponse> {
|
|
130
|
+
return this.fetcher.get<PriceHistoryResponse>(
|
|
131
|
+
getTokenPriceHistoryPath(chain, address),
|
|
132
|
+
args,
|
|
133
|
+
)
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Fetch OHLCV (open / high / low / close / volume) candles for a token.
|
|
138
|
+
* `start_time` and `bucket_size` are required.
|
|
139
|
+
*/
|
|
140
|
+
async getTokenOhlcv(
|
|
141
|
+
chain: Chain,
|
|
142
|
+
address: string,
|
|
143
|
+
args: TokenTimeSeriesArgs & { bucket_size: string },
|
|
144
|
+
): Promise<OhlcvResponse> {
|
|
145
|
+
return this.fetcher.get<OhlcvResponse>(
|
|
146
|
+
getTokenOhlcvPath(chain, address),
|
|
147
|
+
args,
|
|
148
|
+
)
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Fetch recent swap activity for a token.
|
|
153
|
+
*/
|
|
154
|
+
async getTokenActivity(
|
|
155
|
+
chain: Chain,
|
|
156
|
+
address: string,
|
|
157
|
+
args?: TokenActivityArgs,
|
|
158
|
+
): Promise<TokenSwapActivityPaginatedResponse> {
|
|
159
|
+
return this.fetcher.get<TokenSwapActivityPaginatedResponse>(
|
|
160
|
+
getTokenActivityPath(chain, address),
|
|
161
|
+
args,
|
|
162
|
+
)
|
|
163
|
+
}
|
|
99
164
|
}
|
package/src/api/types.ts
CHANGED
|
@@ -7,6 +7,9 @@ import type {
|
|
|
7
7
|
TransactionReceiptResponse as ApiTransactionReceiptResponse,
|
|
8
8
|
AssetMetadataResponse,
|
|
9
9
|
InstantApiKeyResponse,
|
|
10
|
+
ListingsResponse,
|
|
11
|
+
NftListResponse,
|
|
12
|
+
OffersResponse,
|
|
10
13
|
TokenGroupPaginatedResponse,
|
|
11
14
|
TokenGroupResponse,
|
|
12
15
|
} from "@opensea/api-types"
|
|
@@ -1338,3 +1341,162 @@ export type {
|
|
|
1338
1341
|
ListingObject,
|
|
1339
1342
|
SwapTransactionResponse,
|
|
1340
1343
|
} from "@opensea/api-types"
|
|
1344
|
+
|
|
1345
|
+
// ─── New endpoint types (api-types 0.4.0) ───────────────────────────
|
|
1346
|
+
// Request bodies for POST endpoints and response shapes for analytics /
|
|
1347
|
+
// profile / batch / drops-deploy / transfer endpoints. All re-exported
|
|
1348
|
+
// from @opensea/api-types — see packages/api-types/src/index.ts.
|
|
1349
|
+
|
|
1350
|
+
export type {
|
|
1351
|
+
BatchCollectionsRequest,
|
|
1352
|
+
BatchNftsRequest,
|
|
1353
|
+
BatchTokensRequest,
|
|
1354
|
+
CollectionBatchResponse,
|
|
1355
|
+
CollectionHoldersPaginatedResponse,
|
|
1356
|
+
CollectionOfferAggregatesPaginatedResponse,
|
|
1357
|
+
CreateListingActionsRequest,
|
|
1358
|
+
CreateListingActionsResponse,
|
|
1359
|
+
DropDeployReceiptResponse,
|
|
1360
|
+
DropDeployRequest,
|
|
1361
|
+
DropDeployResponse,
|
|
1362
|
+
FloorPriceHistoryResponse,
|
|
1363
|
+
NftAnalyticsResponse,
|
|
1364
|
+
NftBatchResponse,
|
|
1365
|
+
OhlcvResponse,
|
|
1366
|
+
OwnersPaginatedResponse,
|
|
1367
|
+
PortfolioHistoryResponse,
|
|
1368
|
+
PortfolioStatsResponse,
|
|
1369
|
+
PriceHistoryResponse,
|
|
1370
|
+
ProfileCollectionsResponse,
|
|
1371
|
+
TokenBatchResponse,
|
|
1372
|
+
TokenSwapActivityPaginatedResponse,
|
|
1373
|
+
TransferRequest,
|
|
1374
|
+
TransferResponse,
|
|
1375
|
+
} from "@opensea/api-types"
|
|
1376
|
+
|
|
1377
|
+
/**
|
|
1378
|
+
* Query args for paginated collection-analytics endpoints (offer aggregates,
|
|
1379
|
+
* holders). All fields are optional; `cursor` paginates forward.
|
|
1380
|
+
* @category API Query Args
|
|
1381
|
+
*/
|
|
1382
|
+
export interface PaginatedAnalyticsArgs {
|
|
1383
|
+
limit?: number
|
|
1384
|
+
cursor?: string
|
|
1385
|
+
sort_direction?: "asc" | "desc"
|
|
1386
|
+
}
|
|
1387
|
+
|
|
1388
|
+
/**
|
|
1389
|
+
* Query args for the collection holders endpoint — adds optional `owned_by`
|
|
1390
|
+
* filter on top of {@link PaginatedAnalyticsArgs}.
|
|
1391
|
+
* @category API Query Args
|
|
1392
|
+
*/
|
|
1393
|
+
export interface CollectionHoldersArgs extends PaginatedAnalyticsArgs {
|
|
1394
|
+
owned_by?: string
|
|
1395
|
+
}
|
|
1396
|
+
|
|
1397
|
+
/**
|
|
1398
|
+
* Query args for the collection floor-price history endpoint.
|
|
1399
|
+
* @category API Query Args
|
|
1400
|
+
*/
|
|
1401
|
+
export interface CollectionFloorPricesArgs {
|
|
1402
|
+
/** Time window: one_minute, five_minutes, fifteen_minutes, one_hour, one_day, seven_days, thirty_days, one_year, all_time */
|
|
1403
|
+
timeframe?: string
|
|
1404
|
+
/** Number of data points to return */
|
|
1405
|
+
resolution?: number
|
|
1406
|
+
}
|
|
1407
|
+
|
|
1408
|
+
/**
|
|
1409
|
+
* Query args for token price-history and OHLCV endpoints.
|
|
1410
|
+
* @category API Query Args
|
|
1411
|
+
*/
|
|
1412
|
+
export interface TokenTimeSeriesArgs {
|
|
1413
|
+
/** Start time (ISO 8601, required by the API). */
|
|
1414
|
+
start_time: string
|
|
1415
|
+
/** End time (ISO 8601, defaults to now). */
|
|
1416
|
+
end_time?: string
|
|
1417
|
+
/** Candle bucket size: 1s, 1m, 5m, 15m, 1h, 4h, 1d. */
|
|
1418
|
+
bucket_size?: string
|
|
1419
|
+
/** Whether to fill empty time windows with zero-volume candles (OHLCV only). */
|
|
1420
|
+
fill_time_window?: boolean
|
|
1421
|
+
}
|
|
1422
|
+
|
|
1423
|
+
/**
|
|
1424
|
+
* Query args for the token swap-activity endpoint.
|
|
1425
|
+
* @category API Query Args
|
|
1426
|
+
*/
|
|
1427
|
+
export interface TokenActivityArgs {
|
|
1428
|
+
limit?: number
|
|
1429
|
+
cursor?: string
|
|
1430
|
+
}
|
|
1431
|
+
|
|
1432
|
+
/**
|
|
1433
|
+
* Query args for the NFT owners endpoint (paginated with `next` cursor).
|
|
1434
|
+
* @category API Query Args
|
|
1435
|
+
*/
|
|
1436
|
+
export interface NFTOwnersArgs {
|
|
1437
|
+
limit?: number
|
|
1438
|
+
next?: string
|
|
1439
|
+
}
|
|
1440
|
+
|
|
1441
|
+
/**
|
|
1442
|
+
* Query args for the account portfolio and portfolio history endpoints.
|
|
1443
|
+
* @category API Query Args
|
|
1444
|
+
*/
|
|
1445
|
+
export interface PortfolioArgs {
|
|
1446
|
+
/** Timeframe for P&L / net-worth history calculation. */
|
|
1447
|
+
timeframe?: "HOUR" | "DAY" | "WEEK" | "MONTH"
|
|
1448
|
+
}
|
|
1449
|
+
|
|
1450
|
+
/**
|
|
1451
|
+
* Query args shared by the account profile listing-and-offer endpoints
|
|
1452
|
+
* (offers, offers_received, listings).
|
|
1453
|
+
* @category API Query Args
|
|
1454
|
+
*/
|
|
1455
|
+
export interface ProfileOrdersArgs {
|
|
1456
|
+
after?: string
|
|
1457
|
+
limit?: number
|
|
1458
|
+
collection_slugs?: string[]
|
|
1459
|
+
chains?: string[]
|
|
1460
|
+
sort_by?: string
|
|
1461
|
+
sort_direction?: "asc" | "desc"
|
|
1462
|
+
}
|
|
1463
|
+
|
|
1464
|
+
/**
|
|
1465
|
+
* Query args for the account profile favorites endpoint.
|
|
1466
|
+
* @category API Query Args
|
|
1467
|
+
*/
|
|
1468
|
+
export interface ProfileFavoritesArgs {
|
|
1469
|
+
after?: string
|
|
1470
|
+
limit?: number
|
|
1471
|
+
sort_by?: string
|
|
1472
|
+
sort_direction?: "asc" | "desc"
|
|
1473
|
+
chains?: string[]
|
|
1474
|
+
}
|
|
1475
|
+
|
|
1476
|
+
/**
|
|
1477
|
+
* Query args for the account profile collections endpoint.
|
|
1478
|
+
* @category API Query Args
|
|
1479
|
+
*/
|
|
1480
|
+
export interface ProfileCollectionsArgs {
|
|
1481
|
+
after?: string
|
|
1482
|
+
limit?: number
|
|
1483
|
+
chains?: string[]
|
|
1484
|
+
}
|
|
1485
|
+
|
|
1486
|
+
/**
|
|
1487
|
+
* Response from the account favorites endpoint — favorited NFTs.
|
|
1488
|
+
* @category API Response Types
|
|
1489
|
+
*/
|
|
1490
|
+
export type ProfileFavoritesResponse = NftListResponse
|
|
1491
|
+
|
|
1492
|
+
/**
|
|
1493
|
+
* Response from the account profile listings endpoint.
|
|
1494
|
+
* @category API Response Types
|
|
1495
|
+
*/
|
|
1496
|
+
export type ProfileListingsResponse = ListingsResponse
|
|
1497
|
+
|
|
1498
|
+
/**
|
|
1499
|
+
* Response from the account profile offers / offers_received endpoints.
|
|
1500
|
+
* @category API Response Types
|
|
1501
|
+
*/
|
|
1502
|
+
export type ProfileOffersResponse = OffersResponse
|