@opensea/sdk 10.3.1 → 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 +129 -41
- package/lib/api/api.js +180 -48
- package/lib/api/api.js.map +1 -1
- package/lib/api/apiPaths.d.ts +29 -2
- package/lib/api/apiPaths.js +121 -6
- 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 +16 -14
- package/lib/api/listings.js +21 -30
- 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/offers.d.ts +2 -2
- package/lib/api/offers.js +2 -9
- package/lib/api/offers.js.map +1 -1
- package/lib/api/orders.d.ts +4 -21
- package/lib/api/orders.js +15 -96
- package/lib/api/orders.js.map +1 -1
- package/lib/api/tokens.d.ts +27 -1
- package/lib/api/tokens.js +33 -0
- package/lib/api/tokens.js.map +1 -1
- package/lib/api/transactions.d.ts +16 -0
- package/lib/api/transactions.js +24 -0
- package/lib/api/transactions.js.map +1 -0
- package/lib/api/types.d.ts +147 -10
- package/lib/api/types.js.map +1 -1
- package/lib/orders/types.d.ts +0 -67
- package/lib/orders/types.js.map +1 -1
- package/lib/orders/utils.d.ts +1 -19
- package/lib/orders/utils.js +1 -62
- package/lib/orders/utils.js.map +1 -1
- package/lib/sdk/base.d.ts +6 -6
- package/lib/sdk/base.js +2 -2
- package/lib/sdk/orders.d.ts +13 -10
- package/lib/sdk/orders.js +6 -22
- package/lib/sdk/orders.js.map +1 -1
- package/lib/types.d.ts +0 -6
- package/package.json +2 -2
- package/src/api/accounts.ts +130 -0
- package/src/api/api.ts +324 -86
- package/src/api/apiPaths.ts +138 -8
- 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 +37 -41
- package/src/api/nfts.ts +44 -0
- package/src/api/offers.ts +8 -16
- package/src/api/orders.ts +40 -177
- package/src/api/tokens.ts +76 -0
- package/src/api/transactions.ts +28 -0
- package/src/api/types.ts +205 -15
- package/src/orders/types.ts +0 -74
- package/src/orders/utils.ts +2 -73
- package/src/sdk/base.ts +6 -6
- package/src/sdk/orders.ts +31 -32
- package/src/types.ts +0 -6
package/src/api/api.ts
CHANGED
|
@@ -1,11 +1,5 @@
|
|
|
1
1
|
import { API_BASE_MAINNET } from "../constants"
|
|
2
|
-
import type {
|
|
3
|
-
FulfillmentDataResponse,
|
|
4
|
-
OrderAPIOptions,
|
|
5
|
-
OrdersQueryOptions,
|
|
6
|
-
OrderV2,
|
|
7
|
-
ProtocolData,
|
|
8
|
-
} from "../orders/types"
|
|
2
|
+
import type { FulfillmentDataResponse, ProtocolData } from "../orders/types"
|
|
9
3
|
import {
|
|
10
4
|
Chain,
|
|
11
5
|
type OpenSeaAccount,
|
|
@@ -20,6 +14,7 @@ import {
|
|
|
20
14
|
import { executeWithRateLimit } from "../utils/rateLimit"
|
|
21
15
|
import { AccountsAPI } from "./accounts"
|
|
22
16
|
import { getInstantApiKeyPath } from "./apiPaths"
|
|
17
|
+
import { AssetsAPI } from "./assets"
|
|
23
18
|
import { ChainsAPI } from "./chains"
|
|
24
19
|
import { CollectionsAPI } from "./collections"
|
|
25
20
|
import { DropsAPI } from "./drops"
|
|
@@ -30,15 +25,30 @@ import { OffersAPI } from "./offers"
|
|
|
30
25
|
import { OrdersAPI } from "./orders"
|
|
31
26
|
import { SearchAPI } from "./search"
|
|
32
27
|
import { TokensAPI } from "./tokens"
|
|
28
|
+
import { TransactionsAPI } from "./transactions"
|
|
33
29
|
import {
|
|
30
|
+
type BatchCollectionsRequest,
|
|
31
|
+
type BatchNftsRequest,
|
|
32
|
+
type BatchTokensRequest,
|
|
34
33
|
type BuildOfferResponse,
|
|
35
34
|
type CancelOrderResponse,
|
|
35
|
+
type CollectionBatchResponse,
|
|
36
|
+
type CollectionFloorPricesArgs,
|
|
37
|
+
type CollectionHoldersArgs,
|
|
38
|
+
type CollectionHoldersPaginatedResponse,
|
|
36
39
|
type CollectionOffer,
|
|
40
|
+
type CollectionOfferAggregatesPaginatedResponse,
|
|
37
41
|
CollectionOrderByOption,
|
|
42
|
+
type CreateListingActionsRequest,
|
|
43
|
+
type CreateListingActionsResponse,
|
|
38
44
|
type CrossChainFulfillmentRequest,
|
|
39
45
|
type CrossChainFulfillmentResponse,
|
|
46
|
+
type DropDeployReceiptResponse,
|
|
47
|
+
type DropDeployRequest,
|
|
48
|
+
type DropDeployResponse,
|
|
40
49
|
type DropMintRequest,
|
|
41
50
|
type DropMintResponse,
|
|
51
|
+
type FloorPriceHistoryResponse,
|
|
42
52
|
type GetAccountTokensArgs,
|
|
43
53
|
type GetAccountTokensResponse,
|
|
44
54
|
type GetBestListingResponse,
|
|
@@ -58,7 +68,6 @@ import {
|
|
|
58
68
|
type GetNFTResponse,
|
|
59
69
|
type GetOffersResponse,
|
|
60
70
|
type GetOrderByHashResponse,
|
|
61
|
-
type GetOrdersResponse,
|
|
62
71
|
type GetSwapQuoteArgs,
|
|
63
72
|
type GetSwapQuoteResponse,
|
|
64
73
|
type GetTokenGroupResponse,
|
|
@@ -73,12 +82,41 @@ import {
|
|
|
73
82
|
type GetTrendingTokensResponse,
|
|
74
83
|
type Listing,
|
|
75
84
|
type ListNFTsResponse,
|
|
85
|
+
type NFTOwnersArgs,
|
|
86
|
+
type NftAnalyticsResponse,
|
|
87
|
+
type NftBatchResponse,
|
|
76
88
|
type Offer,
|
|
89
|
+
type OhlcvResponse,
|
|
90
|
+
type OwnersPaginatedResponse,
|
|
91
|
+
type PaginatedAnalyticsArgs,
|
|
92
|
+
type PortfolioArgs,
|
|
93
|
+
type PortfolioHistoryResponse,
|
|
94
|
+
type PortfolioStatsResponse,
|
|
95
|
+
type PriceHistoryResponse,
|
|
96
|
+
type ProfileCollectionsArgs,
|
|
97
|
+
type ProfileCollectionsResponse,
|
|
98
|
+
type ProfileFavoritesArgs,
|
|
99
|
+
type ProfileFavoritesResponse,
|
|
100
|
+
type ProfileListingsResponse,
|
|
101
|
+
type ProfileOffersResponse,
|
|
102
|
+
type ProfileOrdersArgs,
|
|
77
103
|
type RequestInstantApiKeyResponse,
|
|
78
104
|
type ResolveAccountResponse,
|
|
79
105
|
type SearchArgs,
|
|
80
106
|
type SearchResponse,
|
|
107
|
+
type SwapExecuteRequest,
|
|
108
|
+
type SwapExecuteResponse,
|
|
109
|
+
type SweepCollectionRequest,
|
|
110
|
+
type SweepCollectionResponse,
|
|
111
|
+
type TokenActivityArgs,
|
|
112
|
+
type TokenBatchResponse,
|
|
113
|
+
type TokenSwapActivityPaginatedResponse,
|
|
114
|
+
type TokenTimeSeriesArgs,
|
|
81
115
|
type TraitFilter,
|
|
116
|
+
type TransactionReceiptRequest,
|
|
117
|
+
type TransactionReceiptResponse,
|
|
118
|
+
type TransferRequest,
|
|
119
|
+
type TransferResponse,
|
|
82
120
|
type ValidateMetadataResponse,
|
|
83
121
|
} from "./types"
|
|
84
122
|
|
|
@@ -115,6 +153,8 @@ export class OpenSeaAPI {
|
|
|
115
153
|
private tokensAPI: TokensAPI
|
|
116
154
|
private chainsAPI: ChainsAPI
|
|
117
155
|
private dropsAPI: DropsAPI
|
|
156
|
+
private transactionsAPI: TransactionsAPI
|
|
157
|
+
private assetsAPI: AssetsAPI
|
|
118
158
|
|
|
119
159
|
/**
|
|
120
160
|
* Create an instance of the OpenSeaAPI
|
|
@@ -143,7 +183,7 @@ export class OpenSeaAPI {
|
|
|
143
183
|
// Initialize specialized API clients
|
|
144
184
|
this.ordersAPI = new OrdersAPI(fetcher, this.chain)
|
|
145
185
|
this.offersAPI = new OffersAPI(fetcher, this.chain)
|
|
146
|
-
this.listingsAPI = new ListingsAPI(fetcher
|
|
186
|
+
this.listingsAPI = new ListingsAPI(fetcher)
|
|
147
187
|
this.collectionsAPI = new CollectionsAPI(fetcher)
|
|
148
188
|
this.nftsAPI = new NFTsAPI(fetcher, this.chain)
|
|
149
189
|
this.accountsAPI = new AccountsAPI(fetcher, this.chain)
|
|
@@ -152,20 +192,8 @@ export class OpenSeaAPI {
|
|
|
152
192
|
this.tokensAPI = new TokensAPI(fetcher)
|
|
153
193
|
this.chainsAPI = new ChainsAPI(fetcher)
|
|
154
194
|
this.dropsAPI = new DropsAPI(fetcher)
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
/**
|
|
158
|
-
* Gets an order from API based on query options.
|
|
159
|
-
* @deprecated Use collection-based endpoints instead: getAllOffers, getAllListings, getBestOffer, getBestListing.
|
|
160
|
-
* @param options Query options for fetching an order
|
|
161
|
-
* @returns The first {@link OrderV2} returned by the API
|
|
162
|
-
*
|
|
163
|
-
* @throws An error if there are no matching orders.
|
|
164
|
-
*/
|
|
165
|
-
public async getOrder(
|
|
166
|
-
options: Omit<OrdersQueryOptions, "limit">,
|
|
167
|
-
): Promise<OrderV2> {
|
|
168
|
-
return this.ordersAPI.getOrder(options)
|
|
195
|
+
this.transactionsAPI = new TransactionsAPI(fetcher)
|
|
196
|
+
this.assetsAPI = new AssetsAPI(fetcher)
|
|
169
197
|
}
|
|
170
198
|
|
|
171
199
|
/**
|
|
@@ -184,18 +212,6 @@ export class OpenSeaAPI {
|
|
|
184
212
|
return this.ordersAPI.getOrderByHash(orderHash, protocolAddress, chain)
|
|
185
213
|
}
|
|
186
214
|
|
|
187
|
-
/**
|
|
188
|
-
* Gets a list of orders from API based on query options.
|
|
189
|
-
* @deprecated Use collection-based endpoints instead: getAllOffers, getAllListings, getBestOffer, getBestListing.
|
|
190
|
-
* @param options Query options for fetching orders
|
|
191
|
-
* @returns The {@link GetOrdersResponse} returned by the API.
|
|
192
|
-
*/
|
|
193
|
-
public async getOrders(
|
|
194
|
-
options: Omit<OrdersQueryOptions, "limit">,
|
|
195
|
-
): Promise<GetOrdersResponse> {
|
|
196
|
-
return this.ordersAPI.getOrders({ ...options, pageSize: this.pageSize })
|
|
197
|
-
}
|
|
198
|
-
|
|
199
215
|
/**
|
|
200
216
|
* Gets all offers for a given collection.
|
|
201
217
|
* @param collectionSlug The slug of the collection.
|
|
@@ -371,20 +387,6 @@ export class OpenSeaAPI {
|
|
|
371
387
|
)
|
|
372
388
|
}
|
|
373
389
|
|
|
374
|
-
/**
|
|
375
|
-
* Post an order to OpenSea.
|
|
376
|
-
* @deprecated Use postListing or postOffer instead.
|
|
377
|
-
* @param order The order to post
|
|
378
|
-
* @param apiOptions API options for the order
|
|
379
|
-
* @returns The {@link OrderV2} posted to the API.
|
|
380
|
-
*/
|
|
381
|
-
public async postOrder(
|
|
382
|
-
order: ProtocolData,
|
|
383
|
-
apiOptions: OrderAPIOptions,
|
|
384
|
-
): Promise<OrderV2> {
|
|
385
|
-
return this.ordersAPI.postOrder(order, apiOptions)
|
|
386
|
-
}
|
|
387
|
-
|
|
388
390
|
/**
|
|
389
391
|
* Post a listing to OpenSea. Returns the new v2 Listing response format.
|
|
390
392
|
* @param order The order to post
|
|
@@ -864,55 +866,61 @@ export class OpenSeaAPI {
|
|
|
864
866
|
|
|
865
867
|
/**
|
|
866
868
|
* Gets all active offers for a specific NFT (not just the best offer).
|
|
867
|
-
* @param
|
|
868
|
-
* @param
|
|
869
|
-
* @param limit The number of offers to return. Must be between 1 and
|
|
870
|
-
* @param next The cursor for the next page of results.
|
|
871
|
-
* @param chain The chain where the NFT is located. Defaults to the chain set in the constructor.
|
|
869
|
+
* @param collectionSlug The collection slug.
|
|
870
|
+
* @param identifier The NFT token id.
|
|
871
|
+
* @param limit The number of offers to return. Must be between 1 and 200.
|
|
872
|
+
* @param next The cursor for the next page of results.
|
|
872
873
|
* @returns The {@link GetOffersResponse} returned by the API.
|
|
873
874
|
*/
|
|
874
|
-
public async
|
|
875
|
-
|
|
876
|
-
|
|
875
|
+
public async getOffersByNFT(
|
|
876
|
+
collectionSlug: string,
|
|
877
|
+
identifier: string | number,
|
|
877
878
|
limit?: number,
|
|
878
879
|
next?: string,
|
|
879
|
-
chain: Chain = this.chain,
|
|
880
880
|
): Promise<GetOffersResponse> {
|
|
881
|
-
return this.offersAPI.
|
|
882
|
-
|
|
883
|
-
|
|
881
|
+
return this.offersAPI.getOffersByNFT(
|
|
882
|
+
collectionSlug,
|
|
883
|
+
identifier,
|
|
884
884
|
limit,
|
|
885
885
|
next,
|
|
886
|
-
chain,
|
|
887
886
|
)
|
|
888
887
|
}
|
|
889
888
|
|
|
890
889
|
/**
|
|
891
|
-
*
|
|
892
|
-
*
|
|
893
|
-
* @param
|
|
894
|
-
* @
|
|
895
|
-
* @param next The cursor for the next page of results. This is returned from a previous request.
|
|
896
|
-
* @param chain The chain where the NFT is located. Defaults to the chain set in the constructor.
|
|
897
|
-
* @param includePrivateListings Whether to include private listings (default: false)
|
|
898
|
-
* @returns The {@link GetListingsResponse} returned by the API.
|
|
890
|
+
* Bulk-buy items from a collection using any payment token, including
|
|
891
|
+
* cross-chain. Returns an ordered list of transactions to execute.
|
|
892
|
+
* @param request The sweep request containing buyer, collection, payment, and item caps.
|
|
893
|
+
* @returns The {@link SweepCollectionResponse} returned by the API.
|
|
899
894
|
*/
|
|
900
|
-
public async
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
)
|
|
895
|
+
public async sweepCollection(
|
|
896
|
+
request: SweepCollectionRequest,
|
|
897
|
+
): Promise<SweepCollectionResponse> {
|
|
898
|
+
return this.listingsAPI.sweepCollection(request)
|
|
899
|
+
}
|
|
900
|
+
|
|
901
|
+
/**
|
|
902
|
+
* Get executable transactions for a token swap. Companion to
|
|
903
|
+
* {@link OpenSeaAPI.getSwapQuote} — quote first, then execute.
|
|
904
|
+
* @param request The swap execution request.
|
|
905
|
+
* @returns The {@link SwapExecuteResponse} with transactions and a quote.
|
|
906
|
+
*/
|
|
907
|
+
public async executeSwap(
|
|
908
|
+
request: SwapExecuteRequest,
|
|
909
|
+
): Promise<SwapExecuteResponse> {
|
|
910
|
+
return this.tokensAPI.executeSwap(request)
|
|
911
|
+
}
|
|
912
|
+
|
|
913
|
+
/**
|
|
914
|
+
* Get the receipt/status for a submitted transaction. Works for all transaction
|
|
915
|
+
* types: listing fulfillments, cross-chain buys, sweeps, offer fulfillments,
|
|
916
|
+
* and token swaps. Poll this endpoint to check completion status.
|
|
917
|
+
* @param request The transaction receipt request.
|
|
918
|
+
* @returns The {@link TransactionReceiptResponse} returned by the API.
|
|
919
|
+
*/
|
|
920
|
+
public async getTransactionReceipt(
|
|
921
|
+
request: TransactionReceiptRequest,
|
|
922
|
+
): Promise<TransactionReceiptResponse> {
|
|
923
|
+
return this.transactionsAPI.getTransactionReceipt(request)
|
|
916
924
|
}
|
|
917
925
|
|
|
918
926
|
/**
|
|
@@ -1012,6 +1020,236 @@ export class OpenSeaAPI {
|
|
|
1012
1020
|
return this.nftsAPI.getNFTMetadata(address, tokenId, chain)
|
|
1013
1021
|
}
|
|
1014
1022
|
|
|
1023
|
+
/**
|
|
1024
|
+
* Fetch multiple tokens in a single request.
|
|
1025
|
+
* @param request Batch request listing chain + contract address pairs.
|
|
1026
|
+
* @returns The {@link TokenBatchResponse} with detailed token info.
|
|
1027
|
+
*/
|
|
1028
|
+
public async getTokensBatch(
|
|
1029
|
+
request: BatchTokensRequest,
|
|
1030
|
+
): Promise<TokenBatchResponse> {
|
|
1031
|
+
return this.tokensAPI.getTokensBatch(request)
|
|
1032
|
+
}
|
|
1033
|
+
|
|
1034
|
+
/**
|
|
1035
|
+
* Fetch the price history of a token.
|
|
1036
|
+
* @param chain Chain the token lives on.
|
|
1037
|
+
* @param address Token contract address.
|
|
1038
|
+
* @param args Time-series window — `start_time` required, `end_time` defaults to now.
|
|
1039
|
+
* @returns The {@link PriceHistoryResponse} returned by the API.
|
|
1040
|
+
*/
|
|
1041
|
+
public async getTokenPriceHistory(
|
|
1042
|
+
chain: Chain,
|
|
1043
|
+
address: string,
|
|
1044
|
+
args: TokenTimeSeriesArgs,
|
|
1045
|
+
): Promise<PriceHistoryResponse> {
|
|
1046
|
+
return this.tokensAPI.getTokenPriceHistory(chain, address, args)
|
|
1047
|
+
}
|
|
1048
|
+
|
|
1049
|
+
/**
|
|
1050
|
+
* Fetch OHLCV candles for a token.
|
|
1051
|
+
* @param chain Chain the token lives on.
|
|
1052
|
+
* @param address Token contract address.
|
|
1053
|
+
* @param args Time-series window plus candle `bucket_size` (required).
|
|
1054
|
+
* @returns The {@link OhlcvResponse} returned by the API.
|
|
1055
|
+
*/
|
|
1056
|
+
public async getTokenOhlcv(
|
|
1057
|
+
chain: Chain,
|
|
1058
|
+
address: string,
|
|
1059
|
+
args: TokenTimeSeriesArgs & { bucket_size: string },
|
|
1060
|
+
): Promise<OhlcvResponse> {
|
|
1061
|
+
return this.tokensAPI.getTokenOhlcv(chain, address, args)
|
|
1062
|
+
}
|
|
1063
|
+
|
|
1064
|
+
/**
|
|
1065
|
+
* Fetch recent swap activity for a token.
|
|
1066
|
+
*/
|
|
1067
|
+
public async getTokenActivity(
|
|
1068
|
+
chain: Chain,
|
|
1069
|
+
address: string,
|
|
1070
|
+
args?: TokenActivityArgs,
|
|
1071
|
+
): Promise<TokenSwapActivityPaginatedResponse> {
|
|
1072
|
+
return this.tokensAPI.getTokenActivity(chain, address, args)
|
|
1073
|
+
}
|
|
1074
|
+
|
|
1075
|
+
/**
|
|
1076
|
+
* Fetch multiple NFTs in a single request.
|
|
1077
|
+
*/
|
|
1078
|
+
public async getNFTsBatch(
|
|
1079
|
+
request: BatchNftsRequest,
|
|
1080
|
+
): Promise<NftBatchResponse> {
|
|
1081
|
+
return this.nftsAPI.getNFTsBatch(request)
|
|
1082
|
+
}
|
|
1083
|
+
|
|
1084
|
+
/**
|
|
1085
|
+
* Fetch owners of an NFT.
|
|
1086
|
+
*/
|
|
1087
|
+
public async getNFTOwners(
|
|
1088
|
+
address: string,
|
|
1089
|
+
identifier: string,
|
|
1090
|
+
chain: Chain = this.chain,
|
|
1091
|
+
args?: NFTOwnersArgs,
|
|
1092
|
+
): Promise<OwnersPaginatedResponse> {
|
|
1093
|
+
return this.nftsAPI.getNFTOwners(address, identifier, chain, args)
|
|
1094
|
+
}
|
|
1095
|
+
|
|
1096
|
+
/**
|
|
1097
|
+
* Fetch analytics (historical sale points) for an NFT.
|
|
1098
|
+
*/
|
|
1099
|
+
public async getNFTAnalytics(
|
|
1100
|
+
address: string,
|
|
1101
|
+
identifier: string,
|
|
1102
|
+
chain: Chain = this.chain,
|
|
1103
|
+
): Promise<NftAnalyticsResponse> {
|
|
1104
|
+
return this.nftsAPI.getNFTAnalytics(address, identifier, chain)
|
|
1105
|
+
}
|
|
1106
|
+
|
|
1107
|
+
/**
|
|
1108
|
+
* Fetch multiple collections in a single request by slug.
|
|
1109
|
+
*/
|
|
1110
|
+
public async getCollectionsBatch(
|
|
1111
|
+
request: BatchCollectionsRequest,
|
|
1112
|
+
): Promise<CollectionBatchResponse> {
|
|
1113
|
+
return this.collectionsAPI.getCollectionsBatch(request)
|
|
1114
|
+
}
|
|
1115
|
+
|
|
1116
|
+
/**
|
|
1117
|
+
* Fetch top offers for a collection grouped by price level.
|
|
1118
|
+
*/
|
|
1119
|
+
public async getCollectionOfferAggregates(
|
|
1120
|
+
slug: string,
|
|
1121
|
+
args?: PaginatedAnalyticsArgs,
|
|
1122
|
+
): Promise<CollectionOfferAggregatesPaginatedResponse> {
|
|
1123
|
+
return this.collectionsAPI.getCollectionOfferAggregates(slug, args)
|
|
1124
|
+
}
|
|
1125
|
+
|
|
1126
|
+
/**
|
|
1127
|
+
* Fetch holders of a collection.
|
|
1128
|
+
*/
|
|
1129
|
+
public async getCollectionHolders(
|
|
1130
|
+
slug: string,
|
|
1131
|
+
args?: CollectionHoldersArgs,
|
|
1132
|
+
): Promise<CollectionHoldersPaginatedResponse> {
|
|
1133
|
+
return this.collectionsAPI.getCollectionHolders(slug, args)
|
|
1134
|
+
}
|
|
1135
|
+
|
|
1136
|
+
/**
|
|
1137
|
+
* Fetch the floor-price history of a collection.
|
|
1138
|
+
*/
|
|
1139
|
+
public async getCollectionFloorPrices(
|
|
1140
|
+
slug: string,
|
|
1141
|
+
args?: CollectionFloorPricesArgs,
|
|
1142
|
+
): Promise<FloorPriceHistoryResponse> {
|
|
1143
|
+
return this.collectionsAPI.getCollectionFloorPrices(slug, args)
|
|
1144
|
+
}
|
|
1145
|
+
|
|
1146
|
+
/**
|
|
1147
|
+
* Get ordered approval + sign actions to create one or more listings.
|
|
1148
|
+
*/
|
|
1149
|
+
public async createListingActions(
|
|
1150
|
+
request: CreateListingActionsRequest,
|
|
1151
|
+
): Promise<CreateListingActionsResponse> {
|
|
1152
|
+
return this.listingsAPI.createListingActions(request)
|
|
1153
|
+
}
|
|
1154
|
+
|
|
1155
|
+
/**
|
|
1156
|
+
* Build a deploy-contract transaction for a new drop.
|
|
1157
|
+
*/
|
|
1158
|
+
public async deployDropContract(
|
|
1159
|
+
request: DropDeployRequest,
|
|
1160
|
+
): Promise<DropDeployResponse> {
|
|
1161
|
+
return this.dropsAPI.deployDropContract(request)
|
|
1162
|
+
}
|
|
1163
|
+
|
|
1164
|
+
/**
|
|
1165
|
+
* Get the receipt of a previously submitted drop-deploy transaction.
|
|
1166
|
+
*/
|
|
1167
|
+
public async getDeployContractReceipt(
|
|
1168
|
+
chain: Chain,
|
|
1169
|
+
txHash: string,
|
|
1170
|
+
): Promise<DropDeployReceiptResponse> {
|
|
1171
|
+
return this.dropsAPI.getDeployReceipt(chain, txHash)
|
|
1172
|
+
}
|
|
1173
|
+
|
|
1174
|
+
/**
|
|
1175
|
+
* Build transactions to transfer NFTs or tokens between wallets.
|
|
1176
|
+
*/
|
|
1177
|
+
public async transferAssets(
|
|
1178
|
+
request: TransferRequest,
|
|
1179
|
+
): Promise<TransferResponse> {
|
|
1180
|
+
return this.assetsAPI.transferAssets(request)
|
|
1181
|
+
}
|
|
1182
|
+
|
|
1183
|
+
/**
|
|
1184
|
+
* Get portfolio stats (net worth, P&L) for an account.
|
|
1185
|
+
*/
|
|
1186
|
+
public async getPortfolioStats(
|
|
1187
|
+
address: string,
|
|
1188
|
+
args?: PortfolioArgs,
|
|
1189
|
+
): Promise<PortfolioStatsResponse> {
|
|
1190
|
+
return this.accountsAPI.getPortfolioStats(address, args)
|
|
1191
|
+
}
|
|
1192
|
+
|
|
1193
|
+
/**
|
|
1194
|
+
* Get portfolio net-worth history for an account.
|
|
1195
|
+
*/
|
|
1196
|
+
public async getPortfolioHistory(
|
|
1197
|
+
address: string,
|
|
1198
|
+
args?: PortfolioArgs,
|
|
1199
|
+
): Promise<PortfolioHistoryResponse> {
|
|
1200
|
+
return this.accountsAPI.getPortfolioHistory(address, args)
|
|
1201
|
+
}
|
|
1202
|
+
|
|
1203
|
+
/**
|
|
1204
|
+
* Get offers received by an account.
|
|
1205
|
+
*/
|
|
1206
|
+
public async getProfileOffersReceived(
|
|
1207
|
+
address: string,
|
|
1208
|
+
args?: ProfileOrdersArgs,
|
|
1209
|
+
): Promise<ProfileOffersResponse> {
|
|
1210
|
+
return this.accountsAPI.getProfileOffersReceived(address, args)
|
|
1211
|
+
}
|
|
1212
|
+
|
|
1213
|
+
/**
|
|
1214
|
+
* Get active offers made by an account.
|
|
1215
|
+
*/
|
|
1216
|
+
public async getProfileOffers(
|
|
1217
|
+
address: string,
|
|
1218
|
+
args?: ProfileOrdersArgs,
|
|
1219
|
+
): Promise<ProfileOffersResponse> {
|
|
1220
|
+
return this.accountsAPI.getProfileOffers(address, args)
|
|
1221
|
+
}
|
|
1222
|
+
|
|
1223
|
+
/**
|
|
1224
|
+
* Get active listings for an account.
|
|
1225
|
+
*/
|
|
1226
|
+
public async getProfileListings(
|
|
1227
|
+
address: string,
|
|
1228
|
+
args?: ProfileOrdersArgs,
|
|
1229
|
+
): Promise<ProfileListingsResponse> {
|
|
1230
|
+
return this.accountsAPI.getProfileListings(address, args)
|
|
1231
|
+
}
|
|
1232
|
+
|
|
1233
|
+
/**
|
|
1234
|
+
* Get items favorited by an account.
|
|
1235
|
+
*/
|
|
1236
|
+
public async getProfileFavorites(
|
|
1237
|
+
address: string,
|
|
1238
|
+
args?: ProfileFavoritesArgs,
|
|
1239
|
+
): Promise<ProfileFavoritesResponse> {
|
|
1240
|
+
return this.accountsAPI.getProfileFavorites(address, args)
|
|
1241
|
+
}
|
|
1242
|
+
|
|
1243
|
+
/**
|
|
1244
|
+
* Get collections owned by an account.
|
|
1245
|
+
*/
|
|
1246
|
+
public async getProfileCollections(
|
|
1247
|
+
address: string,
|
|
1248
|
+
args?: ProfileCollectionsArgs,
|
|
1249
|
+
): Promise<ProfileCollectionsResponse> {
|
|
1250
|
+
return this.accountsAPI.getProfileCollections(address, args)
|
|
1251
|
+
}
|
|
1252
|
+
|
|
1015
1253
|
/**
|
|
1016
1254
|
* Generic fetch method for any API endpoint with automatic rate limit retry
|
|
1017
1255
|
* @param apiPath Path to URL endpoint under API
|
package/src/api/apiPaths.ts
CHANGED
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
import type { OrderProtocol } from "../orders/types"
|
|
2
|
-
import {
|
|
2
|
+
import type { Chain } from "../types"
|
|
3
3
|
|
|
4
4
|
/** Base path prefix for all OpenSea API v2 endpoints. */
|
|
5
5
|
export const API_V2_PREFIX = "/api/v2"
|
|
6
6
|
|
|
7
|
-
export const
|
|
8
|
-
chain
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
) => {
|
|
12
|
-
|
|
13
|
-
return `${API_V2_PREFIX}/orders/${chain}/${protocol}/${sidePath}`
|
|
7
|
+
export const getPostListingPath = (chain: Chain, protocol: OrderProtocol) => {
|
|
8
|
+
return `${API_V2_PREFIX}/orders/${chain}/${protocol}/listings`
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export const getPostOfferPath = (chain: Chain, protocol: OrderProtocol) => {
|
|
12
|
+
return `${API_V2_PREFIX}/orders/${chain}/${protocol}/offers`
|
|
14
13
|
}
|
|
15
14
|
|
|
16
15
|
export const getAllOffersAPIPath = (collectionSlug: string) => {
|
|
@@ -119,6 +118,25 @@ export const getTraitOffersPath = (collectionSlug: string) => {
|
|
|
119
118
|
return `${API_V2_PREFIX}/offers/collection/${collectionSlug}/traits`
|
|
120
119
|
}
|
|
121
120
|
|
|
121
|
+
export const getOffersByNFTPath = (
|
|
122
|
+
collectionSlug: string,
|
|
123
|
+
identifier: string | number,
|
|
124
|
+
) => {
|
|
125
|
+
return `${API_V2_PREFIX}/offers/collection/${collectionSlug}/nfts/${identifier}`
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
export const getSweepListingsPath = () => {
|
|
129
|
+
return `${API_V2_PREFIX}/listings/sweep`
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
export const getSwapExecutePath = () => {
|
|
133
|
+
return `${API_V2_PREFIX}/swap/execute`
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
export const getTransactionReceiptPath = () => {
|
|
137
|
+
return `${API_V2_PREFIX}/transactions/receipt`
|
|
138
|
+
}
|
|
139
|
+
|
|
122
140
|
export const getEventsAPIPath = () => {
|
|
123
141
|
return `${API_V2_PREFIX}/events`
|
|
124
142
|
}
|
|
@@ -238,3 +256,115 @@ export const getCrossChainFulfillmentDataPath = () => {
|
|
|
238
256
|
export const getInstantApiKeyPath = () => {
|
|
239
257
|
return `${API_V2_PREFIX}/auth/keys`
|
|
240
258
|
}
|
|
259
|
+
|
|
260
|
+
// ── Batch lookups ───────────────────────────────────────────────────
|
|
261
|
+
|
|
262
|
+
export const getBatchTokensPath = () => {
|
|
263
|
+
return `${API_V2_PREFIX}/tokens/batch`
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
export const getBatchNFTsPath = () => {
|
|
267
|
+
return `${API_V2_PREFIX}/nfts/batch`
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
export const getBatchCollectionsPath = () => {
|
|
271
|
+
return `${API_V2_PREFIX}/collections/batch`
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
// ── Listings actions ────────────────────────────────────────────────
|
|
275
|
+
|
|
276
|
+
export const getCreateListingActionsPath = () => {
|
|
277
|
+
return `${API_V2_PREFIX}/listings/actions`
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
// ── Drops deploy ────────────────────────────────────────────────────
|
|
281
|
+
|
|
282
|
+
export const getDeployDropPath = () => {
|
|
283
|
+
return `${API_V2_PREFIX}/drops/deploy`
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
export const getDeployDropReceiptPath = (chain: Chain, txHash: string) => {
|
|
287
|
+
return `${API_V2_PREFIX}/drops/deploy/${chain}/${txHash}/receipt`
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
// ── Assets transfer ─────────────────────────────────────────────────
|
|
291
|
+
|
|
292
|
+
export const getTransferAssetsPath = () => {
|
|
293
|
+
return `${API_V2_PREFIX}/assets/transfer`
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
// ── Collection analytics ────────────────────────────────────────────
|
|
297
|
+
|
|
298
|
+
export const getCollectionOfferAggregatesPath = (slug: string) => {
|
|
299
|
+
return `${API_V2_PREFIX}/collections/${slug}/offer_aggregates`
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
export const getCollectionHoldersPath = (slug: string) => {
|
|
303
|
+
return `${API_V2_PREFIX}/collections/${slug}/holders`
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
export const getCollectionFloorPricesPath = (slug: string) => {
|
|
307
|
+
return `${API_V2_PREFIX}/collections/${slug}/floor_prices`
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
// ── Token analytics ─────────────────────────────────────────────────
|
|
311
|
+
|
|
312
|
+
export const getTokenPriceHistoryPath = (chain: Chain, address: string) => {
|
|
313
|
+
return `${API_V2_PREFIX}/chain/${chain}/token/${address}/price_history`
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
export const getTokenOhlcvPath = (chain: Chain, address: string) => {
|
|
317
|
+
return `${API_V2_PREFIX}/chain/${chain}/token/${address}/ohlcv`
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
export const getTokenActivityPath = (chain: Chain, address: string) => {
|
|
321
|
+
return `${API_V2_PREFIX}/chain/${chain}/token/${address}/activity`
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
// ── NFT analytics ───────────────────────────────────────────────────
|
|
325
|
+
|
|
326
|
+
export const getNFTOwnersPath = (
|
|
327
|
+
chain: Chain,
|
|
328
|
+
address: string,
|
|
329
|
+
identifier: string,
|
|
330
|
+
) => {
|
|
331
|
+
return `${API_V2_PREFIX}/chain/${chain}/contract/${address}/nfts/${identifier}/owners`
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
export const getNFTAnalyticsPath = (
|
|
335
|
+
chain: Chain,
|
|
336
|
+
address: string,
|
|
337
|
+
identifier: string,
|
|
338
|
+
) => {
|
|
339
|
+
return `${API_V2_PREFIX}/chain/${chain}/contract/${address}/nfts/${identifier}/analytics`
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
// ── Account portfolio / profile ─────────────────────────────────────
|
|
343
|
+
|
|
344
|
+
export const getPortfolioStatsPath = (address: string) => {
|
|
345
|
+
return `${API_V2_PREFIX}/account/${address}/portfolio`
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
export const getPortfolioHistoryPath = (address: string) => {
|
|
349
|
+
return `${API_V2_PREFIX}/account/${address}/portfolio/history`
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
export const getProfileOffersReceivedPath = (address: string) => {
|
|
353
|
+
return `${API_V2_PREFIX}/account/${address}/offers_received`
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
export const getProfileOffersPath = (address: string) => {
|
|
357
|
+
return `${API_V2_PREFIX}/account/${address}/offers`
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
export const getProfileListingsPath = (address: string) => {
|
|
361
|
+
return `${API_V2_PREFIX}/account/${address}/listings`
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
export const getProfileFavoritesPath = (address: string) => {
|
|
365
|
+
return `${API_V2_PREFIX}/account/${address}/favorites`
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
export const getProfileCollectionsPath = (address: string) => {
|
|
369
|
+
return `${API_V2_PREFIX}/account/${address}/collections`
|
|
370
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { getTransferAssetsPath } from "./apiPaths"
|
|
2
|
+
import type { Fetcher } from "./fetcher"
|
|
3
|
+
import type { TransferRequest, TransferResponse } from "./types"
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Asset transfer API operations.
|
|
7
|
+
*
|
|
8
|
+
* Returns ready-to-sign transaction data for moving NFTs or tokens from
|
|
9
|
+
* one wallet to another. The endpoint supports multi-asset transfers in
|
|
10
|
+
* a single request; the response is an ordered list of transactions to
|
|
11
|
+
* submit onchain.
|
|
12
|
+
*/
|
|
13
|
+
export class AssetsAPI {
|
|
14
|
+
constructor(private fetcher: Fetcher) {}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Build transactions to transfer one or more NFTs or fungible tokens.
|
|
18
|
+
*/
|
|
19
|
+
async transferAssets(request: TransferRequest): Promise<TransferResponse> {
|
|
20
|
+
return this.fetcher.post<TransferResponse>(getTransferAssetsPath(), request)
|
|
21
|
+
}
|
|
22
|
+
}
|