@coinbase-sample/prime-sdk-ts 0.6.1 → 0.6.3

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 (64) hide show
  1. package/README.md +207 -67
  2. package/dist/activities/index.js +21 -39
  3. package/dist/addressBooks/index.js +18 -5
  4. package/dist/allocations/index.js +19 -18
  5. package/dist/balances/index.js +23 -17
  6. package/dist/client-manual.js +84 -0
  7. package/dist/client-modular.js +57 -0
  8. package/dist/client-only.js +31 -0
  9. package/dist/{client.js → clients/client.js} +12 -2
  10. package/dist/clients/clientWithServices.js +323 -0
  11. package/dist/{types/client.d.ts → clients/clientWithServicesTypes.js} +3 -6
  12. package/dist/clients/index.js +28 -0
  13. package/dist/clients/types.js +2 -0
  14. package/dist/constants.js +1 -1
  15. package/dist/financing/index.js +16 -3
  16. package/dist/futures/index.js +4 -4
  17. package/dist/index.js +27 -18
  18. package/dist/invoices/index.js +16 -12
  19. package/dist/onchainAddressBook/index.js +4 -4
  20. package/dist/orders/index.js +38 -58
  21. package/dist/positions/index.js +21 -6
  22. package/dist/products/index.js +16 -3
  23. package/dist/services.js +75 -0
  24. package/dist/shared/envUtils.js +66 -0
  25. package/dist/shared/paginatedResponse.js +3 -0
  26. package/dist/staking/index.js +5 -5
  27. package/dist/transactions/index.js +26 -17
  28. package/dist/types/activities/index.d.ts +2 -3
  29. package/dist/types/addressBooks/index.d.ts +2 -3
  30. package/dist/types/allocations/index.d.ts +2 -3
  31. package/dist/types/assets/index.d.ts +2 -3
  32. package/dist/types/balances/index.d.ts +2 -3
  33. package/dist/types/client-manual.d.ts +58 -0
  34. package/dist/types/client-modular.d.ts +39 -0
  35. package/dist/types/client-only.d.ts +18 -0
  36. package/dist/types/clients/client.d.ts +27 -0
  37. package/dist/types/clients/clientWithServices.d.ts +229 -0
  38. package/dist/types/clients/clientWithServicesTypes.d.ts +115 -0
  39. package/dist/types/clients/index.d.ts +19 -0
  40. package/dist/types/clients/types.d.ts +48 -0
  41. package/dist/types/commission/index.d.ts +2 -3
  42. package/dist/types/constants.d.ts +1 -1
  43. package/dist/types/financing/index.d.ts +2 -3
  44. package/dist/types/futures/index.d.ts +2 -3
  45. package/dist/types/index.d.ts +2 -1
  46. package/dist/types/invoices/index.d.ts +2 -3
  47. package/dist/types/onchainAddressBook/index.d.ts +2 -3
  48. package/dist/types/orders/index.d.ts +2 -3
  49. package/dist/types/paymentMethods/index.d.ts +2 -3
  50. package/dist/types/portfolios/index.d.ts +2 -3
  51. package/dist/types/positions/index.d.ts +2 -3
  52. package/dist/types/products/index.d.ts +2 -3
  53. package/dist/types/services.d.ts +39 -0
  54. package/dist/types/shared/envUtils.d.ts +36 -0
  55. package/dist/types/shared/paginatedResponse.d.ts +5 -4
  56. package/dist/types/staking/index.d.ts +2 -3
  57. package/dist/types/transactions/index.d.ts +2 -3
  58. package/dist/types/types.d.ts +37 -0
  59. package/dist/types/users/index.d.ts +2 -3
  60. package/dist/types/wallets/index.d.ts +2 -3
  61. package/dist/types.js +39 -0
  62. package/dist/users/index.js +21 -6
  63. package/dist/wallets/index.js +24 -12
  64. package/package.json +32 -1
@@ -0,0 +1,115 @@
1
+ /**
2
+ * Copyright 2025-present Coinbase Global, Inc.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ import type { IActivitiesService } from '../activities';
17
+ import type { IAddressBooksService } from '../addressBooks';
18
+ import type { IAllocationService } from '../allocations';
19
+ import type { IAssetsService } from '../assets';
20
+ import type { IBalancesService } from '../balances';
21
+ import type { ICommissionService } from '../commission';
22
+ import type { IFinancingService } from '../financing';
23
+ import type { IFuturesService } from '../futures';
24
+ import type { IInvoicesService } from '../invoices';
25
+ import type { OnchainAddressBookService } from '../onchainAddressBook';
26
+ import type { IOrdersService } from '../orders';
27
+ import type { IPaymentMethodsService } from '../paymentMethods';
28
+ import type { IPortfoliosService } from '../portfolios';
29
+ import type { IPositionsService } from '../positions';
30
+ import type { IProductsService } from '../products';
31
+ import type { IStakingService } from '../staking';
32
+ import type { ITransactionsService } from '../transactions';
33
+ import type { IUsersService } from '../users';
34
+ import type { IWalletsService } from '../wallets';
35
+ /**
36
+ * Interface defining all lazy service getters for the modular client
37
+ */
38
+ export interface LazyServiceGetters {
39
+ /**
40
+ * Activities service for managing portfolio and entity activities
41
+ */
42
+ readonly activities: IActivitiesService;
43
+ /**
44
+ * Address books service for managing portfolio address books
45
+ */
46
+ readonly addressBooks: IAddressBooksService;
47
+ /**
48
+ * Allocations service for managing portfolio allocations
49
+ */
50
+ readonly allocations: IAllocationService;
51
+ /**
52
+ * Assets service for managing entity assets
53
+ */
54
+ readonly assets: IAssetsService;
55
+ /**
56
+ * Balances service for managing wallet and portfolio balances
57
+ */
58
+ readonly balances: IBalancesService;
59
+ /**
60
+ * Commission service for retrieving commission information
61
+ */
62
+ readonly commission: ICommissionService;
63
+ /**
64
+ * Financing service for margin, buying power, and FCM operations
65
+ */
66
+ readonly financing: IFinancingService;
67
+ /**
68
+ * Futures service for managing futures positions and sweeps
69
+ */
70
+ readonly futures: IFuturesService;
71
+ /**
72
+ * Invoices service for managing entity invoices
73
+ */
74
+ readonly invoices: IInvoicesService;
75
+ /**
76
+ * Onchain address book service for managing blockchain addresses
77
+ */
78
+ readonly onchainAddressBook: OnchainAddressBookService;
79
+ /**
80
+ * Orders service for creating and managing trading orders
81
+ */
82
+ readonly orders: IOrdersService;
83
+ /**
84
+ * Payment methods service for managing entity payment methods
85
+ */
86
+ readonly paymentMethods: IPaymentMethodsService;
87
+ /**
88
+ * Portfolios service for managing portfolio information
89
+ */
90
+ readonly portfolios: IPortfoliosService;
91
+ /**
92
+ * Positions service for managing trading positions
93
+ */
94
+ readonly positions: IPositionsService;
95
+ /**
96
+ * Products service for retrieving available trading products
97
+ */
98
+ readonly products: IProductsService;
99
+ /**
100
+ * Staking service for managing staking operations
101
+ */
102
+ readonly staking: IStakingService;
103
+ /**
104
+ * Transactions service for managing transaction history
105
+ */
106
+ readonly transactions: ITransactionsService;
107
+ /**
108
+ * Users service for managing entity and portfolio users
109
+ */
110
+ readonly users: IUsersService;
111
+ /**
112
+ * Wallets service for managing portfolio wallets
113
+ */
114
+ readonly wallets: IWalletsService;
115
+ }
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Copyright 2025-present Coinbase Global, Inc.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ export { CoinbasePrimeClient } from './client';
17
+ export { CoinbasePrimeClientWithServices } from './clientWithServices';
18
+ export { CoinbasePrimeClientConfig, IPrimeApiClient, LazyService, } from './types';
19
+ export { CoinbaseClient, CoinbaseHttpClientRetryOptions, CoinbaseCallOptions, Method, CoinbaseClientException, CoinbaseError, CoinbaseResponse, TransformRequestFn, TransformResponseFn, } from '@coinbase-sample/core-ts';
@@ -0,0 +1,48 @@
1
+ /**
2
+ * Copyright 2025-present Coinbase Global, Inc.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ import type { CoinbaseHttpClientRetryOptions, CoinbaseHttpRequestOptions, CoinbaseResponse } from '@coinbase-sample/core-ts';
17
+ /**
18
+ * Configuration options for Prime SDK clients.
19
+ *
20
+ * This unified interface is used by:
21
+ * - CoinbasePrimeClient (traditional client)
22
+ * - CoinbasePrimeClientWithServices (enhanced client)
23
+ *
24
+ * Note: We use Omit<> to cleanly override pagination properties that may
25
+ * have different type constraints between core-ts and Prime SDK.
26
+ */
27
+ export interface CoinbasePrimeClientConfig extends Omit<CoinbaseHttpClientRetryOptions, 'defaultLimit' | 'maxPages' | 'maxItems'> {
28
+ defaultLimit?: number;
29
+ maxPages?: number;
30
+ maxItems?: number;
31
+ }
32
+ export interface IPrimeApiClient {
33
+ request(options: CoinbaseHttpRequestOptions): Promise<CoinbaseResponse>;
34
+ getDefaultPaginationLimit(): number;
35
+ getMaxPages(): number;
36
+ getMaxItems(): number;
37
+ }
38
+ /**
39
+ * Factory function type for creating service instances
40
+ */
41
+ export type ServiceFactory<T> = () => T;
42
+ /**
43
+ * Type helper for lazy service initialization
44
+ */
45
+ export type LazyService<T> = {
46
+ instance?: T;
47
+ factory: ServiceFactory<T>;
48
+ };
@@ -13,14 +13,13 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- import { CoinbaseCallOptions } from '@coinbase-sample/core-ts';
17
- import { CoinbasePrimeClient } from '../client';
16
+ import { CoinbaseCallOptions, IPrimeApiClient } from '../clients';
18
17
  import { GetPortfolioCommissionRequest, GetPortfolioCommissionResponse } from './types';
19
18
  export interface ICommissionService {
20
19
  getPortfolioCommission(request: GetPortfolioCommissionRequest, options?: CoinbaseCallOptions): Promise<GetPortfolioCommissionResponse>;
21
20
  }
22
21
  export declare class CommissionService implements ICommissionService {
23
22
  private client;
24
- constructor(client: CoinbasePrimeClient);
23
+ constructor(client: IPrimeApiClient);
25
24
  getPortfolioCommission(request: GetPortfolioCommissionRequest, options?: CoinbaseCallOptions): Promise<GetPortfolioCommissionResponse>;
26
25
  }
@@ -13,7 +13,7 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- export declare const VERSION = "0.6.1";
16
+ export declare const VERSION = "0.6.3";
17
17
  export declare const API_BASE_PATH = "https://api.prime.coinbase.com/v1/";
18
18
  export declare const USER_AGENT: string;
19
19
  export declare const CB_ACCESS_KEY_HEADER = "X-CB-ACCESS-KEY";
@@ -13,8 +13,7 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- import { CoinbaseCallOptions } from '@coinbase-sample/core-ts';
17
- import { CoinbasePrimeClient } from '../client';
16
+ import { IPrimeApiClient, CoinbaseCallOptions } from '../clients';
18
17
  import { ListExistingLocatesRequest, ListExistingLocatesResponse, ListInterestAccrualsRequest, ListInterestAccrualsResponse, ListPortfolioInterestAccrualsRequest, ListPortfolioInterestAccrualsResponse, ListMarginCallSummariesRequest, ListMarginCallSummariesResponse, ListMarginConversionsRequest, ListMarginConversionsResponse, GetEntityLocateAvailabilitiesRequest, GetEntityLocateAvailabilitiesResponse, GetMarginInformationRequest, GetMarginInformationResponse, GetPortfolioBuyingPowerRequest, GetPortfolioBuyingPowerResponse, GetPortfolioCreditInformationRequest, GetPortfolioCreditInformationResponse, GetPortfolioWithdrawalPowerRequest, GetPortfolioWithdrawalPowerResponse, GetTieredPricingFeesRequest, GetTieredPricingFeesResponse, GetFcmMarginCallDetailsRequest, GetFcmMarginCallDetailsResponse, GetFcmRiskLimitsRequest, GetFcmRiskLimitsResponse, CreateNewLocatesRequest, CreateNewLocatesResponse } from './types';
19
18
  export interface IFinancingService {
20
19
  listExistingLocates(request: ListExistingLocatesRequest, options?: CoinbaseCallOptions): Promise<ListExistingLocatesResponse>;
@@ -34,7 +33,7 @@ export interface IFinancingService {
34
33
  }
35
34
  export declare class FinancingService implements IFinancingService {
36
35
  private client;
37
- constructor(client: CoinbasePrimeClient);
36
+ constructor(client: IPrimeApiClient);
38
37
  listExistingLocates(request: ListExistingLocatesRequest, options?: CoinbaseCallOptions): Promise<ListExistingLocatesResponse>;
39
38
  listInterestAccruals(request: ListInterestAccrualsRequest, options?: CoinbaseCallOptions): Promise<ListInterestAccrualsResponse>;
40
39
  listPortfolioInterestAccruals(request: ListPortfolioInterestAccrualsRequest, options?: CoinbaseCallOptions): Promise<ListPortfolioInterestAccrualsResponse>;
@@ -13,8 +13,7 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- import { CoinbaseCallOptions } from '@coinbase-sample/core-ts';
17
- import { CoinbasePrimeClient } from '../client';
16
+ import { CoinbaseCallOptions, IPrimeApiClient } from '../clients';
18
17
  import { ListEntityFuturesSweepsRequest, ListEntityFuturesSweepsResponse, GetEntityFuturesBalanceRequest, GetEntityFuturesBalanceResponse, GetEntityFuturesPositionsRequest, GetEntityFuturesPositionsResponse, ScheduleEntityFuturesSweepRequest, ScheduleEntityFuturesSweepResponse, UpdateEntityFuturesAutoSweepRequest, UpdateEntityFuturesAutoSweepResponse, CancelEntitySweepRequest, CancelEntitySweepResponse } from './types';
19
18
  export interface IFuturesService {
20
19
  listEntitySweeps(request: ListEntityFuturesSweepsRequest, options?: CoinbaseCallOptions): Promise<ListEntityFuturesSweepsResponse>;
@@ -26,7 +25,7 @@ export interface IFuturesService {
26
25
  }
27
26
  export declare class FuturesService implements IFuturesService {
28
27
  private client;
29
- constructor(client: CoinbasePrimeClient);
28
+ constructor(client: IPrimeApiClient);
30
29
  listEntitySweeps(request: ListEntityFuturesSweepsRequest, options?: CoinbaseCallOptions): Promise<ListEntityFuturesSweepsResponse>;
31
30
  getEntityBalance(request: GetEntityFuturesBalanceRequest, options?: CoinbaseCallOptions): Promise<GetEntityFuturesBalanceResponse>;
32
31
  getEntityPositions(request: GetEntityFuturesPositionsRequest, options?: CoinbaseCallOptions): Promise<GetEntityFuturesPositionsResponse>;
@@ -13,8 +13,9 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- export { CoinbasePrimeClient } from './client';
16
+ export { CoinbaseClient, CoinbaseHttpClientRetryOptions, CoinbaseCallOptions, Method, CoinbaseClientException, CoinbaseError, CoinbaseResponse, TransformRequestFn, TransformResponseFn, CoinbasePrimeClientWithServices, CoinbasePrimeClientConfig, CoinbasePrimeClient, IPrimeApiClient, } from './clients';
17
17
  export { CoinbasePrimeCredentials } from './credentials';
18
+ export { createCredentialsFromEnv } from './shared/envUtils';
18
19
  export { ActivitiesService, IActivitiesService } from './activities';
19
20
  export { AddressBooksService, IAddressBooksService } from './addressBooks';
20
21
  export { AllocationService, IAllocationService } from './allocations';
@@ -13,14 +13,13 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- import { CoinbaseCallOptions } from '@coinbase-sample/core-ts';
17
- import { CoinbasePrimeClient } from '../client';
16
+ import { IPrimeApiClient, CoinbaseCallOptions } from '../clients';
18
17
  import { ListInvoicesRequest, ListInvoicesResponse } from './types';
19
18
  export interface IInvoicesService {
20
19
  listInvoices(request: ListInvoicesRequest, options?: CoinbaseCallOptions): Promise<ListInvoicesResponse>;
21
20
  }
22
21
  export declare class InvoicesService implements IInvoicesService {
23
22
  private client;
24
- constructor(client: CoinbasePrimeClient);
23
+ constructor(client: IPrimeApiClient);
25
24
  listInvoices(request: ListInvoicesRequest, options?: CoinbaseCallOptions): Promise<ListInvoicesResponse>;
26
25
  }
@@ -13,8 +13,7 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- import { CoinbaseCallOptions } from '@coinbase-sample/core-ts';
17
- import { CoinbasePrimeClient } from '../client';
16
+ import { CoinbaseCallOptions, IPrimeApiClient } from '../clients';
18
17
  import { ListOnchainAddressBookRequest, ListOnchainAddressBookResponse, CreateOnchainAddressBookEntryRequest, CreateOnchainAddressBookEntryResponse, UpdateOnchainAddressBookEntryRequest, UpdateOnchainAddressBookEntryResponse, DeleteOnchainAddressBookEntryRequest, DeleteOnchainAddressBookEntryResponse } from './types';
19
18
  export interface IOnchainAddressBookService {
20
19
  listOnchainAddressBook(request: ListOnchainAddressBookRequest, options?: CoinbaseCallOptions): Promise<ListOnchainAddressBookResponse>;
@@ -24,7 +23,7 @@ export interface IOnchainAddressBookService {
24
23
  }
25
24
  export declare class OnchainAddressBookService implements IOnchainAddressBookService {
26
25
  private client;
27
- constructor(client: CoinbasePrimeClient);
26
+ constructor(client: IPrimeApiClient);
28
27
  listOnchainAddressBook(request: ListOnchainAddressBookRequest, options?: CoinbaseCallOptions): Promise<ListOnchainAddressBookResponse>;
29
28
  createOnchainAddressBookEntry(request: CreateOnchainAddressBookEntryRequest, options?: CoinbaseCallOptions): Promise<CreateOnchainAddressBookEntryResponse>;
30
29
  updateOnchainAddressBookEntry(request: UpdateOnchainAddressBookEntryRequest, options?: CoinbaseCallOptions): Promise<UpdateOnchainAddressBookEntryResponse>;
@@ -13,8 +13,7 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- import { CoinbaseCallOptions } from '@coinbase-sample/core-ts';
17
- import { CoinbasePrimeClient } from '../client';
16
+ import { CoinbaseCallOptions, IPrimeApiClient } from '../clients';
18
17
  import { ListOpenOrdersResponse, ListOpenOrdersRequest, ListOrderFillsRequest, ListOrderFillsResponse, ListPortfolioOrdersResponse, ListPortfolioOrdersRequest, GetOrderResponse, GetOrderRequest, GetOrderEditHistoryRequest, GetOrderEditHistoryResponse, ListPortfolioFillsRequest, ListPortfolioFillsResponse, CreateOrderPreviewRequest, CreateOrderPreviewResponse, CancelOrderRequest, CancelOrderResponse, CreateOrderRequest, CreateOrderResponse, CreateQuoteRequest, CreateQuoteResponse, AcceptQuoteRequest, AcceptQuoteResponse } from './types';
19
18
  export interface IOrdersService {
20
19
  getOrder(request: GetOrderRequest, options?: CoinbaseCallOptions): Promise<GetOrderResponse>;
@@ -31,7 +30,7 @@ export interface IOrdersService {
31
30
  }
32
31
  export declare class OrdersService implements IOrdersService {
33
32
  private client;
34
- constructor(client: CoinbasePrimeClient);
33
+ constructor(client: IPrimeApiClient);
35
34
  getOrder(request: GetOrderRequest, options?: CoinbaseCallOptions): Promise<GetOrderResponse>;
36
35
  getOrderEditHistory(request: GetOrderEditHistoryRequest, options?: CoinbaseCallOptions): Promise<GetOrderEditHistoryResponse>;
37
36
  listPortfolioFills(request: ListPortfolioFillsRequest, options?: CoinbaseCallOptions): Promise<ListPortfolioFillsResponse>;
@@ -13,8 +13,7 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- import { CoinbaseCallOptions } from '@coinbase-sample/core-ts';
17
- import { CoinbasePrimeClient } from '../client';
16
+ import { CoinbaseCallOptions, IPrimeApiClient } from '../clients';
18
17
  import { ListEntityPaymentMethodsRequest, ListEntityPaymentMethodsResponse, GetPaymentMethodRequest, GetPaymentMethodResponse } from './types';
19
18
  export interface IPaymentMethodsService {
20
19
  listEntityPaymentMethods(request: ListEntityPaymentMethodsRequest, options?: CoinbaseCallOptions): Promise<ListEntityPaymentMethodsResponse>;
@@ -22,7 +21,7 @@ export interface IPaymentMethodsService {
22
21
  }
23
22
  export declare class PaymentMethodsService implements IPaymentMethodsService {
24
23
  private client;
25
- constructor(client: CoinbasePrimeClient);
24
+ constructor(client: IPrimeApiClient);
26
25
  listEntityPaymentMethods(request: ListEntityPaymentMethodsRequest, options?: CoinbaseCallOptions): Promise<ListEntityPaymentMethodsResponse>;
27
26
  getPaymentMethod(request: GetPaymentMethodRequest, options?: CoinbaseCallOptions): Promise<GetPaymentMethodResponse>;
28
27
  }
@@ -13,8 +13,7 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- import { CoinbaseCallOptions } from '@coinbase-sample/core-ts';
17
- import { CoinbasePrimeClient } from '../client';
16
+ import { CoinbaseCallOptions, IPrimeApiClient } from '../clients';
18
17
  import { GetPortfolioRequest, GetPortfolioResponse, GetPortfolioCreditRequest, GetPortfolioCreditResponse, GetCounterpartyIdRequest, GetCounterpartyIdResponse, ListPortfoliosResponse, ListPortfoliosRequest } from './types';
19
18
  export interface IPortfoliosService {
20
19
  getPortfolio(request: GetPortfolioRequest, options?: CoinbaseCallOptions): Promise<GetPortfolioResponse>;
@@ -24,7 +23,7 @@ export interface IPortfoliosService {
24
23
  }
25
24
  export declare class PortfoliosService implements IPortfoliosService {
26
25
  private client;
27
- constructor(client: CoinbasePrimeClient);
26
+ constructor(client: IPrimeApiClient);
28
27
  getPortfolio(request: GetPortfolioRequest, options?: CoinbaseCallOptions): Promise<GetPortfolioResponse>;
29
28
  getPortfolioCredit(request: GetPortfolioCreditRequest, options?: CoinbaseCallOptions): Promise<GetPortfolioCreditResponse>;
30
29
  getCounterpartyId(request: GetCounterpartyIdRequest, options?: CoinbaseCallOptions): Promise<GetCounterpartyIdResponse>;
@@ -13,8 +13,7 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- import { CoinbaseCallOptions } from '@coinbase-sample/core-ts';
17
- import { CoinbasePrimeClient } from '../client';
16
+ import { IPrimeApiClient, CoinbaseCallOptions } from '../clients';
18
17
  import { ListAggregateEntityPositionsRequest, ListAggregateEntityPositionsResponse, ListEntityPositionsRequest, ListEntityPositionsResponse } from './types';
19
18
  export interface IPositionsService {
20
19
  listAggregateEntityPositions(request: ListAggregateEntityPositionsRequest, options?: CoinbaseCallOptions): Promise<ListAggregateEntityPositionsResponse>;
@@ -22,7 +21,7 @@ export interface IPositionsService {
22
21
  }
23
22
  export declare class PositionsService implements IPositionsService {
24
23
  private client;
25
- constructor(client: CoinbasePrimeClient);
24
+ constructor(client: IPrimeApiClient);
26
25
  listAggregateEntityPositions(request: ListAggregateEntityPositionsRequest, options?: CoinbaseCallOptions): Promise<ListAggregateEntityPositionsResponse>;
27
26
  listEntityPositions(request: ListEntityPositionsRequest, options?: CoinbaseCallOptions): Promise<ListEntityPositionsResponse>;
28
27
  }
@@ -13,14 +13,13 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- import { CoinbaseCallOptions } from '@coinbase-sample/core-ts';
17
- import { CoinbasePrimeClient } from '../client';
16
+ import { IPrimeApiClient, CoinbaseCallOptions } from '../clients';
18
17
  import { ListProductsRequest, ListProductsResponse } from './types';
19
18
  export interface IProductsService {
20
19
  listProducts(request: ListProductsRequest, options?: CoinbaseCallOptions): Promise<ListProductsResponse>;
21
20
  }
22
21
  export declare class ProductsService implements IProductsService {
23
22
  private client;
24
- constructor(client: CoinbasePrimeClient);
23
+ constructor(client: IPrimeApiClient);
25
24
  listProducts(request: ListProductsRequest, options?: CoinbaseCallOptions): Promise<ListProductsResponse>;
26
25
  }
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Copyright 2025-present Coinbase Global, Inc.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ export { ActivitiesService, IActivitiesService } from './activities';
17
+ export { AddressBooksService, IAddressBooksService } from './addressBooks';
18
+ export { AllocationService, IAllocationService } from './allocations';
19
+ export { AssetsService, IAssetsService } from './assets';
20
+ export { BalancesService, IBalancesService } from './balances';
21
+ export { CommissionService, ICommissionService } from './commission';
22
+ export { FinancingService, IFinancingService } from './financing';
23
+ export { FuturesService, IFuturesService } from './futures';
24
+ export { InvoicesService, IInvoicesService } from './invoices';
25
+ export { OnchainAddressBookService } from './onchainAddressBook';
26
+ export { OrdersService, IOrdersService } from './orders';
27
+ export { PaymentMethodsService, IPaymentMethodsService, } from './paymentMethods';
28
+ export { PortfoliosService, IPortfoliosService } from './portfolios';
29
+ export { PositionsService, IPositionsService } from './positions';
30
+ export { ProductsService, IProductsService } from './products';
31
+ export { StakingService, IStakingService } from './staking';
32
+ export { TransactionsService, ITransactionsService } from './transactions';
33
+ export { UsersService, IUsersService } from './users';
34
+ export { WalletsService, IWalletsService } from './wallets';
35
+ export type * from './model/';
36
+ export * from './model/enums/';
37
+ export type { IPrimeApiClient, // Interface for client dependency injection
38
+ CoinbaseCallOptions, // Optional parameters for service methods
39
+ Method, } from './clients';
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Copyright 2025-present Coinbase Global, Inc.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ import { CoinbasePrimeCredentials } from '../credentials';
17
+ /**
18
+ * Shared utility function to create credentials from environment variables
19
+ * Used by both CoinbasePrimeClient and CoinbasePrimeClientWithServices
20
+ *
21
+ * Automatically attempts to load .env file if dotenv is available.
22
+ * If dotenv is not installed or .env file doesn't exist, falls back to
23
+ * using environment variables set directly.
24
+ *
25
+ * @advanced For custom scenarios. Most users should use Client.fromEnv() instead.
26
+ * @example
27
+ * ```typescript
28
+ * // Basic usage (recommended)
29
+ * const client = CoinbasePrimeClient.fromEnv();
30
+ *
31
+ * // Advanced usage (custom scenarios)
32
+ * const credentials = createCredentialsFromEnv();
33
+ * const client = new CoinbasePrimeClient(credentials, 'custom-url');
34
+ * ```
35
+ */
36
+ export declare function createCredentialsFromEnv(): CoinbasePrimeCredentials;
@@ -13,14 +13,15 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- import { CoinbaseCallOptions } from '@coinbase-sample/core-ts';
17
- import { CoinbasePrimeClient } from 'src/client';
16
+ import { CoinbaseCallOptions, IPrimeApiClient } from '../clients';
17
+ import { SortDirection } from '../model/enums/SortDirection';
18
18
  /**
19
19
  * Base type for paginated requests
20
20
  */
21
21
  export type BasePaginatedRequest = {
22
22
  cursor?: string;
23
23
  limit?: number;
24
+ sortDirection?: SortDirection.Asc | SortDirection.Desc | undefined;
24
25
  };
25
26
  /**
26
27
  * API call signature for paginated endpoints
@@ -116,5 +117,5 @@ export declare const ResponseExtractors: {
116
117
  /**
117
118
  * Get the default pagination options for a client
118
119
  */
119
- export declare function getDefaultPaginationOptions(client: CoinbasePrimeClient, options: CoinbaseCallOptions | undefined): CoinbaseCallOptions;
120
- export declare function getQueryParams(client: CoinbasePrimeClient, request: BasePaginatedRequest): Record<string, string | number | string[]>;
120
+ export declare function getDefaultPaginationOptions(client: IPrimeApiClient, options: CoinbaseCallOptions | undefined): CoinbaseCallOptions;
121
+ export declare function getQueryParams(client: IPrimeApiClient, request: BasePaginatedRequest): Record<string, string | number | string[]>;
@@ -13,8 +13,7 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- import { CoinbaseCallOptions } from '@coinbase-sample/core-ts';
17
- import { CoinbasePrimeClient } from '../client';
16
+ import { IPrimeApiClient, CoinbaseCallOptions } from '../clients';
18
17
  import { CreateStakeRequest, CreateStakeResponse, CreateUnstakeRequest, CreateUnstakeResponse, CreatePortfolioStakeRequest, CreatePortfolioStakeResponse, CreatePortfolioUnstakeRequest, CreatePortfolioUnstakeResponse } from './types';
19
18
  export interface IStakingService {
20
19
  createStake(request: CreateStakeRequest, options?: CoinbaseCallOptions): Promise<CreateStakeResponse>;
@@ -24,7 +23,7 @@ export interface IStakingService {
24
23
  }
25
24
  export declare class StakingService implements IStakingService {
26
25
  private client;
27
- constructor(client: CoinbasePrimeClient);
26
+ constructor(client: IPrimeApiClient);
28
27
  createStake(request: CreateStakeRequest, options?: CoinbaseCallOptions): Promise<CreateStakeResponse>;
29
28
  createUnstake(request: CreateUnstakeRequest, options?: CoinbaseCallOptions): Promise<CreateUnstakeResponse>;
30
29
  createPortfolioStake(request: CreatePortfolioStakeRequest, options?: CoinbaseCallOptions): Promise<CreatePortfolioStakeResponse>;
@@ -13,8 +13,7 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- import { CoinbaseCallOptions } from '@coinbase-sample/core-ts';
17
- import { CoinbasePrimeClient } from '../client';
16
+ import { IPrimeApiClient, CoinbaseCallOptions } from '../clients';
18
17
  import { CreateConversionRequest, CreateConversionResponse, CreateOnchainTransactionRequest, CreateOnchainTransactionResponse, CreateTransferRequest, CreateTransferResponse, CreateWithdrawalRequest, CreateWithdrawalResponse, GetTransactionRequest, GetTransactionResponse, ListPortfolioTransactionsRequest, ListPortfolioTransactionsResponse, ListWalletTransactionsRequest, ListWalletTransactionsResponse } from './types';
19
18
  export interface ITransactionsService {
20
19
  getTransaction(request: GetTransactionRequest, options?: CoinbaseCallOptions): Promise<GetTransactionResponse>;
@@ -27,7 +26,7 @@ export interface ITransactionsService {
27
26
  }
28
27
  export declare class TransactionsService implements ITransactionsService {
29
28
  private client;
30
- constructor(client: CoinbasePrimeClient);
29
+ constructor(client: IPrimeApiClient);
31
30
  getTransaction(request: GetTransactionRequest, options?: CoinbaseCallOptions): Promise<GetTransactionResponse>;
32
31
  listPortfolioTransactions(request: ListPortfolioTransactionsRequest, options?: CoinbaseCallOptions): Promise<ListPortfolioTransactionsResponse>;
33
32
  listWalletTransactions(request: ListWalletTransactionsRequest, options?: CoinbaseCallOptions): Promise<ListWalletTransactionsResponse>;
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Copyright 2025-present Coinbase Global, Inc.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ export type * from './model/';
17
+ export * from './model/enums/';
18
+ export type { IActivitiesService } from './activities';
19
+ export type { IAddressBooksService } from './addressBooks';
20
+ export type { IAllocationService } from './allocations';
21
+ export type { IAssetsService } from './assets';
22
+ export type { IBalancesService } from './balances';
23
+ export type { ICommissionService } from './commission';
24
+ export type { IFinancingService } from './financing';
25
+ export type { IFuturesService } from './futures';
26
+ export type { IInvoicesService } from './invoices';
27
+ export type { OnchainAddressBookService } from './onchainAddressBook';
28
+ export type { IOrdersService } from './orders';
29
+ export type { IPaymentMethodsService } from './paymentMethods';
30
+ export type { IPortfoliosService } from './portfolios';
31
+ export type { IPositionsService } from './positions';
32
+ export type { IProductsService } from './products';
33
+ export type { IStakingService } from './staking';
34
+ export type { ITransactionsService } from './transactions';
35
+ export type { IUsersService } from './users';
36
+ export type { IWalletsService } from './wallets';
37
+ export { IPrimeApiClient, CoinbasePrimeClientConfig, CoinbaseClient, CoinbaseHttpClientRetryOptions, CoinbaseCallOptions, Method, CoinbaseClientException, CoinbaseError, CoinbaseResponse, TransformRequestFn, TransformResponseFn, } from './clients';
@@ -13,8 +13,7 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- import { CoinbaseCallOptions } from '@coinbase-sample/core-ts';
17
- import { CoinbasePrimeClient } from '../client';
16
+ import { IPrimeApiClient, CoinbaseCallOptions } from '../clients';
18
17
  import { ListPortfolioUsersRequest, ListPortfolioUsersResponse, ListUsersRequest, ListUsersResponse } from './types';
19
18
  export interface IUsersService {
20
19
  listUsers(request: ListUsersRequest, options?: CoinbaseCallOptions): Promise<ListUsersResponse>;
@@ -22,7 +21,7 @@ export interface IUsersService {
22
21
  }
23
22
  export declare class UsersService implements IUsersService {
24
23
  private client;
25
- constructor(client: CoinbasePrimeClient);
24
+ constructor(client: IPrimeApiClient);
26
25
  listUsers(request: ListUsersRequest, options?: CoinbaseCallOptions): Promise<ListUsersResponse>;
27
26
  listPortfolioUsers(request: ListPortfolioUsersRequest, options?: CoinbaseCallOptions): Promise<ListPortfolioUsersResponse>;
28
27
  }
@@ -13,8 +13,7 @@
13
13
  * See the License for the specific language governing permissions and
14
14
  * limitations under the License.
15
15
  */
16
- import { CoinbaseCallOptions } from '@coinbase-sample/core-ts';
17
- import { CoinbasePrimeClient } from '../client';
16
+ import { IPrimeApiClient, CoinbaseCallOptions } from '../clients';
18
17
  import { ListWalletsRequest, ListWalletsResponse, GetWalletRequest, GetWalletResponse, GetWalletDepositInstructionsRequest, GetWalletDepositInstructionsResponse, ListWalletAddressesRequest, ListWalletAddressesResponse, CreateWalletRequest, CreateWalletResponse, CreateWalletDepositAddressRequest, CreateWalletDepositAddressResponse } from './types';
19
18
  export interface IWalletsService {
20
19
  listWallets(request: ListWalletsRequest, options?: CoinbaseCallOptions): Promise<ListWalletsResponse>;
@@ -26,7 +25,7 @@ export interface IWalletsService {
26
25
  }
27
26
  export declare class WalletsService implements IWalletsService {
28
27
  private client;
29
- constructor(client: CoinbasePrimeClient);
28
+ constructor(client: IPrimeApiClient);
30
29
  listWallets(request: ListWalletsRequest, options?: CoinbaseCallOptions): Promise<ListWalletsResponse>;
31
30
  getWallet(request: GetWalletRequest, options?: CoinbaseCallOptions): Promise<GetWalletResponse>;
32
31
  getWalletDepositInstructions(request: GetWalletDepositInstructionsRequest, options?: CoinbaseCallOptions): Promise<GetWalletDepositInstructionsResponse>;