@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
@@ -1,6 +1,6 @@
1
1
  import type { Chain, OpenSeaAccount, OpenSeaPaymentToken } from "../types";
2
2
  import type { Fetcher } from "./fetcher";
3
- import type { GetAccountTokensArgs, GetAccountTokensResponse, ResolveAccountResponse } from "./types";
3
+ import type { GetAccountTokensArgs, GetAccountTokensResponse, PortfolioArgs, PortfolioHistoryResponse, PortfolioStatsResponse, ProfileCollectionsArgs, ProfileCollectionsResponse, ProfileFavoritesArgs, ProfileFavoritesResponse, ProfileListingsResponse, ProfileOffersResponse, ProfileOrdersArgs, ResolveAccountResponse } from "./types";
4
4
  /**
5
5
  * Account and payment token related API operations
6
6
  */
@@ -24,4 +24,32 @@ export declare class AccountsAPI {
24
24
  * Resolve an ENS name, OpenSea username, or wallet address to canonical account info.
25
25
  */
26
26
  resolveAccount(identifier: string): Promise<ResolveAccountResponse>;
27
+ /**
28
+ * Get portfolio stats (net worth, P&L) for an account.
29
+ */
30
+ getPortfolioStats(address: string, args?: PortfolioArgs): Promise<PortfolioStatsResponse>;
31
+ /**
32
+ * Get portfolio net-worth history for an account.
33
+ */
34
+ getPortfolioHistory(address: string, args?: PortfolioArgs): Promise<PortfolioHistoryResponse>;
35
+ /**
36
+ * Get offers received by an account, scoped by collection/chain.
37
+ */
38
+ getProfileOffersReceived(address: string, args?: ProfileOrdersArgs): Promise<ProfileOffersResponse>;
39
+ /**
40
+ * Get active offers made by an account.
41
+ */
42
+ getProfileOffers(address: string, args?: ProfileOrdersArgs): Promise<ProfileOffersResponse>;
43
+ /**
44
+ * Get active listings for an account.
45
+ */
46
+ getProfileListings(address: string, args?: ProfileOrdersArgs): Promise<ProfileListingsResponse>;
47
+ /**
48
+ * Get items favorited by an account.
49
+ */
50
+ getProfileFavorites(address: string, args?: ProfileFavoritesArgs): Promise<ProfileFavoritesResponse>;
51
+ /**
52
+ * Get collections owned by an account.
53
+ */
54
+ getProfileCollections(address: string, args?: ProfileCollectionsArgs): Promise<ProfileCollectionsResponse>;
27
55
  }
@@ -1,8 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.AccountsAPI = void 0;
4
- const converters_1 = require("../utils/converters");
5
4
  const apiPaths_1 = require("./apiPaths");
5
+ function joinArray(value) {
6
+ return value && value.length > 0 ? value.join(",") : undefined;
7
+ }
6
8
  /**
7
9
  * Account and payment token related API operations
8
10
  */
@@ -17,15 +19,20 @@ class AccountsAPI {
17
19
  * Fetch a payment token.
18
20
  */
19
21
  async getPaymentToken(address, chain = this.chain) {
20
- const json = await this.fetcher.get((0, apiPaths_1.getPaymentTokenPath)(chain, address));
21
- return (0, converters_1.paymentTokenFromJSON)(json);
22
+ return this.fetcher.get((0, apiPaths_1.getPaymentTokenPath)(chain, address));
22
23
  }
23
24
  /**
24
25
  * Fetch account for an address.
25
26
  */
26
27
  async getAccount(address) {
27
- const json = await this.fetcher.get((0, apiPaths_1.getAccountPath)(address));
28
- return (0, converters_1.accountFromJSON)(json);
28
+ const response = await this.fetcher.get((0, apiPaths_1.getAccountPath)(address));
29
+ // The api-types schema marks `social_media_accounts` as a required
30
+ // non-nullable array, but the live API returns `null` for accounts that
31
+ // haven't linked any socials. Normalize to `[]` so callers can safely map.
32
+ return {
33
+ ...response,
34
+ socialMediaAccounts: response.socialMediaAccounts ?? [],
35
+ };
29
36
  }
30
37
  /**
31
38
  * Fetch token balances for an account.
@@ -41,6 +48,66 @@ class AccountsAPI {
41
48
  const response = await this.fetcher.get((0, apiPaths_1.getResolveAccountPath)(identifier));
42
49
  return response;
43
50
  }
51
+ /**
52
+ * Get portfolio stats (net worth, P&L) for an account.
53
+ */
54
+ async getPortfolioStats(address, args) {
55
+ return this.fetcher.get((0, apiPaths_1.getPortfolioStatsPath)(address), args);
56
+ }
57
+ /**
58
+ * Get portfolio net-worth history for an account.
59
+ */
60
+ async getPortfolioHistory(address, args) {
61
+ return this.fetcher.get((0, apiPaths_1.getPortfolioHistoryPath)(address), args);
62
+ }
63
+ /**
64
+ * Get offers received by an account, scoped by collection/chain.
65
+ */
66
+ async getProfileOffersReceived(address, args) {
67
+ return this.fetcher.get((0, apiPaths_1.getProfileOffersReceivedPath)(address), {
68
+ ...args,
69
+ collectionSlugs: joinArray(args?.collectionSlugs),
70
+ chains: joinArray(args?.chains),
71
+ });
72
+ }
73
+ /**
74
+ * Get active offers made by an account.
75
+ */
76
+ async getProfileOffers(address, args) {
77
+ return this.fetcher.get((0, apiPaths_1.getProfileOffersPath)(address), {
78
+ ...args,
79
+ collectionSlugs: joinArray(args?.collectionSlugs),
80
+ chains: joinArray(args?.chains),
81
+ });
82
+ }
83
+ /**
84
+ * Get active listings for an account.
85
+ */
86
+ async getProfileListings(address, args) {
87
+ return this.fetcher.get((0, apiPaths_1.getProfileListingsPath)(address), {
88
+ ...args,
89
+ collectionSlugs: joinArray(args?.collectionSlugs),
90
+ chains: joinArray(args?.chains),
91
+ });
92
+ }
93
+ /**
94
+ * Get items favorited by an account.
95
+ */
96
+ async getProfileFavorites(address, args) {
97
+ return this.fetcher.get((0, apiPaths_1.getProfileFavoritesPath)(address), {
98
+ ...args,
99
+ chains: joinArray(args?.chains),
100
+ });
101
+ }
102
+ /**
103
+ * Get collections owned by an account.
104
+ */
105
+ async getProfileCollections(address, args) {
106
+ return this.fetcher.get((0, apiPaths_1.getProfileCollectionsPath)(address), {
107
+ ...args,
108
+ chains: joinArray(args?.chains),
109
+ });
110
+ }
44
111
  }
45
112
  exports.AccountsAPI = AccountsAPI;
46
113
  //# sourceMappingURL=accounts.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"accounts.js","sourceRoot":"","sources":["../../src/api/accounts.ts"],"names":[],"mappings":";;;AACA,oDAA2E;AAC3E,yCAKmB;AAQnB;;GAEG;AACH,MAAa,WAAW;IAEZ;IACA;IAFV,YACU,OAAgB,EAChB,KAAY;QADZ,YAAO,GAAP,OAAO,CAAS;QAChB,UAAK,GAAL,KAAK,CAAO;IACnB,CAAC;IAEJ;;OAEG;IACH,KAAK,CAAC,eAAe,CACnB,OAAe,EACf,KAAK,GAAG,IAAI,CAAC,KAAK;QAElB,MAAM,IAAI,GAAG,MAAM,I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B,CACzB,OAAe,EACf,IAA6B;QAE7B,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CACrB,IAAA,oCAAyB,EAAC,OAAO,CAAC,EAClC;YACE,GAAG,IAAI;YACP,MAAM,EAAE,SAAS,CAAC,IAAI,EAAE,MAAM,CAAC;SAChC,CACF,CAAA;IACH,CAAC;CACF;AAtKD,kCAsKC"}
package/lib/api/api.d.ts CHANGED
@@ -1,6 +1,8 @@
1
1
  import type { FulfillmentDataResponse, ProtocolData } from "../orders/types";
2
2
  import { Chain, type OpenSeaAccount, type OpenSeaAPIConfig, type OpenSeaCollection, type OpenSeaCollectionStats, type OpenSeaPaymentToken, type OrderSide, type RequestOptions } from "../types";
3
- import { type BuildOfferResponse, type CancelOrderResponse, type CollectionOffer, CollectionOrderByOption, type CrossChainFulfillmentRequest, type CrossChainFulfillmentResponse, type DropMintRequest, type DropMintResponse, type GetAccountTokensArgs, type GetAccountTokensResponse, type GetBestListingResponse, type GetBestOfferResponse, type GetChainsResponse, type GetCollectionsPaginatedResponse, type GetCollectionsResponse, type GetContractResponse, type GetDropResponse, type GetDropsArgs, type GetDropsResponse, type GetEventsArgs, type GetEventsByCollectionArgs, type GetEventsResponse, type GetListingsResponse, type GetNFTMetadataResponse, type GetNFTResponse, type GetOffersResponse, type GetOrderByHashResponse, type GetSwapQuoteArgs, type GetSwapQuoteResponse, type GetTokenGroupResponse, type GetTokenGroupsArgs, type GetTokenGroupsResponse, type GetTokenResponse, type GetTokensArgs, type GetTopCollectionsArgs, type GetTopTokensResponse, type GetTraitsResponse, type GetTrendingCollectionsArgs, type GetTrendingTokensResponse, type Listing, type ListNFTsResponse, type Offer, type RequestInstantApiKeyResponse, type ResolveAccountResponse, type SearchArgs, type SearchResponse, type SwapExecuteRequest, type SwapExecuteResponse, type SweepCollectionRequest, type SweepCollectionResponse, type TraitFilter, type TransactionReceiptRequest, type TransactionReceiptResponse, type ValidateMetadataResponse } from "./types";
3
+ import { type Camelize } from "../utils/case";
4
+ import type { PostOptions } from "./fetcher";
5
+ import { type BatchCollectionsRequest, type BatchNftsRequest, type BatchTokensRequest, type BuildOfferResponse, type CancelOrderResponse, type CollectionBatchResponse, type CollectionFloorPricesArgs, type CollectionHoldersArgs, type CollectionHoldersPaginatedResponse, type CollectionOffer, type CollectionOfferAggregatesPaginatedResponse, CollectionOrderByOption, type CreateListingActionsRequest, type CreateListingActionsResponse, type CrossChainFulfillmentRequest, type CrossChainFulfillmentResponse, type DropDeployReceiptResponse, type DropDeployRequest, type DropDeployResponse, type DropMintRequest, type DropMintResponse, type FloorPriceHistoryResponse, type GetAccountTokensArgs, type GetAccountTokensResponse, type GetBestListingResponse, type GetBestOfferResponse, type GetChainsResponse, type GetCollectionsPaginatedResponse, type GetCollectionsResponse, type GetContractResponse, type GetDropResponse, type GetDropsArgs, type GetDropsResponse, type GetEventsArgs, type GetEventsByCollectionArgs, type GetEventsResponse, type GetListingsResponse, type GetNFTMetadataResponse, type GetNFTResponse, type GetOffersResponse, type GetOrderByHashResponse, type GetSwapQuoteArgs, type GetSwapQuoteResponse, type GetTokenGroupResponse, type GetTokenGroupsArgs, type GetTokenGroupsResponse, type GetTokenResponse, type GetTokensArgs, type GetTopCollectionsArgs, type GetTopTokensResponse, type GetTraitsResponse, type GetTrendingCollectionsArgs, type GetTrendingTokensResponse, type Listing, type ListNFTsResponse, type NFTOwnersArgs, type NftAnalyticsResponse, type NftBatchResponse, type Offer, type OhlcvResponse, type OwnersPaginatedResponse, type PaginatedAnalyticsArgs, type PortfolioArgs, type PortfolioHistoryResponse, type PortfolioStatsResponse, type PriceHistoryResponse, type ProfileCollectionsArgs, type ProfileCollectionsResponse, type ProfileFavoritesArgs, type ProfileFavoritesResponse, type ProfileListingsResponse, type ProfileOffersResponse, type ProfileOrdersArgs, type RequestInstantApiKeyResponse, type ResolveAccountResponse, type SearchArgs, type SearchResponse, type SwapExecuteRequest, type SwapExecuteResponse, type SweepCollectionRequest, type SweepCollectionResponse, type TokenActivityArgs, type TokenBatchResponse, type TokenSwapActivityPaginatedResponse, type TokenTimeSeriesArgs, type TraitFilter, type TransactionReceiptRequest, type TransactionReceiptResponse, type TransferRequest, type TransferResponse, type ValidateMetadataResponse } from "./types";
4
6
  /**
5
7
  * The API class for the OpenSea SDK.
6
8
  * @category Main Classes
@@ -32,6 +34,7 @@ export declare class OpenSeaAPI {
32
34
  private chainsAPI;
33
35
  private dropsAPI;
34
36
  private transactionsAPI;
37
+ private assetsAPI;
35
38
  /**
36
39
  * Create an instance of the OpenSeaAPI
37
40
  * @param config OpenSeaAPIConfig for setting up the API, including an optional API key, Chain name, and base URL
@@ -122,7 +125,7 @@ export declare class OpenSeaAPI {
122
125
  * @param includeOptionalCreatorFees Whether to include optional creator fees in the fulfillment. If creator fees are already required, this is a no-op. Defaults to false.
123
126
  * @returns The {@link FulfillmentDataResponse}
124
127
  */
125
- generateFulfillmentData(fulfillerAddress: string, orderHash: string, protocolAddress: string, side: OrderSide, assetContractAddress?: string, tokenId?: string, unitsToFill?: string, recipientAddress?: string, includeOptionalCreatorFees?: boolean): Promise<FulfillmentDataResponse>;
128
+ generateFulfillmentData(fulfillerAddress: string, orderHash: string, protocolAddress: string, side: OrderSide, assetContractAddress?: string, tokenId?: string, unitsToFill?: string, recipientAddress?: string, includeOptionalCreatorFees?: boolean): Promise<Camelize<FulfillmentDataResponse>>;
126
129
  /**
127
130
  * Post a listing to OpenSea. Returns the new v2 Listing response format.
128
131
  * @param order The order to post
@@ -261,7 +264,7 @@ export declare class OpenSeaAPI {
261
264
  * @param chain The chain where the NFT is located.
262
265
  * @returns The response from the API.
263
266
  */
264
- refreshNFTMetadata(address: string, identifier: string, chain?: Chain): Promise<Response>;
267
+ refreshNFTMetadata(address: string, identifier: string, chain?: Chain): Promise<Record<string, unknown>>;
265
268
  /**
266
269
  * Offchain cancel an order, offer or listing, by its order hash when protected by the SignedZone.
267
270
  * Protocol and Chain are required to prevent hash collisions.
@@ -473,6 +476,106 @@ export declare class OpenSeaAPI {
473
476
  * @returns The {@link GetNFTMetadataResponse} returned by the API.
474
477
  */
475
478
  getNFTMetadata(address: string, tokenId: string, chain?: Chain): Promise<GetNFTMetadataResponse>;
479
+ /**
480
+ * Fetch multiple tokens in a single request.
481
+ * @param request Batch request listing chain + contract address pairs.
482
+ * @returns The {@link TokenBatchResponse} with detailed token info.
483
+ */
484
+ getTokensBatch(request: BatchTokensRequest): Promise<TokenBatchResponse>;
485
+ /**
486
+ * Fetch the price history of a token.
487
+ * @param chain Chain the token lives on.
488
+ * @param address Token contract address.
489
+ * @param args Time-series window — `start_time` required, `end_time` defaults to now.
490
+ * @returns The {@link PriceHistoryResponse} returned by the API.
491
+ */
492
+ getTokenPriceHistory(chain: Chain, address: string, args: TokenTimeSeriesArgs): Promise<PriceHistoryResponse>;
493
+ /**
494
+ * Fetch OHLCV candles for a token.
495
+ * @param chain Chain the token lives on.
496
+ * @param address Token contract address.
497
+ * @param args Time-series window plus candle `bucketSize` (required).
498
+ * @returns The {@link OhlcvResponse} returned by the API.
499
+ */
500
+ getTokenOhlcv(chain: Chain, address: string, args: TokenTimeSeriesArgs & {
501
+ bucketSize: string;
502
+ }): Promise<OhlcvResponse>;
503
+ /**
504
+ * Fetch recent swap activity for a token.
505
+ */
506
+ getTokenActivity(chain: Chain, address: string, args?: TokenActivityArgs): Promise<TokenSwapActivityPaginatedResponse>;
507
+ /**
508
+ * Fetch multiple NFTs in a single request.
509
+ */
510
+ getNFTsBatch(request: BatchNftsRequest): Promise<NftBatchResponse>;
511
+ /**
512
+ * Fetch owners of an NFT.
513
+ */
514
+ getNFTOwners(address: string, identifier: string, chain?: Chain, args?: NFTOwnersArgs): Promise<OwnersPaginatedResponse>;
515
+ /**
516
+ * Fetch analytics (historical sale points) for an NFT.
517
+ */
518
+ getNFTAnalytics(address: string, identifier: string, chain?: Chain): Promise<NftAnalyticsResponse>;
519
+ /**
520
+ * Fetch multiple collections in a single request by slug.
521
+ */
522
+ getCollectionsBatch(request: BatchCollectionsRequest): Promise<CollectionBatchResponse>;
523
+ /**
524
+ * Fetch top offers for a collection grouped by price level.
525
+ */
526
+ getCollectionOfferAggregates(slug: string, args?: PaginatedAnalyticsArgs): Promise<CollectionOfferAggregatesPaginatedResponse>;
527
+ /**
528
+ * Fetch holders of a collection.
529
+ */
530
+ getCollectionHolders(slug: string, args?: CollectionHoldersArgs): Promise<CollectionHoldersPaginatedResponse>;
531
+ /**
532
+ * Fetch the floor-price history of a collection.
533
+ */
534
+ getCollectionFloorPrices(slug: string, args?: CollectionFloorPricesArgs): Promise<FloorPriceHistoryResponse>;
535
+ /**
536
+ * Get ordered approval + sign actions to create one or more listings.
537
+ */
538
+ createListingActions(request: CreateListingActionsRequest): Promise<CreateListingActionsResponse>;
539
+ /**
540
+ * Build a deploy-contract transaction for a new drop.
541
+ */
542
+ deployDropContract(request: DropDeployRequest): Promise<DropDeployResponse>;
543
+ /**
544
+ * Get the receipt of a previously submitted drop-deploy transaction.
545
+ */
546
+ getDeployContractReceipt(chain: Chain, txHash: string): Promise<DropDeployReceiptResponse>;
547
+ /**
548
+ * Build transactions to transfer NFTs or tokens between wallets.
549
+ */
550
+ transferAssets(request: TransferRequest): Promise<TransferResponse>;
551
+ /**
552
+ * Get portfolio stats (net worth, P&L) for an account.
553
+ */
554
+ getPortfolioStats(address: string, args?: PortfolioArgs): Promise<PortfolioStatsResponse>;
555
+ /**
556
+ * Get portfolio net-worth history for an account.
557
+ */
558
+ getPortfolioHistory(address: string, args?: PortfolioArgs): Promise<PortfolioHistoryResponse>;
559
+ /**
560
+ * Get offers received by an account.
561
+ */
562
+ getProfileOffersReceived(address: string, args?: ProfileOrdersArgs): Promise<ProfileOffersResponse>;
563
+ /**
564
+ * Get active offers made by an account.
565
+ */
566
+ getProfileOffers(address: string, args?: ProfileOrdersArgs): Promise<ProfileOffersResponse>;
567
+ /**
568
+ * Get active listings for an account.
569
+ */
570
+ getProfileListings(address: string, args?: ProfileOrdersArgs): Promise<ProfileListingsResponse>;
571
+ /**
572
+ * Get items favorited by an account.
573
+ */
574
+ getProfileFavorites(address: string, args?: ProfileFavoritesArgs): Promise<ProfileFavoritesResponse>;
575
+ /**
576
+ * Get collections owned by an account.
577
+ */
578
+ getProfileCollections(address: string, args?: ProfileCollectionsArgs): Promise<ProfileCollectionsResponse>;
476
579
  /**
477
580
  * Generic fetch method for any API endpoint with automatic rate limit retry
478
581
  * @param apiPath Path to URL endpoint under API
@@ -480,16 +583,19 @@ export declare class OpenSeaAPI {
480
583
  * @param options Request options like timeout and abort signal.
481
584
  * @returns @typeParam T The response from the API.
482
585
  */
483
- get<T>(apiPath: string, query?: object, options?: RequestOptions): Promise<T>;
586
+ get<T>(apiPath: string, query?: object, options?: RequestOptions): Promise<Camelize<T>>;
484
587
  /**
485
588
  * Generic post method for any API endpoint with automatic rate limit retry
486
589
  * @param apiPath Path to URL endpoint under API
487
590
  * @param body Data to send.
488
591
  * @param headers Additional headers to send with the request.
489
- * @param options Request options like timeout and abort signal.
592
+ * @param options Request options. Includes the {@link PostOptions.snakeizeBody}
593
+ * opt-out (defaults to `true`) for callers that need to emit
594
+ * the body in exact wire shape (e.g. Seaport-shaped POSTs
595
+ * whose inner keys are camelCase on the wire).
490
596
  * @returns @typeParam T The response from the API.
491
597
  */
492
- post<T>(apiPath: string, body?: object, headers?: object, options?: RequestOptions): Promise<T>;
598
+ post<T>(apiPath: string, body?: object, headers?: object, options?: PostOptions): Promise<Camelize<T>>;
493
599
  private objectToSearchParams;
494
600
  /**
495
601
  * Fetch from an API Endpoint, sending auth token in headers
@@ -509,12 +615,13 @@ export declare class OpenSeaAPI {
509
615
  *
510
616
  * @example
511
617
  * ```ts
512
- * const { api_key } = await OpenSeaAPI.requestInstantApiKey()
513
- * const api = new OpenSeaAPI({ apiKey: api_key })
618
+ * const { apiKey } = await OpenSeaAPI.requestInstantApiKey()
619
+ * const api = new OpenSeaAPI({ apiKey })
514
620
  * ```
515
621
  *
516
622
  * @param apiBaseUrl Optional base URL override (defaults to mainnet).
517
- * @returns The {@link RequestInstantApiKeyResponse} containing the new key.
623
+ * @returns The {@link RequestInstantApiKeyResponse} containing the new key,
624
+ * with response keys camelized to match SDK conventions.
518
625
  */
519
626
  static requestInstantApiKey(apiBaseUrl?: string): Promise<RequestInstantApiKeyResponse>;
520
627
  /**
package/lib/api/api.js CHANGED
@@ -3,9 +3,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.OpenSeaAPI = void 0;
4
4
  const constants_1 = require("../constants");
5
5
  const types_1 = require("../types");
6
+ const case_1 = require("../utils/case");
6
7
  const rateLimit_1 = require("../utils/rateLimit");
7
8
  const accounts_1 = require("./accounts");
8
9
  const apiPaths_1 = require("./apiPaths");
10
+ const assets_1 = require("./assets");
9
11
  const chains_1 = require("./chains");
10
12
  const collections_1 = require("./collections");
11
13
  const drops_1 = require("./drops");
@@ -50,6 +52,7 @@ class OpenSeaAPI {
50
52
  chainsAPI;
51
53
  dropsAPI;
52
54
  transactionsAPI;
55
+ assetsAPI;
53
56
  /**
54
57
  * Create an instance of the OpenSeaAPI
55
58
  * @param config OpenSeaAPIConfig for setting up the API, including an optional API key, Chain name, and base URL
@@ -84,6 +87,7 @@ class OpenSeaAPI {
84
87
  this.chainsAPI = new chains_1.ChainsAPI(fetcher);
85
88
  this.dropsAPI = new drops_1.DropsAPI(fetcher);
86
89
  this.transactionsAPI = new transactions_1.TransactionsAPI(fetcher);
90
+ this.assetsAPI = new assets_1.AssetsAPI(fetcher);
87
91
  }
88
92
  /**
89
93
  * Gets a single order by its order hash.
@@ -612,6 +616,148 @@ class OpenSeaAPI {
612
616
  async getNFTMetadata(address, tokenId, chain = this.chain) {
613
617
  return this.nftsAPI.getNFTMetadata(address, tokenId, chain);
614
618
  }
619
+ /**
620
+ * Fetch multiple tokens in a single request.
621
+ * @param request Batch request listing chain + contract address pairs.
622
+ * @returns The {@link TokenBatchResponse} with detailed token info.
623
+ */
624
+ async getTokensBatch(request) {
625
+ return this.tokensAPI.getTokensBatch(request);
626
+ }
627
+ /**
628
+ * Fetch the price history of a token.
629
+ * @param chain Chain the token lives on.
630
+ * @param address Token contract address.
631
+ * @param args Time-series window — `start_time` required, `end_time` defaults to now.
632
+ * @returns The {@link PriceHistoryResponse} returned by the API.
633
+ */
634
+ async getTokenPriceHistory(chain, address, args) {
635
+ return this.tokensAPI.getTokenPriceHistory(chain, address, args);
636
+ }
637
+ /**
638
+ * Fetch OHLCV candles for a token.
639
+ * @param chain Chain the token lives on.
640
+ * @param address Token contract address.
641
+ * @param args Time-series window plus candle `bucketSize` (required).
642
+ * @returns The {@link OhlcvResponse} returned by the API.
643
+ */
644
+ async getTokenOhlcv(chain, address, args) {
645
+ return this.tokensAPI.getTokenOhlcv(chain, address, args);
646
+ }
647
+ /**
648
+ * Fetch recent swap activity for a token.
649
+ */
650
+ async getTokenActivity(chain, address, args) {
651
+ return this.tokensAPI.getTokenActivity(chain, address, args);
652
+ }
653
+ /**
654
+ * Fetch multiple NFTs in a single request.
655
+ */
656
+ async getNFTsBatch(request) {
657
+ return this.nftsAPI.getNFTsBatch(request);
658
+ }
659
+ /**
660
+ * Fetch owners of an NFT.
661
+ */
662
+ async getNFTOwners(address, identifier, chain = this.chain, args) {
663
+ return this.nftsAPI.getNFTOwners(address, identifier, chain, args);
664
+ }
665
+ /**
666
+ * Fetch analytics (historical sale points) for an NFT.
667
+ */
668
+ async getNFTAnalytics(address, identifier, chain = this.chain) {
669
+ return this.nftsAPI.getNFTAnalytics(address, identifier, chain);
670
+ }
671
+ /**
672
+ * Fetch multiple collections in a single request by slug.
673
+ */
674
+ async getCollectionsBatch(request) {
675
+ return this.collectionsAPI.getCollectionsBatch(request);
676
+ }
677
+ /**
678
+ * Fetch top offers for a collection grouped by price level.
679
+ */
680
+ async getCollectionOfferAggregates(slug, args) {
681
+ return this.collectionsAPI.getCollectionOfferAggregates(slug, args);
682
+ }
683
+ /**
684
+ * Fetch holders of a collection.
685
+ */
686
+ async getCollectionHolders(slug, args) {
687
+ return this.collectionsAPI.getCollectionHolders(slug, args);
688
+ }
689
+ /**
690
+ * Fetch the floor-price history of a collection.
691
+ */
692
+ async getCollectionFloorPrices(slug, args) {
693
+ return this.collectionsAPI.getCollectionFloorPrices(slug, args);
694
+ }
695
+ /**
696
+ * Get ordered approval + sign actions to create one or more listings.
697
+ */
698
+ async createListingActions(request) {
699
+ return this.listingsAPI.createListingActions(request);
700
+ }
701
+ /**
702
+ * Build a deploy-contract transaction for a new drop.
703
+ */
704
+ async deployDropContract(request) {
705
+ return this.dropsAPI.deployDropContract(request);
706
+ }
707
+ /**
708
+ * Get the receipt of a previously submitted drop-deploy transaction.
709
+ */
710
+ async getDeployContractReceipt(chain, txHash) {
711
+ return this.dropsAPI.getDeployReceipt(chain, txHash);
712
+ }
713
+ /**
714
+ * Build transactions to transfer NFTs or tokens between wallets.
715
+ */
716
+ async transferAssets(request) {
717
+ return this.assetsAPI.transferAssets(request);
718
+ }
719
+ /**
720
+ * Get portfolio stats (net worth, P&L) for an account.
721
+ */
722
+ async getPortfolioStats(address, args) {
723
+ return this.accountsAPI.getPortfolioStats(address, args);
724
+ }
725
+ /**
726
+ * Get portfolio net-worth history for an account.
727
+ */
728
+ async getPortfolioHistory(address, args) {
729
+ return this.accountsAPI.getPortfolioHistory(address, args);
730
+ }
731
+ /**
732
+ * Get offers received by an account.
733
+ */
734
+ async getProfileOffersReceived(address, args) {
735
+ return this.accountsAPI.getProfileOffersReceived(address, args);
736
+ }
737
+ /**
738
+ * Get active offers made by an account.
739
+ */
740
+ async getProfileOffers(address, args) {
741
+ return this.accountsAPI.getProfileOffers(address, args);
742
+ }
743
+ /**
744
+ * Get active listings for an account.
745
+ */
746
+ async getProfileListings(address, args) {
747
+ return this.accountsAPI.getProfileListings(address, args);
748
+ }
749
+ /**
750
+ * Get items favorited by an account.
751
+ */
752
+ async getProfileFavorites(address, args) {
753
+ return this.accountsAPI.getProfileFavorites(address, args);
754
+ }
755
+ /**
756
+ * Get collections owned by an account.
757
+ */
758
+ async getProfileCollections(address, args) {
759
+ return this.accountsAPI.getProfileCollections(address, args);
760
+ }
615
761
  /**
616
762
  * Generic fetch method for any API endpoint with automatic rate limit retry
617
763
  * @param apiPath Path to URL endpoint under API
@@ -621,11 +767,14 @@ class OpenSeaAPI {
621
767
  */
622
768
  async get(apiPath, query = {}, options) {
623
769
  return (0, rateLimit_1.executeWithRateLimit)(async () => {
624
- const qs = this.objectToSearchParams(query);
770
+ // Snakeize query keys so consumers can pass camelCase args even
771
+ // though the API expects snake_case URL params.
772
+ const qs = this.objectToSearchParams((0, case_1.snakeizeKeysDeep)(query));
625
773
  const url = qs
626
774
  ? `${this.apiBaseUrl}${apiPath}?${qs}`
627
775
  : `${this.apiBaseUrl}${apiPath}`;
628
- return await this._fetch(url, undefined, undefined, options);
776
+ const raw = await this._fetch(url, undefined, undefined, options);
777
+ return (0, case_1.camelizeKeysDeep)(raw);
629
778
  }, { logger: this.logger });
630
779
  }
631
780
  /**
@@ -633,13 +782,23 @@ class OpenSeaAPI {
633
782
  * @param apiPath Path to URL endpoint under API
634
783
  * @param body Data to send.
635
784
  * @param headers Additional headers to send with the request.
636
- * @param options Request options like timeout and abort signal.
785
+ * @param options Request options. Includes the {@link PostOptions.snakeizeBody}
786
+ * opt-out (defaults to `true`) for callers that need to emit
787
+ * the body in exact wire shape (e.g. Seaport-shaped POSTs
788
+ * whose inner keys are camelCase on the wire).
637
789
  * @returns @typeParam T The response from the API.
638
790
  */
639
791
  async post(apiPath, body, headers, options) {
640
792
  return (0, rateLimit_1.executeWithRateLimit)(async () => {
641
793
  const url = `${this.apiBaseUrl}${apiPath}`;
642
- return await this._fetch(url, headers, body, options);
794
+ // Snakeize the body so consumers can pass camelCase even though the
795
+ // API expects snake_case JSON. Opt-out via `snakeizeBody: false` for
796
+ // Seaport-shaped bodies whose inner keys must remain camelCase on the
797
+ // wire (the OpenSea OpenAPI spec uses mixed casing for these).
798
+ const shouldSnakeize = options?.snakeizeBody !== false;
799
+ const wireBody = body == null || !shouldSnakeize ? body : (0, case_1.snakeizeKeysDeep)(body);
800
+ const raw = await this._fetch(url, headers, wireBody, options);
801
+ return (0, case_1.camelizeKeysDeep)(raw);
643
802
  }, { logger: this.logger });
644
803
  }
645
804
  objectToSearchParams(params = {}) {
@@ -720,15 +879,21 @@ class OpenSeaAPI {
720
879
  if (response.status === 599 || response.status === 429) {
721
880
  throw await this._createRateLimitError(response);
722
881
  }
723
- const responseBody = await response.json().catch(() => ({}));
882
+ const rawBody = await response.json().catch(() => ({}));
883
+ const responseBody = (0, case_1.camelizeKeysDeep)(rawBody);
724
884
  const errors = responseBody?.errors;
725
- if (errors?.length > 0) {
726
- let errorMessage = Array.isArray(errors)
727
- ? errors.join(", ")
728
- : String(errors);
729
- if (errorMessage === "[object Object]") {
730
- errorMessage = JSON.stringify(errors);
731
- }
885
+ if (errors?.length !== undefined && errors.length > 0) {
886
+ // Handle both string entries (`["not found"]`) and structured ones
887
+ // (`[{code: "invalid_param", message: "..."}]`) — String() on an
888
+ // object yields "[object Object]", so JSON-stringify any non-string
889
+ // element individually before joining.
890
+ const errorMessage = Array.isArray(errors)
891
+ ? errors
892
+ .map(e => (typeof e === "string" ? e : JSON.stringify(e)))
893
+ .join(", ")
894
+ : typeof errors === "string"
895
+ ? errors
896
+ : JSON.stringify(errors);
732
897
  throw new Error(`Server Error: ${errorMessage}`);
733
898
  }
734
899
  throw new Error(`Server Error (${response.status}): ${response.statusText}`);
@@ -752,12 +917,13 @@ class OpenSeaAPI {
752
917
  *
753
918
  * @example
754
919
  * ```ts
755
- * const { api_key } = await OpenSeaAPI.requestInstantApiKey()
756
- * const api = new OpenSeaAPI({ apiKey: api_key })
920
+ * const { apiKey } = await OpenSeaAPI.requestInstantApiKey()
921
+ * const api = new OpenSeaAPI({ apiKey })
757
922
  * ```
758
923
  *
759
924
  * @param apiBaseUrl Optional base URL override (defaults to mainnet).
760
- * @returns The {@link RequestInstantApiKeyResponse} containing the new key.
925
+ * @returns The {@link RequestInstantApiKeyResponse} containing the new key,
926
+ * with response keys camelized to match SDK conventions.
761
927
  */
762
928
  static async requestInstantApiKey(apiBaseUrl = constants_1.API_BASE_MAINNET) {
763
929
  const response = await fetch(`${apiBaseUrl}${(0, apiPaths_1.getInstantApiKeyPath)()}`, {
@@ -771,7 +937,8 @@ class OpenSeaAPI {
771
937
  if (!response.ok) {
772
938
  throw new Error(`Server Error (${response.status}): ${response.statusText}`);
773
939
  }
774
- return response.json();
940
+ const raw = await response.json();
941
+ return (0, case_1.camelizeKeysDeep)(raw);
775
942
  }
776
943
  /**
777
944
  * Maximum retry-after value in seconds (5 minutes).
@@ -826,7 +993,9 @@ class OpenSeaAPI {
826
993
  // Add status code and retry-after information to the error object
827
994
  error.statusCode = response.status;
828
995
  error.retryAfter = retryAfter;
829
- error.responseBody = await response.json().catch(() => undefined);
996
+ const rawBody = await response.json().catch(() => undefined);
997
+ error.responseBody =
998
+ rawBody === undefined ? undefined : (0, case_1.camelizeKeysDeep)(rawBody);
830
999
  return error;
831
1000
  }
832
1001
  }