@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/accounts.ts
CHANGED
|
@@ -4,15 +4,36 @@ import {
|
|
|
4
4
|
getAccountPath,
|
|
5
5
|
getAccountTokensPath,
|
|
6
6
|
getPaymentTokenPath,
|
|
7
|
+
getPortfolioHistoryPath,
|
|
8
|
+
getPortfolioStatsPath,
|
|
9
|
+
getProfileCollectionsPath,
|
|
10
|
+
getProfileFavoritesPath,
|
|
11
|
+
getProfileListingsPath,
|
|
12
|
+
getProfileOffersPath,
|
|
13
|
+
getProfileOffersReceivedPath,
|
|
7
14
|
getResolveAccountPath,
|
|
8
15
|
} from "./apiPaths"
|
|
9
16
|
import type { Fetcher } from "./fetcher"
|
|
10
17
|
import type {
|
|
11
18
|
GetAccountTokensArgs,
|
|
12
19
|
GetAccountTokensResponse,
|
|
20
|
+
PortfolioArgs,
|
|
21
|
+
PortfolioHistoryResponse,
|
|
22
|
+
PortfolioStatsResponse,
|
|
23
|
+
ProfileCollectionsArgs,
|
|
24
|
+
ProfileCollectionsResponse,
|
|
25
|
+
ProfileFavoritesArgs,
|
|
26
|
+
ProfileFavoritesResponse,
|
|
27
|
+
ProfileListingsResponse,
|
|
28
|
+
ProfileOffersResponse,
|
|
29
|
+
ProfileOrdersArgs,
|
|
13
30
|
ResolveAccountResponse,
|
|
14
31
|
} from "./types"
|
|
15
32
|
|
|
33
|
+
function joinArray(value: string[] | undefined): string | undefined {
|
|
34
|
+
return value && value.length > 0 ? value.join(",") : undefined
|
|
35
|
+
}
|
|
36
|
+
|
|
16
37
|
/**
|
|
17
38
|
* Account and payment token related API operations
|
|
18
39
|
*/
|
|
@@ -66,4 +87,113 @@ export class AccountsAPI {
|
|
|
66
87
|
)
|
|
67
88
|
return response
|
|
68
89
|
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Get portfolio stats (net worth, P&L) for an account.
|
|
93
|
+
*/
|
|
94
|
+
async getPortfolioStats(
|
|
95
|
+
address: string,
|
|
96
|
+
args?: PortfolioArgs,
|
|
97
|
+
): Promise<PortfolioStatsResponse> {
|
|
98
|
+
return this.fetcher.get<PortfolioStatsResponse>(
|
|
99
|
+
getPortfolioStatsPath(address),
|
|
100
|
+
args,
|
|
101
|
+
)
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Get portfolio net-worth history for an account.
|
|
106
|
+
*/
|
|
107
|
+
async getPortfolioHistory(
|
|
108
|
+
address: string,
|
|
109
|
+
args?: PortfolioArgs,
|
|
110
|
+
): Promise<PortfolioHistoryResponse> {
|
|
111
|
+
return this.fetcher.get<PortfolioHistoryResponse>(
|
|
112
|
+
getPortfolioHistoryPath(address),
|
|
113
|
+
args,
|
|
114
|
+
)
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Get offers received by an account, scoped by collection/chain.
|
|
119
|
+
*/
|
|
120
|
+
async getProfileOffersReceived(
|
|
121
|
+
address: string,
|
|
122
|
+
args?: ProfileOrdersArgs,
|
|
123
|
+
): Promise<ProfileOffersResponse> {
|
|
124
|
+
return this.fetcher.get<ProfileOffersResponse>(
|
|
125
|
+
getProfileOffersReceivedPath(address),
|
|
126
|
+
{
|
|
127
|
+
...args,
|
|
128
|
+
collection_slugs: joinArray(args?.collection_slugs),
|
|
129
|
+
chains: joinArray(args?.chains),
|
|
130
|
+
},
|
|
131
|
+
)
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Get active offers made by an account.
|
|
136
|
+
*/
|
|
137
|
+
async getProfileOffers(
|
|
138
|
+
address: string,
|
|
139
|
+
args?: ProfileOrdersArgs,
|
|
140
|
+
): Promise<ProfileOffersResponse> {
|
|
141
|
+
return this.fetcher.get<ProfileOffersResponse>(
|
|
142
|
+
getProfileOffersPath(address),
|
|
143
|
+
{
|
|
144
|
+
...args,
|
|
145
|
+
collection_slugs: joinArray(args?.collection_slugs),
|
|
146
|
+
chains: joinArray(args?.chains),
|
|
147
|
+
},
|
|
148
|
+
)
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Get active listings for an account.
|
|
153
|
+
*/
|
|
154
|
+
async getProfileListings(
|
|
155
|
+
address: string,
|
|
156
|
+
args?: ProfileOrdersArgs,
|
|
157
|
+
): Promise<ProfileListingsResponse> {
|
|
158
|
+
return this.fetcher.get<ProfileListingsResponse>(
|
|
159
|
+
getProfileListingsPath(address),
|
|
160
|
+
{
|
|
161
|
+
...args,
|
|
162
|
+
collection_slugs: joinArray(args?.collection_slugs),
|
|
163
|
+
chains: joinArray(args?.chains),
|
|
164
|
+
},
|
|
165
|
+
)
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* Get items favorited by an account.
|
|
170
|
+
*/
|
|
171
|
+
async getProfileFavorites(
|
|
172
|
+
address: string,
|
|
173
|
+
args?: ProfileFavoritesArgs,
|
|
174
|
+
): Promise<ProfileFavoritesResponse> {
|
|
175
|
+
return this.fetcher.get<ProfileFavoritesResponse>(
|
|
176
|
+
getProfileFavoritesPath(address),
|
|
177
|
+
{
|
|
178
|
+
...args,
|
|
179
|
+
chains: joinArray(args?.chains),
|
|
180
|
+
},
|
|
181
|
+
)
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* Get collections owned by an account.
|
|
186
|
+
*/
|
|
187
|
+
async getProfileCollections(
|
|
188
|
+
address: string,
|
|
189
|
+
args?: ProfileCollectionsArgs,
|
|
190
|
+
): Promise<ProfileCollectionsResponse> {
|
|
191
|
+
return this.fetcher.get<ProfileCollectionsResponse>(
|
|
192
|
+
getProfileCollectionsPath(address),
|
|
193
|
+
{
|
|
194
|
+
...args,
|
|
195
|
+
chains: joinArray(args?.chains),
|
|
196
|
+
},
|
|
197
|
+
)
|
|
198
|
+
}
|
|
69
199
|
}
|
package/src/api/api.ts
CHANGED
|
@@ -14,6 +14,7 @@ import {
|
|
|
14
14
|
import { executeWithRateLimit } from "../utils/rateLimit"
|
|
15
15
|
import { AccountsAPI } from "./accounts"
|
|
16
16
|
import { getInstantApiKeyPath } from "./apiPaths"
|
|
17
|
+
import { AssetsAPI } from "./assets"
|
|
17
18
|
import { ChainsAPI } from "./chains"
|
|
18
19
|
import { CollectionsAPI } from "./collections"
|
|
19
20
|
import { DropsAPI } from "./drops"
|
|
@@ -26,14 +27,28 @@ import { SearchAPI } from "./search"
|
|
|
26
27
|
import { TokensAPI } from "./tokens"
|
|
27
28
|
import { TransactionsAPI } from "./transactions"
|
|
28
29
|
import {
|
|
30
|
+
type BatchCollectionsRequest,
|
|
31
|
+
type BatchNftsRequest,
|
|
32
|
+
type BatchTokensRequest,
|
|
29
33
|
type BuildOfferResponse,
|
|
30
34
|
type CancelOrderResponse,
|
|
35
|
+
type CollectionBatchResponse,
|
|
36
|
+
type CollectionFloorPricesArgs,
|
|
37
|
+
type CollectionHoldersArgs,
|
|
38
|
+
type CollectionHoldersPaginatedResponse,
|
|
31
39
|
type CollectionOffer,
|
|
40
|
+
type CollectionOfferAggregatesPaginatedResponse,
|
|
32
41
|
CollectionOrderByOption,
|
|
42
|
+
type CreateListingActionsRequest,
|
|
43
|
+
type CreateListingActionsResponse,
|
|
33
44
|
type CrossChainFulfillmentRequest,
|
|
34
45
|
type CrossChainFulfillmentResponse,
|
|
46
|
+
type DropDeployReceiptResponse,
|
|
47
|
+
type DropDeployRequest,
|
|
48
|
+
type DropDeployResponse,
|
|
35
49
|
type DropMintRequest,
|
|
36
50
|
type DropMintResponse,
|
|
51
|
+
type FloorPriceHistoryResponse,
|
|
37
52
|
type GetAccountTokensArgs,
|
|
38
53
|
type GetAccountTokensResponse,
|
|
39
54
|
type GetBestListingResponse,
|
|
@@ -67,7 +82,24 @@ import {
|
|
|
67
82
|
type GetTrendingTokensResponse,
|
|
68
83
|
type Listing,
|
|
69
84
|
type ListNFTsResponse,
|
|
85
|
+
type NFTOwnersArgs,
|
|
86
|
+
type NftAnalyticsResponse,
|
|
87
|
+
type NftBatchResponse,
|
|
70
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,
|
|
71
103
|
type RequestInstantApiKeyResponse,
|
|
72
104
|
type ResolveAccountResponse,
|
|
73
105
|
type SearchArgs,
|
|
@@ -76,9 +108,15 @@ import {
|
|
|
76
108
|
type SwapExecuteResponse,
|
|
77
109
|
type SweepCollectionRequest,
|
|
78
110
|
type SweepCollectionResponse,
|
|
111
|
+
type TokenActivityArgs,
|
|
112
|
+
type TokenBatchResponse,
|
|
113
|
+
type TokenSwapActivityPaginatedResponse,
|
|
114
|
+
type TokenTimeSeriesArgs,
|
|
79
115
|
type TraitFilter,
|
|
80
116
|
type TransactionReceiptRequest,
|
|
81
117
|
type TransactionReceiptResponse,
|
|
118
|
+
type TransferRequest,
|
|
119
|
+
type TransferResponse,
|
|
82
120
|
type ValidateMetadataResponse,
|
|
83
121
|
} from "./types"
|
|
84
122
|
|
|
@@ -116,6 +154,7 @@ export class OpenSeaAPI {
|
|
|
116
154
|
private chainsAPI: ChainsAPI
|
|
117
155
|
private dropsAPI: DropsAPI
|
|
118
156
|
private transactionsAPI: TransactionsAPI
|
|
157
|
+
private assetsAPI: AssetsAPI
|
|
119
158
|
|
|
120
159
|
/**
|
|
121
160
|
* Create an instance of the OpenSeaAPI
|
|
@@ -154,6 +193,7 @@ export class OpenSeaAPI {
|
|
|
154
193
|
this.chainsAPI = new ChainsAPI(fetcher)
|
|
155
194
|
this.dropsAPI = new DropsAPI(fetcher)
|
|
156
195
|
this.transactionsAPI = new TransactionsAPI(fetcher)
|
|
196
|
+
this.assetsAPI = new AssetsAPI(fetcher)
|
|
157
197
|
}
|
|
158
198
|
|
|
159
199
|
/**
|
|
@@ -980,6 +1020,236 @@ export class OpenSeaAPI {
|
|
|
980
1020
|
return this.nftsAPI.getNFTMetadata(address, tokenId, chain)
|
|
981
1021
|
}
|
|
982
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
|
+
|
|
983
1253
|
/**
|
|
984
1254
|
* Generic fetch method for any API endpoint with automatic rate limit retry
|
|
985
1255
|
* @param apiPath Path to URL endpoint under API
|
package/src/api/apiPaths.ts
CHANGED
|
@@ -256,3 +256,115 @@ export const getCrossChainFulfillmentDataPath = () => {
|
|
|
256
256
|
export const getInstantApiKeyPath = () => {
|
|
257
257
|
return `${API_V2_PREFIX}/auth/keys`
|
|
258
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
|
+
}
|
package/src/api/collections.ts
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import type { Chain, OpenSeaCollection, OpenSeaCollectionStats } from "../types"
|
|
2
2
|
import { collectionFromJSON } from "../utils/converters"
|
|
3
3
|
import {
|
|
4
|
+
getBatchCollectionsPath,
|
|
5
|
+
getCollectionFloorPricesPath,
|
|
6
|
+
getCollectionHoldersPath,
|
|
7
|
+
getCollectionOfferAggregatesPath,
|
|
4
8
|
getCollectionPath,
|
|
5
9
|
getCollectionStatsPath,
|
|
6
10
|
getCollectionsPath,
|
|
@@ -10,7 +14,14 @@ import {
|
|
|
10
14
|
} from "./apiPaths"
|
|
11
15
|
import type { Fetcher } from "./fetcher"
|
|
12
16
|
import {
|
|
17
|
+
type BatchCollectionsRequest,
|
|
18
|
+
type CollectionBatchResponse,
|
|
19
|
+
type CollectionFloorPricesArgs,
|
|
20
|
+
type CollectionHoldersArgs,
|
|
21
|
+
type CollectionHoldersPaginatedResponse,
|
|
22
|
+
type CollectionOfferAggregatesPaginatedResponse,
|
|
13
23
|
CollectionOrderByOption,
|
|
24
|
+
type FloorPriceHistoryResponse,
|
|
14
25
|
type GetCollectionResponse,
|
|
15
26
|
type GetCollectionsArgs,
|
|
16
27
|
type GetCollectionsPaginatedResponse,
|
|
@@ -18,6 +29,7 @@ import {
|
|
|
18
29
|
type GetTopCollectionsArgs,
|
|
19
30
|
type GetTraitsResponse,
|
|
20
31
|
type GetTrendingCollectionsArgs,
|
|
32
|
+
type PaginatedAnalyticsArgs,
|
|
21
33
|
} from "./types"
|
|
22
34
|
|
|
23
35
|
/**
|
|
@@ -117,4 +129,57 @@ export class CollectionsAPI {
|
|
|
117
129
|
)
|
|
118
130
|
return response
|
|
119
131
|
}
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Fetch multiple collections in a single request by slug.
|
|
135
|
+
*/
|
|
136
|
+
async getCollectionsBatch(
|
|
137
|
+
request: BatchCollectionsRequest,
|
|
138
|
+
): Promise<CollectionBatchResponse> {
|
|
139
|
+
return this.fetcher.post<CollectionBatchResponse>(
|
|
140
|
+
getBatchCollectionsPath(),
|
|
141
|
+
request,
|
|
142
|
+
)
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Fetch aggregated offer information for a collection — top offers grouped
|
|
147
|
+
* by price level. Useful for displaying offer-book depth.
|
|
148
|
+
*/
|
|
149
|
+
async getCollectionOfferAggregates(
|
|
150
|
+
slug: string,
|
|
151
|
+
args?: PaginatedAnalyticsArgs,
|
|
152
|
+
): Promise<CollectionOfferAggregatesPaginatedResponse> {
|
|
153
|
+
return this.fetcher.get<CollectionOfferAggregatesPaginatedResponse>(
|
|
154
|
+
getCollectionOfferAggregatesPath(slug),
|
|
155
|
+
args,
|
|
156
|
+
)
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* Fetch holders of a collection, ranked by quantity owned. Optionally
|
|
161
|
+
* filter to a single owner via `args.owned_by`.
|
|
162
|
+
*/
|
|
163
|
+
async getCollectionHolders(
|
|
164
|
+
slug: string,
|
|
165
|
+
args?: CollectionHoldersArgs,
|
|
166
|
+
): Promise<CollectionHoldersPaginatedResponse> {
|
|
167
|
+
return this.fetcher.get<CollectionHoldersPaginatedResponse>(
|
|
168
|
+
getCollectionHoldersPath(slug),
|
|
169
|
+
args,
|
|
170
|
+
)
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* Fetch the floor-price history of a collection.
|
|
175
|
+
*/
|
|
176
|
+
async getCollectionFloorPrices(
|
|
177
|
+
slug: string,
|
|
178
|
+
args?: CollectionFloorPricesArgs,
|
|
179
|
+
): Promise<FloorPriceHistoryResponse> {
|
|
180
|
+
return this.fetcher.get<FloorPriceHistoryResponse>(
|
|
181
|
+
getCollectionFloorPricesPath(slug),
|
|
182
|
+
args,
|
|
183
|
+
)
|
|
184
|
+
}
|
|
120
185
|
}
|