@opensea/sdk 10.4.0 → 11.0.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.
Files changed (86) hide show
  1. package/lib/api/accounts.d.ts +29 -1
  2. package/lib/api/accounts.js +72 -5
  3. package/lib/api/accounts.js.map +1 -1
  4. package/lib/api/api.d.ts +116 -9
  5. package/lib/api/api.js +186 -17
  6. package/lib/api/api.js.map +1 -1
  7. package/lib/api/apiPaths.d.ts +22 -0
  8. package/lib/api/apiPaths.js +97 -1
  9. package/lib/api/apiPaths.js.map +1 -1
  10. package/lib/api/assets.d.ts +18 -0
  11. package/lib/api/assets.js +26 -0
  12. package/lib/api/assets.js.map +1 -0
  13. package/lib/api/collections.d.ts +19 -1
  14. package/lib/api/collections.js +33 -15
  15. package/lib/api/collections.js.map +1 -1
  16. package/lib/api/drops.d.ts +12 -1
  17. package/lib/api/drops.js +14 -0
  18. package/lib/api/drops.js.map +1 -1
  19. package/lib/api/fetcher.d.ts +35 -5
  20. package/lib/api/listings.d.ts +8 -1
  21. package/lib/api/listings.js +12 -3
  22. package/lib/api/listings.js.map +1 -1
  23. package/lib/api/nfts.d.ts +15 -2
  24. package/lib/api/nfts.js +21 -5
  25. package/lib/api/nfts.js.map +1 -1
  26. package/lib/api/offers.d.ts +11 -0
  27. package/lib/api/offers.js +14 -11
  28. package/lib/api/offers.js.map +1 -1
  29. package/lib/api/orders.d.ts +16 -1
  30. package/lib/api/orders.js +17 -3
  31. package/lib/api/orders.js.map +1 -1
  32. package/lib/api/tokens.d.ts +22 -1
  33. package/lib/api/tokens.js +26 -0
  34. package/lib/api/tokens.js.map +1 -1
  35. package/lib/api/types.d.ts +296 -341
  36. package/lib/api/types.js +2 -1
  37. package/lib/api/types.js.map +1 -1
  38. package/lib/orders/types.d.ts +2 -2
  39. package/lib/orders/utils.d.ts +53 -13
  40. package/lib/orders/utils.js +33 -50
  41. package/lib/orders/utils.js.map +1 -1
  42. package/lib/sdk/base.d.ts +11 -4
  43. package/lib/sdk/base.js +4 -4
  44. package/lib/sdk/base.js.map +1 -1
  45. package/lib/sdk/cancellation.d.ts +3 -1
  46. package/lib/sdk/cancellation.js +12 -6
  47. package/lib/sdk/cancellation.js.map +1 -1
  48. package/lib/sdk/fulfillment.js +7 -4
  49. package/lib/sdk/fulfillment.js.map +1 -1
  50. package/lib/sdk/orders.js +1 -1
  51. package/lib/sdk/orders.js.map +1 -1
  52. package/lib/types.d.ts +22 -122
  53. package/lib/types.js.map +1 -1
  54. package/lib/utils/case.d.ts +63 -0
  55. package/lib/utils/case.js +83 -0
  56. package/lib/utils/case.js.map +1 -0
  57. package/lib/utils/utils.d.ts +0 -1
  58. package/lib/utils/utils.js +0 -1
  59. package/lib/utils/utils.js.map +1 -1
  60. package/package.json +2 -2
  61. package/src/api/accounts.ts +141 -5
  62. package/src/api/api.ts +328 -23
  63. package/src/api/apiPaths.ts +112 -0
  64. package/src/api/assets.ts +22 -0
  65. package/src/api/collections.ts +71 -20
  66. package/src/api/drops.ts +34 -1
  67. package/src/api/fetcher.ts +41 -6
  68. package/src/api/listings.ts +21 -3
  69. package/src/api/nfts.ts +47 -7
  70. package/src/api/offers.ts +17 -10
  71. package/src/api/orders.ts +29 -5
  72. package/src/api/tokens.ts +65 -0
  73. package/src/api/types.ts +382 -354
  74. package/src/orders/types.ts +2 -2
  75. package/src/orders/utils.ts +57 -79
  76. package/src/sdk/base.ts +4 -4
  77. package/src/sdk/cancellation.ts +16 -6
  78. package/src/sdk/fulfillment.ts +7 -6
  79. package/src/sdk/orders.ts +1 -1
  80. package/src/types.ts +33 -120
  81. package/src/utils/case.ts +150 -0
  82. package/src/utils/utils.ts +0 -1
  83. package/lib/utils/converters.d.ts +0 -37
  84. package/lib/utils/converters.js +0 -137
  85. package/lib/utils/converters.js.map +0 -1
  86. package/src/utils/converters.ts +0 -145
package/src/api/api.ts CHANGED
@@ -11,13 +11,20 @@ import {
11
11
  type OrderSide,
12
12
  type RequestOptions,
13
13
  } from "../types"
14
+ import {
15
+ type Camelize,
16
+ camelizeKeysDeep,
17
+ snakeizeKeysDeep,
18
+ } from "../utils/case"
14
19
  import { executeWithRateLimit } from "../utils/rateLimit"
15
20
  import { AccountsAPI } from "./accounts"
16
21
  import { getInstantApiKeyPath } from "./apiPaths"
22
+ import { AssetsAPI } from "./assets"
17
23
  import { ChainsAPI } from "./chains"
18
24
  import { CollectionsAPI } from "./collections"
19
25
  import { DropsAPI } from "./drops"
20
26
  import { EventsAPI } from "./events"
27
+ import type { PostOptions } from "./fetcher"
21
28
  import { ListingsAPI } from "./listings"
22
29
  import { NFTsAPI } from "./nfts"
23
30
  import { OffersAPI } from "./offers"
@@ -26,14 +33,28 @@ import { SearchAPI } from "./search"
26
33
  import { TokensAPI } from "./tokens"
27
34
  import { TransactionsAPI } from "./transactions"
28
35
  import {
36
+ type BatchCollectionsRequest,
37
+ type BatchNftsRequest,
38
+ type BatchTokensRequest,
29
39
  type BuildOfferResponse,
30
40
  type CancelOrderResponse,
41
+ type CollectionBatchResponse,
42
+ type CollectionFloorPricesArgs,
43
+ type CollectionHoldersArgs,
44
+ type CollectionHoldersPaginatedResponse,
31
45
  type CollectionOffer,
46
+ type CollectionOfferAggregatesPaginatedResponse,
32
47
  CollectionOrderByOption,
48
+ type CreateListingActionsRequest,
49
+ type CreateListingActionsResponse,
33
50
  type CrossChainFulfillmentRequest,
34
51
  type CrossChainFulfillmentResponse,
52
+ type DropDeployReceiptResponse,
53
+ type DropDeployRequest,
54
+ type DropDeployResponse,
35
55
  type DropMintRequest,
36
56
  type DropMintResponse,
57
+ type FloorPriceHistoryResponse,
37
58
  type GetAccountTokensArgs,
38
59
  type GetAccountTokensResponse,
39
60
  type GetBestListingResponse,
@@ -67,7 +88,24 @@ import {
67
88
  type GetTrendingTokensResponse,
68
89
  type Listing,
69
90
  type ListNFTsResponse,
91
+ type NFTOwnersArgs,
92
+ type NftAnalyticsResponse,
93
+ type NftBatchResponse,
70
94
  type Offer,
95
+ type OhlcvResponse,
96
+ type OwnersPaginatedResponse,
97
+ type PaginatedAnalyticsArgs,
98
+ type PortfolioArgs,
99
+ type PortfolioHistoryResponse,
100
+ type PortfolioStatsResponse,
101
+ type PriceHistoryResponse,
102
+ type ProfileCollectionsArgs,
103
+ type ProfileCollectionsResponse,
104
+ type ProfileFavoritesArgs,
105
+ type ProfileFavoritesResponse,
106
+ type ProfileListingsResponse,
107
+ type ProfileOffersResponse,
108
+ type ProfileOrdersArgs,
71
109
  type RequestInstantApiKeyResponse,
72
110
  type ResolveAccountResponse,
73
111
  type SearchArgs,
@@ -76,9 +114,15 @@ import {
76
114
  type SwapExecuteResponse,
77
115
  type SweepCollectionRequest,
78
116
  type SweepCollectionResponse,
117
+ type TokenActivityArgs,
118
+ type TokenBatchResponse,
119
+ type TokenSwapActivityPaginatedResponse,
120
+ type TokenTimeSeriesArgs,
79
121
  type TraitFilter,
80
122
  type TransactionReceiptRequest,
81
123
  type TransactionReceiptResponse,
124
+ type TransferRequest,
125
+ type TransferResponse,
82
126
  type ValidateMetadataResponse,
83
127
  } from "./types"
84
128
 
@@ -116,6 +160,7 @@ export class OpenSeaAPI {
116
160
  private chainsAPI: ChainsAPI
117
161
  private dropsAPI: DropsAPI
118
162
  private transactionsAPI: TransactionsAPI
163
+ private assetsAPI: AssetsAPI
119
164
 
120
165
  /**
121
166
  * Create an instance of the OpenSeaAPI
@@ -154,6 +199,7 @@ export class OpenSeaAPI {
154
199
  this.chainsAPI = new ChainsAPI(fetcher)
155
200
  this.dropsAPI = new DropsAPI(fetcher)
156
201
  this.transactionsAPI = new TransactionsAPI(fetcher)
202
+ this.assetsAPI = new AssetsAPI(fetcher)
157
203
  }
158
204
 
159
205
  /**
@@ -333,7 +379,7 @@ export class OpenSeaAPI {
333
379
  unitsToFill?: string,
334
380
  recipientAddress?: string,
335
381
  includeOptionalCreatorFees: boolean = false,
336
- ): Promise<FulfillmentDataResponse> {
382
+ ): Promise<Camelize<FulfillmentDataResponse>> {
337
383
  return this.ordersAPI.generateFulfillmentData(
338
384
  fulfillerAddress,
339
385
  orderHash,
@@ -597,7 +643,7 @@ export class OpenSeaAPI {
597
643
  address: string,
598
644
  identifier: string,
599
645
  chain: Chain = this.chain,
600
- ): Promise<Response> {
646
+ ): Promise<Record<string, unknown>> {
601
647
  return this.nftsAPI.refreshNFTMetadata(address, identifier, chain)
602
648
  }
603
649
 
@@ -980,6 +1026,236 @@ export class OpenSeaAPI {
980
1026
  return this.nftsAPI.getNFTMetadata(address, tokenId, chain)
981
1027
  }
982
1028
 
1029
+ /**
1030
+ * Fetch multiple tokens in a single request.
1031
+ * @param request Batch request listing chain + contract address pairs.
1032
+ * @returns The {@link TokenBatchResponse} with detailed token info.
1033
+ */
1034
+ public async getTokensBatch(
1035
+ request: BatchTokensRequest,
1036
+ ): Promise<TokenBatchResponse> {
1037
+ return this.tokensAPI.getTokensBatch(request)
1038
+ }
1039
+
1040
+ /**
1041
+ * Fetch the price history of a token.
1042
+ * @param chain Chain the token lives on.
1043
+ * @param address Token contract address.
1044
+ * @param args Time-series window — `start_time` required, `end_time` defaults to now.
1045
+ * @returns The {@link PriceHistoryResponse} returned by the API.
1046
+ */
1047
+ public async getTokenPriceHistory(
1048
+ chain: Chain,
1049
+ address: string,
1050
+ args: TokenTimeSeriesArgs,
1051
+ ): Promise<PriceHistoryResponse> {
1052
+ return this.tokensAPI.getTokenPriceHistory(chain, address, args)
1053
+ }
1054
+
1055
+ /**
1056
+ * Fetch OHLCV candles for a token.
1057
+ * @param chain Chain the token lives on.
1058
+ * @param address Token contract address.
1059
+ * @param args Time-series window plus candle `bucketSize` (required).
1060
+ * @returns The {@link OhlcvResponse} returned by the API.
1061
+ */
1062
+ public async getTokenOhlcv(
1063
+ chain: Chain,
1064
+ address: string,
1065
+ args: TokenTimeSeriesArgs & { bucketSize: string },
1066
+ ): Promise<OhlcvResponse> {
1067
+ return this.tokensAPI.getTokenOhlcv(chain, address, args)
1068
+ }
1069
+
1070
+ /**
1071
+ * Fetch recent swap activity for a token.
1072
+ */
1073
+ public async getTokenActivity(
1074
+ chain: Chain,
1075
+ address: string,
1076
+ args?: TokenActivityArgs,
1077
+ ): Promise<TokenSwapActivityPaginatedResponse> {
1078
+ return this.tokensAPI.getTokenActivity(chain, address, args)
1079
+ }
1080
+
1081
+ /**
1082
+ * Fetch multiple NFTs in a single request.
1083
+ */
1084
+ public async getNFTsBatch(
1085
+ request: BatchNftsRequest,
1086
+ ): Promise<NftBatchResponse> {
1087
+ return this.nftsAPI.getNFTsBatch(request)
1088
+ }
1089
+
1090
+ /**
1091
+ * Fetch owners of an NFT.
1092
+ */
1093
+ public async getNFTOwners(
1094
+ address: string,
1095
+ identifier: string,
1096
+ chain: Chain = this.chain,
1097
+ args?: NFTOwnersArgs,
1098
+ ): Promise<OwnersPaginatedResponse> {
1099
+ return this.nftsAPI.getNFTOwners(address, identifier, chain, args)
1100
+ }
1101
+
1102
+ /**
1103
+ * Fetch analytics (historical sale points) for an NFT.
1104
+ */
1105
+ public async getNFTAnalytics(
1106
+ address: string,
1107
+ identifier: string,
1108
+ chain: Chain = this.chain,
1109
+ ): Promise<NftAnalyticsResponse> {
1110
+ return this.nftsAPI.getNFTAnalytics(address, identifier, chain)
1111
+ }
1112
+
1113
+ /**
1114
+ * Fetch multiple collections in a single request by slug.
1115
+ */
1116
+ public async getCollectionsBatch(
1117
+ request: BatchCollectionsRequest,
1118
+ ): Promise<CollectionBatchResponse> {
1119
+ return this.collectionsAPI.getCollectionsBatch(request)
1120
+ }
1121
+
1122
+ /**
1123
+ * Fetch top offers for a collection grouped by price level.
1124
+ */
1125
+ public async getCollectionOfferAggregates(
1126
+ slug: string,
1127
+ args?: PaginatedAnalyticsArgs,
1128
+ ): Promise<CollectionOfferAggregatesPaginatedResponse> {
1129
+ return this.collectionsAPI.getCollectionOfferAggregates(slug, args)
1130
+ }
1131
+
1132
+ /**
1133
+ * Fetch holders of a collection.
1134
+ */
1135
+ public async getCollectionHolders(
1136
+ slug: string,
1137
+ args?: CollectionHoldersArgs,
1138
+ ): Promise<CollectionHoldersPaginatedResponse> {
1139
+ return this.collectionsAPI.getCollectionHolders(slug, args)
1140
+ }
1141
+
1142
+ /**
1143
+ * Fetch the floor-price history of a collection.
1144
+ */
1145
+ public async getCollectionFloorPrices(
1146
+ slug: string,
1147
+ args?: CollectionFloorPricesArgs,
1148
+ ): Promise<FloorPriceHistoryResponse> {
1149
+ return this.collectionsAPI.getCollectionFloorPrices(slug, args)
1150
+ }
1151
+
1152
+ /**
1153
+ * Get ordered approval + sign actions to create one or more listings.
1154
+ */
1155
+ public async createListingActions(
1156
+ request: CreateListingActionsRequest,
1157
+ ): Promise<CreateListingActionsResponse> {
1158
+ return this.listingsAPI.createListingActions(request)
1159
+ }
1160
+
1161
+ /**
1162
+ * Build a deploy-contract transaction for a new drop.
1163
+ */
1164
+ public async deployDropContract(
1165
+ request: DropDeployRequest,
1166
+ ): Promise<DropDeployResponse> {
1167
+ return this.dropsAPI.deployDropContract(request)
1168
+ }
1169
+
1170
+ /**
1171
+ * Get the receipt of a previously submitted drop-deploy transaction.
1172
+ */
1173
+ public async getDeployContractReceipt(
1174
+ chain: Chain,
1175
+ txHash: string,
1176
+ ): Promise<DropDeployReceiptResponse> {
1177
+ return this.dropsAPI.getDeployReceipt(chain, txHash)
1178
+ }
1179
+
1180
+ /**
1181
+ * Build transactions to transfer NFTs or tokens between wallets.
1182
+ */
1183
+ public async transferAssets(
1184
+ request: TransferRequest,
1185
+ ): Promise<TransferResponse> {
1186
+ return this.assetsAPI.transferAssets(request)
1187
+ }
1188
+
1189
+ /**
1190
+ * Get portfolio stats (net worth, P&L) for an account.
1191
+ */
1192
+ public async getPortfolioStats(
1193
+ address: string,
1194
+ args?: PortfolioArgs,
1195
+ ): Promise<PortfolioStatsResponse> {
1196
+ return this.accountsAPI.getPortfolioStats(address, args)
1197
+ }
1198
+
1199
+ /**
1200
+ * Get portfolio net-worth history for an account.
1201
+ */
1202
+ public async getPortfolioHistory(
1203
+ address: string,
1204
+ args?: PortfolioArgs,
1205
+ ): Promise<PortfolioHistoryResponse> {
1206
+ return this.accountsAPI.getPortfolioHistory(address, args)
1207
+ }
1208
+
1209
+ /**
1210
+ * Get offers received by an account.
1211
+ */
1212
+ public async getProfileOffersReceived(
1213
+ address: string,
1214
+ args?: ProfileOrdersArgs,
1215
+ ): Promise<ProfileOffersResponse> {
1216
+ return this.accountsAPI.getProfileOffersReceived(address, args)
1217
+ }
1218
+
1219
+ /**
1220
+ * Get active offers made by an account.
1221
+ */
1222
+ public async getProfileOffers(
1223
+ address: string,
1224
+ args?: ProfileOrdersArgs,
1225
+ ): Promise<ProfileOffersResponse> {
1226
+ return this.accountsAPI.getProfileOffers(address, args)
1227
+ }
1228
+
1229
+ /**
1230
+ * Get active listings for an account.
1231
+ */
1232
+ public async getProfileListings(
1233
+ address: string,
1234
+ args?: ProfileOrdersArgs,
1235
+ ): Promise<ProfileListingsResponse> {
1236
+ return this.accountsAPI.getProfileListings(address, args)
1237
+ }
1238
+
1239
+ /**
1240
+ * Get items favorited by an account.
1241
+ */
1242
+ public async getProfileFavorites(
1243
+ address: string,
1244
+ args?: ProfileFavoritesArgs,
1245
+ ): Promise<ProfileFavoritesResponse> {
1246
+ return this.accountsAPI.getProfileFavorites(address, args)
1247
+ }
1248
+
1249
+ /**
1250
+ * Get collections owned by an account.
1251
+ */
1252
+ public async getProfileCollections(
1253
+ address: string,
1254
+ args?: ProfileCollectionsArgs,
1255
+ ): Promise<ProfileCollectionsResponse> {
1256
+ return this.accountsAPI.getProfileCollections(address, args)
1257
+ }
1258
+
983
1259
  /**
984
1260
  * Generic fetch method for any API endpoint with automatic rate limit retry
985
1261
  * @param apiPath Path to URL endpoint under API
@@ -991,14 +1267,17 @@ export class OpenSeaAPI {
991
1267
  apiPath: string,
992
1268
  query: object = {},
993
1269
  options?: RequestOptions,
994
- ): Promise<T> {
1270
+ ): Promise<Camelize<T>> {
995
1271
  return executeWithRateLimit(
996
1272
  async () => {
997
- const qs = this.objectToSearchParams(query)
1273
+ // Snakeize query keys so consumers can pass camelCase args even
1274
+ // though the API expects snake_case URL params.
1275
+ const qs = this.objectToSearchParams(snakeizeKeysDeep(query))
998
1276
  const url = qs
999
1277
  ? `${this.apiBaseUrl}${apiPath}?${qs}`
1000
1278
  : `${this.apiBaseUrl}${apiPath}`
1001
- return await this._fetch(url, undefined, undefined, options)
1279
+ const raw = await this._fetch(url, undefined, undefined, options)
1280
+ return camelizeKeysDeep(raw) as Camelize<T>
1002
1281
  },
1003
1282
  { logger: this.logger },
1004
1283
  )
@@ -1009,19 +1288,30 @@ export class OpenSeaAPI {
1009
1288
  * @param apiPath Path to URL endpoint under API
1010
1289
  * @param body Data to send.
1011
1290
  * @param headers Additional headers to send with the request.
1012
- * @param options Request options like timeout and abort signal.
1291
+ * @param options Request options. Includes the {@link PostOptions.snakeizeBody}
1292
+ * opt-out (defaults to `true`) for callers that need to emit
1293
+ * the body in exact wire shape (e.g. Seaport-shaped POSTs
1294
+ * whose inner keys are camelCase on the wire).
1013
1295
  * @returns @typeParam T The response from the API.
1014
1296
  */
1015
1297
  public async post<T>(
1016
1298
  apiPath: string,
1017
1299
  body?: object,
1018
1300
  headers?: object,
1019
- options?: RequestOptions,
1020
- ): Promise<T> {
1301
+ options?: PostOptions,
1302
+ ): Promise<Camelize<T>> {
1021
1303
  return executeWithRateLimit(
1022
1304
  async () => {
1023
1305
  const url = `${this.apiBaseUrl}${apiPath}`
1024
- return await this._fetch(url, headers, body, options)
1306
+ // Snakeize the body so consumers can pass camelCase even though the
1307
+ // API expects snake_case JSON. Opt-out via `snakeizeBody: false` for
1308
+ // Seaport-shaped bodies whose inner keys must remain camelCase on the
1309
+ // wire (the OpenSea OpenAPI spec uses mixed casing for these).
1310
+ const shouldSnakeize = options?.snakeizeBody !== false
1311
+ const wireBody =
1312
+ body == null || !shouldSnakeize ? body : snakeizeKeysDeep(body)
1313
+ const raw = await this._fetch(url, headers, wireBody, options)
1314
+ return camelizeKeysDeep(raw) as Camelize<T>
1025
1315
  },
1026
1316
  { logger: this.logger },
1027
1317
  )
@@ -1117,15 +1407,26 @@ export class OpenSeaAPI {
1117
1407
  if (response.status === 599 || response.status === 429) {
1118
1408
  throw await this._createRateLimitError(response)
1119
1409
  }
1120
- const responseBody = await response.json().catch(() => ({}))
1121
- const errors = responseBody?.errors
1122
- if (errors?.length > 0) {
1123
- let errorMessage = Array.isArray(errors)
1124
- ? errors.join(", ")
1125
- : String(errors)
1126
- if (errorMessage === "[object Object]") {
1127
- errorMessage = JSON.stringify(errors)
1128
- }
1410
+ const rawBody = await response.json().catch(() => ({}))
1411
+ const responseBody = camelizeKeysDeep(rawBody) as {
1412
+ errors?: { length?: number } | unknown[]
1413
+ }
1414
+ const errors = responseBody?.errors as
1415
+ | { length?: number }
1416
+ | unknown[]
1417
+ | undefined
1418
+ if (errors?.length !== undefined && errors.length > 0) {
1419
+ // Handle both string entries (`["not found"]`) and structured ones
1420
+ // (`[{code: "invalid_param", message: "..."}]`) — String() on an
1421
+ // object yields "[object Object]", so JSON-stringify any non-string
1422
+ // element individually before joining.
1423
+ const errorMessage = Array.isArray(errors)
1424
+ ? errors
1425
+ .map(e => (typeof e === "string" ? e : JSON.stringify(e)))
1426
+ .join(", ")
1427
+ : typeof errors === "string"
1428
+ ? errors
1429
+ : JSON.stringify(errors)
1129
1430
  throw new Error(`Server Error: ${errorMessage}`)
1130
1431
  }
1131
1432
  throw new Error(
@@ -1151,12 +1452,13 @@ export class OpenSeaAPI {
1151
1452
  *
1152
1453
  * @example
1153
1454
  * ```ts
1154
- * const { api_key } = await OpenSeaAPI.requestInstantApiKey()
1155
- * const api = new OpenSeaAPI({ apiKey: api_key })
1455
+ * const { apiKey } = await OpenSeaAPI.requestInstantApiKey()
1456
+ * const api = new OpenSeaAPI({ apiKey })
1156
1457
  * ```
1157
1458
  *
1158
1459
  * @param apiBaseUrl Optional base URL override (defaults to mainnet).
1159
- * @returns The {@link RequestInstantApiKeyResponse} containing the new key.
1460
+ * @returns The {@link RequestInstantApiKeyResponse} containing the new key,
1461
+ * with response keys camelized to match SDK conventions.
1160
1462
  */
1161
1463
  public static async requestInstantApiKey(
1162
1464
  apiBaseUrl: string = API_BASE_MAINNET,
@@ -1174,7 +1476,8 @@ export class OpenSeaAPI {
1174
1476
  `Server Error (${response.status}): ${response.statusText}`,
1175
1477
  )
1176
1478
  }
1177
- return response.json()
1479
+ const raw = await response.json()
1480
+ return camelizeKeysDeep(raw) as RequestInstantApiKeyResponse
1178
1481
  }
1179
1482
 
1180
1483
  /**
@@ -1239,7 +1542,9 @@ export class OpenSeaAPI {
1239
1542
  // Add status code and retry-after information to the error object
1240
1543
  error.statusCode = response.status
1241
1544
  error.retryAfter = retryAfter
1242
- error.responseBody = await response.json().catch(() => undefined)
1545
+ const rawBody = await response.json().catch(() => undefined)
1546
+ error.responseBody =
1547
+ rawBody === undefined ? undefined : camelizeKeysDeep(rawBody)
1243
1548
  return error
1244
1549
  }
1245
1550
  }
@@ -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
+ }