@coinbase-sample/prime-sdk-ts 0.6.2 → 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 (56) hide show
  1. package/README.md +207 -67
  2. package/dist/addressBooks/index.js +2 -2
  3. package/dist/allocations/index.js +3 -3
  4. package/dist/client-manual.js +84 -0
  5. package/dist/client-modular.js +57 -0
  6. package/dist/client-only.js +31 -0
  7. package/dist/{client.js → clients/client.js} +12 -2
  8. package/dist/clients/clientWithServices.js +323 -0
  9. package/dist/{types/client.d.ts → clients/clientWithServicesTypes.js} +3 -6
  10. package/dist/clients/index.js +28 -0
  11. package/dist/clients/types.js +2 -0
  12. package/dist/constants.js +1 -1
  13. package/dist/futures/index.js +4 -4
  14. package/dist/index.js +27 -18
  15. package/dist/onchainAddressBook/index.js +4 -4
  16. package/dist/orders/index.js +6 -6
  17. package/dist/services.js +75 -0
  18. package/dist/shared/envUtils.js +66 -0
  19. package/dist/staking/index.js +5 -5
  20. package/dist/transactions/index.js +5 -5
  21. package/dist/types/activities/index.d.ts +2 -3
  22. package/dist/types/addressBooks/index.d.ts +2 -3
  23. package/dist/types/allocations/index.d.ts +2 -3
  24. package/dist/types/assets/index.d.ts +2 -3
  25. package/dist/types/balances/index.d.ts +2 -3
  26. package/dist/types/client-manual.d.ts +58 -0
  27. package/dist/types/client-modular.d.ts +39 -0
  28. package/dist/types/client-only.d.ts +18 -0
  29. package/dist/types/clients/client.d.ts +27 -0
  30. package/dist/types/clients/clientWithServices.d.ts +229 -0
  31. package/dist/types/clients/clientWithServicesTypes.d.ts +115 -0
  32. package/dist/types/clients/index.d.ts +19 -0
  33. package/dist/types/clients/types.d.ts +48 -0
  34. package/dist/types/commission/index.d.ts +2 -3
  35. package/dist/types/constants.d.ts +1 -1
  36. package/dist/types/financing/index.d.ts +2 -3
  37. package/dist/types/futures/index.d.ts +2 -3
  38. package/dist/types/index.d.ts +2 -1
  39. package/dist/types/invoices/index.d.ts +2 -3
  40. package/dist/types/onchainAddressBook/index.d.ts +2 -3
  41. package/dist/types/orders/index.d.ts +2 -3
  42. package/dist/types/paymentMethods/index.d.ts +2 -3
  43. package/dist/types/portfolios/index.d.ts +2 -3
  44. package/dist/types/positions/index.d.ts +2 -3
  45. package/dist/types/products/index.d.ts +2 -3
  46. package/dist/types/services.d.ts +39 -0
  47. package/dist/types/shared/envUtils.d.ts +36 -0
  48. package/dist/types/shared/paginatedResponse.d.ts +3 -4
  49. package/dist/types/staking/index.d.ts +2 -3
  50. package/dist/types/transactions/index.d.ts +2 -3
  51. package/dist/types/types.d.ts +37 -0
  52. package/dist/types/users/index.d.ts +2 -3
  53. package/dist/types/wallets/index.d.ts +2 -3
  54. package/dist/types.js +39 -0
  55. package/dist/wallets/index.js +3 -3
  56. package/package.json +32 -1
@@ -0,0 +1,66 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createCredentialsFromEnv = createCredentialsFromEnv;
4
+ /**
5
+ * Copyright 2025-present Coinbase Global, Inc.
6
+ *
7
+ * Licensed under the Apache License, Version 2.0 (the "License");
8
+ * you may not use this file except in compliance with the License.
9
+ * You may obtain a copy of the License at
10
+ *
11
+ * http://www.apache.org/licenses/LICENSE-2.0
12
+ *
13
+ * Unless required by applicable law or agreed to in writing, software
14
+ * distributed under the License is distributed on an "AS IS" BASIS,
15
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ * See the License for the specific language governing permissions and
17
+ * limitations under the License.
18
+ */
19
+ const credentials_1 = require("../credentials");
20
+ /**
21
+ * Shared utility function to create credentials from environment variables
22
+ * Used by both CoinbasePrimeClient and CoinbasePrimeClientWithServices
23
+ *
24
+ * Automatically attempts to load .env file if dotenv is available.
25
+ * If dotenv is not installed or .env file doesn't exist, falls back to
26
+ * using environment variables set directly.
27
+ *
28
+ * @advanced For custom scenarios. Most users should use Client.fromEnv() instead.
29
+ * @example
30
+ * ```typescript
31
+ * // Basic usage (recommended)
32
+ * const client = CoinbasePrimeClient.fromEnv();
33
+ *
34
+ * // Advanced usage (custom scenarios)
35
+ * const credentials = createCredentialsFromEnv();
36
+ * const client = new CoinbasePrimeClient(credentials, 'custom-url');
37
+ * ```
38
+ */
39
+ function createCredentialsFromEnv() {
40
+ // Try to load .env file if dotenv is available (optional)
41
+ try {
42
+ require('dotenv').config();
43
+ }
44
+ catch (error) {
45
+ // dotenv not installed or .env file doesn't exist - that's fine
46
+ // Environment variables might be set directly via shell, Docker, CI/CD, etc.
47
+ }
48
+ const credsJson = process.env.PRIME_CREDENTIALS;
49
+ if (!credsJson) {
50
+ throw new Error('PRIME_CREDENTIALS environment variable is required. ' +
51
+ 'Set it to a JSON string with AccessKey, SecretKey, and Passphrase. ' +
52
+ 'You can set it directly (export PRIME_CREDENTIALS=\'{"AccessKey":"...","SecretKey":"...","Passphrase":"..."}\') ' +
53
+ 'or create a .env file with PRIME_CREDENTIALS={"AccessKey":"...","SecretKey":"...","Passphrase":"..."}.');
54
+ }
55
+ let creds;
56
+ try {
57
+ creds = JSON.parse(credsJson);
58
+ }
59
+ catch (error) {
60
+ throw new Error('PRIME_CREDENTIALS must be valid JSON with AccessKey, SecretKey, and Passphrase fields.');
61
+ }
62
+ if (!creds.AccessKey || !creds.SecretKey || !creds.Passphrase) {
63
+ throw new Error('PRIME_CREDENTIALS must contain AccessKey, SecretKey, and Passphrase fields.');
64
+ }
65
+ return new credentials_1.CoinbasePrimeCredentials(creds.AccessKey, creds.SecretKey, creds.Passphrase);
66
+ }
@@ -25,7 +25,7 @@ exports.StakingService = void 0;
25
25
  * See the License for the specific language governing permissions and
26
26
  * limitations under the License.
27
27
  */
28
- const core_ts_1 = require("@coinbase-sample/core-ts");
28
+ const clients_1 = require("../clients");
29
29
  class StakingService {
30
30
  constructor(client) {
31
31
  this.client = client;
@@ -35,7 +35,7 @@ class StakingService {
35
35
  const bodyParams = Object.assign(Object.assign({}, request), { portfolioId: undefined, walletId: undefined });
36
36
  const response = yield this.client.request({
37
37
  url: `portfolios/${request.portfolioId}/wallets/${request.walletId}/staking/initiate`,
38
- method: core_ts_1.Method.POST,
38
+ method: clients_1.Method.POST,
39
39
  bodyParams,
40
40
  callOptions: options,
41
41
  });
@@ -47,7 +47,7 @@ class StakingService {
47
47
  const bodyParams = Object.assign(Object.assign({}, request), { portfolioId: undefined, walletId: undefined });
48
48
  const response = yield this.client.request({
49
49
  url: `portfolios/${request.portfolioId}/wallets/${request.walletId}/staking/unstake`,
50
- method: core_ts_1.Method.POST,
50
+ method: clients_1.Method.POST,
51
51
  bodyParams,
52
52
  callOptions: options,
53
53
  });
@@ -59,7 +59,7 @@ class StakingService {
59
59
  const bodyParams = Object.assign(Object.assign({}, request), { portfolioId: undefined });
60
60
  const response = yield this.client.request({
61
61
  url: `portfolios/${request.portfolioId}/staking/initiate`,
62
- method: core_ts_1.Method.POST,
62
+ method: clients_1.Method.POST,
63
63
  bodyParams,
64
64
  callOptions: options,
65
65
  });
@@ -71,7 +71,7 @@ class StakingService {
71
71
  const bodyParams = Object.assign(Object.assign({}, request), { portfolioId: undefined });
72
72
  const response = yield this.client.request({
73
73
  url: `portfolios/${request.portfolioId}/staking/unstake`,
74
- method: core_ts_1.Method.POST,
74
+ method: clients_1.Method.POST,
75
75
  bodyParams,
76
76
  callOptions: options,
77
77
  });
@@ -36,7 +36,7 @@ exports.TransactionsService = void 0;
36
36
  * See the License for the specific language governing permissions and
37
37
  * limitations under the License.
38
38
  */
39
- const core_ts_1 = require("@coinbase-sample/core-ts");
39
+ const clients_1 = require("../clients");
40
40
  const paginatedResponse_1 = require("../shared/paginatedResponse");
41
41
  class TransactionsService {
42
42
  constructor(client) {
@@ -91,7 +91,7 @@ class TransactionsService {
91
91
  const response = yield this.client.request({
92
92
  url: `portfolios/${request.portfolioId}/wallets/${request.walletId}/conversion`,
93
93
  bodyParams,
94
- method: core_ts_1.Method.POST,
94
+ method: clients_1.Method.POST,
95
95
  callOptions: options,
96
96
  });
97
97
  return response.data;
@@ -103,7 +103,7 @@ class TransactionsService {
103
103
  const response = yield this.client.request({
104
104
  url: `portfolios/${request.portfolioId}/wallets/${request.walletId}/transfers`,
105
105
  bodyParams,
106
- method: core_ts_1.Method.POST,
106
+ method: clients_1.Method.POST,
107
107
  callOptions: options,
108
108
  });
109
109
  return response.data;
@@ -115,7 +115,7 @@ class TransactionsService {
115
115
  const response = yield this.client.request({
116
116
  url: `portfolios/${request.portfolioId}/wallets/${request.walletId}/withdrawals`,
117
117
  bodyParams,
118
- method: core_ts_1.Method.POST,
118
+ method: clients_1.Method.POST,
119
119
  callOptions: options,
120
120
  });
121
121
  return response.data;
@@ -127,7 +127,7 @@ class TransactionsService {
127
127
  const response = yield this.client.request({
128
128
  url: `portfolios/${request.portfolioId}/wallets/${request.walletId}/onchain_transaction`,
129
129
  bodyParams,
130
- method: core_ts_1.Method.POST,
130
+ method: clients_1.Method.POST,
131
131
  callOptions: options,
132
132
  });
133
133
  return response.data;
@@ -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 { GetActivityRequest, GetActivityResponse, GetPortfolioActivitiesRequest, GetPortfolioActivityResponse, ListPortfolioActivitiesRequest, ListPortfolioActivitiesResponse, ListEntityActivitiesRequest, ListEntityActivitiesResponse } from './types';
19
18
  export interface IActivitiesService {
20
19
  getActivity(request: GetActivityRequest): Promise<GetActivityResponse>;
@@ -24,7 +23,7 @@ export interface IActivitiesService {
24
23
  }
25
24
  export declare class ActivitiesService implements IActivitiesService {
26
25
  private client;
27
- constructor(client: CoinbasePrimeClient);
26
+ constructor(client: IPrimeApiClient);
28
27
  getActivity(request: GetActivityRequest, options?: CoinbaseCallOptions): Promise<GetActivityResponse>;
29
28
  getPortfolioActivity(request: GetPortfolioActivitiesRequest, options?: CoinbaseCallOptions): Promise<GetPortfolioActivityResponse>;
30
29
  listEntityActivities(request: ListEntityActivitiesRequest, options?: CoinbaseCallOptions): Promise<ListEntityActivitiesResponse>;
@@ -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 { ListAddressBooksRequest, ListAddressBooksResponse, CreateAddressBookRequest, CreateAddressBookResponse } from './types';
19
18
  export interface IAddressBooksService {
20
19
  listAddressBooks(request: ListAddressBooksRequest, options?: CoinbaseCallOptions): Promise<ListAddressBooksResponse>;
@@ -22,7 +21,7 @@ export interface IAddressBooksService {
22
21
  }
23
22
  export declare class AddressBooksService implements IAddressBooksService {
24
23
  private client;
25
- constructor(client: CoinbasePrimeClient);
24
+ constructor(client: IPrimeApiClient);
26
25
  listAddressBooks(request: ListAddressBooksRequest, options?: CoinbaseCallOptions): Promise<ListAddressBooksResponse>;
27
26
  createAddressBook(request: CreateAddressBookRequest, options?: CoinbaseCallOptions): Promise<CreateAddressBookResponse>;
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 { CreateAllocationRequest, CreateAllocationResponse, CreateNetAllocationRequest, CreateNetAllocationResponse, ListPortfolioAllocationsRequest, ListPortfolioAllocationsResponse, ListNetAllocationsRequest, ListNetAllocationsResponse, GetAllocationRequest, GetAllocationResponse } from './types';
19
18
  export interface IAllocationService {
20
19
  createAllocation(request: CreateAllocationRequest, options?: CoinbaseCallOptions): Promise<CreateAllocationResponse>;
@@ -25,7 +24,7 @@ export interface IAllocationService {
25
24
  }
26
25
  export declare class AllocationService implements IAllocationService {
27
26
  private client;
28
- constructor(client: CoinbasePrimeClient);
27
+ constructor(client: IPrimeApiClient);
29
28
  createAllocation(request: CreateAllocationRequest, options?: CoinbaseCallOptions): Promise<CreateAllocationResponse>;
30
29
  createNetAllocation(request: CreateNetAllocationRequest, options?: CoinbaseCallOptions): Promise<CreateNetAllocationResponse>;
31
30
  listPortfolioAllocations(request: ListPortfolioAllocationsRequest, options?: CoinbaseCallOptions): Promise<ListPortfolioAllocationsResponse>;
@@ -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 { ListAssetsRequest, ListAssetsResponse } from './types';
19
18
  export interface IAssetsService {
20
19
  listAssets(request: ListAssetsRequest, options?: CoinbaseCallOptions): Promise<ListAssetsResponse>;
21
20
  }
22
21
  export declare class AssetsService implements IAssetsService {
23
22
  private client;
24
- constructor(client: CoinbasePrimeClient);
23
+ constructor(client: IPrimeApiClient);
25
24
  listAssets(request: ListAssetsRequest, options?: CoinbaseCallOptions): Promise<ListAssetsResponse>;
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 { GetWalletBalanceRequest, GetWalletBalanceResponse, ListOnchainWalletBalancesRequest, ListOnchainWalletBalancesResponse, ListPortfolioBalancesRequest, ListPortfolioBalancesResponse, ListEntityBalancesRequest, ListEntityBalancesResponse } from './types';
19
18
  export interface IBalancesService {
20
19
  listPortfolioBalances(request: ListPortfolioBalancesRequest, options?: CoinbaseCallOptions): Promise<ListPortfolioBalancesResponse>;
@@ -24,7 +23,7 @@ export interface IBalancesService {
24
23
  }
25
24
  export declare class BalancesService implements IBalancesService {
26
25
  private client;
27
- constructor(client: CoinbasePrimeClient);
26
+ constructor(client: IPrimeApiClient);
28
27
  listPortfolioBalances(request: ListPortfolioBalancesRequest, options?: CoinbaseCallOptions): Promise<ListPortfolioBalancesResponse>;
29
28
  getWalletBalance(request: GetWalletBalanceRequest, options?: CoinbaseCallOptions): Promise<GetWalletBalanceResponse>;
30
29
  listOnchainWalletBalances(request: ListOnchainWalletBalancesRequest, options?: CoinbaseCallOptions): Promise<ListOnchainWalletBalancesResponse>;
@@ -0,0 +1,58 @@
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 { IPrimeApiClient, CoinbasePrimeClient, CoinbasePrimeClientConfig, CoinbaseClient, CoinbaseHttpClientRetryOptions, CoinbaseCallOptions, Method, CoinbaseClientException, CoinbaseError, CoinbaseResponse, TransformRequestFn, TransformResponseFn, } from './clients';
17
+ export { CoinbasePrimeCredentials } from './credentials';
18
+ export { createCredentialsFromEnv } from './shared/envUtils';
19
+ export { ActivitiesService, IActivitiesService } from './activities';
20
+ export { AddressBooksService, IAddressBooksService } from './addressBooks';
21
+ export { AllocationService, IAllocationService } from './allocations';
22
+ export { AssetsService, IAssetsService } from './assets';
23
+ export { BalancesService, IBalancesService } from './balances';
24
+ export { CommissionService, ICommissionService } from './commission';
25
+ export { FinancingService, IFinancingService } from './financing';
26
+ export { FuturesService, IFuturesService } from './futures';
27
+ export { InvoicesService, IInvoicesService } from './invoices';
28
+ export { OnchainAddressBookService } from './onchainAddressBook';
29
+ export { OrdersService, IOrdersService } from './orders';
30
+ export { PaymentMethodsService, IPaymentMethodsService, } from './paymentMethods';
31
+ export { PortfoliosService, IPortfoliosService } from './portfolios';
32
+ export { PositionsService, IPositionsService } from './positions';
33
+ export { ProductsService, IProductsService } from './products';
34
+ export { StakingService, IStakingService } from './staking';
35
+ export { TransactionsService, ITransactionsService } from './transactions';
36
+ export { UsersService, IUsersService } from './users';
37
+ export { WalletsService, IWalletsService } from './wallets';
38
+ export type * from './model/';
39
+ export * from './model/enums/';
40
+ export type { GetActivityRequest, GetActivityResponse, GetPortfolioActivitiesRequest, GetPortfolioActivityResponse, ListEntityActivitiesRequest, ListEntityActivitiesResponse, ListPortfolioActivitiesRequest, ListPortfolioActivitiesResponse, } from './activities/types';
41
+ export type { CreateAddressBookRequest, CreateAddressBookResponse, ListAddressBooksRequest, ListAddressBooksResponse, } from './addressBooks/types';
42
+ export type { CreateAllocationRequest, CreateAllocationResponse, CreateNetAllocationRequest, CreateNetAllocationResponse, ListNetAllocationsRequest, ListNetAllocationsResponse, ListPortfolioAllocationsRequest, ListPortfolioAllocationsResponse, GetAllocationRequest, GetAllocationResponse, } from './allocations/types';
43
+ export type { ListAssetsRequest, ListAssetsResponse } from './assets/types';
44
+ export type { GetWalletBalanceRequest, GetWalletBalanceResponse, ListOnchainWalletBalancesRequest, ListOnchainWalletBalancesResponse, ListPortfolioBalancesRequest, ListPortfolioBalancesResponse, ListEntityBalancesRequest, ListEntityBalancesResponse, } from './balances/types';
45
+ export type { GetPortfolioCommissionRequest, GetPortfolioCommissionResponse, } from './commission/types';
46
+ export type { AcceptQuoteRequest, AcceptQuoteResponse, CancelOrderRequest, CancelOrderResponse, CreateOrderPreviewRequest, CreateOrderPreviewResponse, CreateOrderRequest, CreateOrderResponse, CreateQuoteRequest, CreateQuoteResponse, GetOrderRequest, GetOrderResponse, GetOrderEditHistoryRequest, GetOrderEditHistoryResponse, ListOpenOrdersRequest, ListOpenOrdersResponse, ListOrderFillsRequest, ListOrderFillsResponse, ListPortfolioFillsRequest, ListPortfolioFillsResponse, ListPortfolioOrdersRequest, ListPortfolioOrdersResponse, } from './orders/types';
47
+ export type { ListExistingLocatesRequest, ListExistingLocatesResponse, ListInterestAccrualsRequest, ListInterestAccrualsResponse, ListPortfolioInterestAccrualsRequest, ListPortfolioInterestAccrualsResponse, ListMarginCallSummariesRequest, ListMarginCallSummariesResponse, ListMarginConversionsRequest, ListMarginConversionsResponse, GetEntityLocateAvailabilitiesRequest, GetEntityLocateAvailabilitiesResponse, GetMarginInformationRequest, GetMarginInformationResponse, GetPortfolioBuyingPowerRequest, GetPortfolioBuyingPowerResponse, GetPortfolioCreditInformationRequest, GetPortfolioCreditInformationResponse, GetPortfolioWithdrawalPowerRequest, GetPortfolioWithdrawalPowerResponse, GetFcmMarginCallDetailsRequest, GetFcmMarginCallDetailsResponse, GetFcmRiskLimitsRequest, GetFcmRiskLimitsResponse, GetTieredPricingFeesRequest, GetTieredPricingFeesResponse, CreateNewLocatesRequest, CreateNewLocatesResponse, } from './financing/types';
48
+ export type { CancelEntitySweepRequest, CancelEntitySweepResponse, GetEntityFuturesBalanceRequest, GetEntityFuturesBalanceResponse, GetEntityFuturesPositionsRequest, GetEntityFuturesPositionsResponse, ListEntityFuturesSweepsRequest, ListEntityFuturesSweepsResponse, ScheduleEntityFuturesSweepRequest, ScheduleEntityFuturesSweepResponse, UpdateEntityFuturesAutoSweepRequest, UpdateEntityFuturesAutoSweepResponse, } from './futures/types';
49
+ export type { ListInvoicesRequest, ListInvoicesResponse, } from './invoices/types';
50
+ export type { CreateOnchainAddressBookEntryRequest, CreateOnchainAddressBookEntryResponse, DeleteOnchainAddressBookEntryRequest, DeleteOnchainAddressBookEntryResponse, ListOnchainAddressBookRequest, ListOnchainAddressBookResponse, UpdateOnchainAddressBookEntryRequest, UpdateOnchainAddressBookEntryResponse, } from './onchainAddressBook/types';
51
+ export type { GetPaymentMethodRequest, GetPaymentMethodResponse, ListEntityPaymentMethodsRequest, ListEntityPaymentMethodsResponse, } from './paymentMethods/types';
52
+ export type { ListPortfoliosRequest, ListPortfoliosResponse, GetPortfolioCreditRequest, GetPortfolioCreditResponse, GetPortfolioRequest, GetPortfolioResponse, GetCounterpartyIdRequest, GetCounterpartyIdResponse, } from './portfolios/types';
53
+ export type { ListAggregateEntityPositionsRequest, ListAggregateEntityPositionsResponse, ListEntityPositionsRequest, ListEntityPositionsResponse, } from './positions/types';
54
+ export type { ListProductsRequest, ListProductsResponse, } from './products/types';
55
+ export type { CreateStakeRequest, CreateStakeResponse, CreateUnstakeRequest, CreateUnstakeResponse, CreatePortfolioStakeRequest, CreatePortfolioStakeResponse, CreatePortfolioUnstakeRequest, CreatePortfolioUnstakeResponse, } from './staking/types';
56
+ export type { CreateConversionRequest, CreateConversionResponse, CreateOnchainTransactionRequest, CreateOnchainTransactionResponse, CreateTransferRequest, CreateTransferResponse, CreateWithdrawalRequest, CreateWithdrawalResponse, GetTransactionRequest, GetTransactionResponse, ListPortfolioTransactionsRequest, ListPortfolioTransactionsResponse, ListWalletTransactionsRequest, ListWalletTransactionsResponse, } from './transactions/types';
57
+ export type { ListPortfolioUsersRequest, ListPortfolioUsersResponse, ListUsersRequest, ListUsersResponse, } from './users/types';
58
+ export type { CreateWalletRequest, CreateWalletResponse, CreateWalletDepositAddressRequest, CreateWalletDepositAddressResponse, GetWalletDepositInstructionsRequest, GetWalletDepositInstructionsResponse, GetWalletRequest, GetWalletResponse, ListWalletAddressesRequest, ListWalletAddressesResponse, ListWalletsRequest, ListWalletsResponse, } from './wallets/types';
@@ -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 { IPrimeApiClient, CoinbasePrimeClientWithServices, CoinbasePrimeClientConfig, CoinbaseClient, CoinbaseHttpClientRetryOptions, CoinbaseCallOptions, Method, CoinbaseClientException, CoinbaseError, CoinbaseResponse, TransformRequestFn, TransformResponseFn, } from './clients';
17
+ export { CoinbasePrimeCredentials } from './credentials';
18
+ export { createCredentialsFromEnv } from './shared/envUtils';
19
+ export type * from './model/';
20
+ export * from './model/enums/';
21
+ export type { IActivitiesService } from './activities';
22
+ export type { IAddressBooksService } from './addressBooks';
23
+ export type { IAllocationService } from './allocations';
24
+ export type { IAssetsService } from './assets';
25
+ export type { IBalancesService } from './balances';
26
+ export type { ICommissionService } from './commission';
27
+ export type { IFinancingService } from './financing';
28
+ export type { IFuturesService } from './futures';
29
+ export type { IInvoicesService } from './invoices';
30
+ export type { OnchainAddressBookService } from './onchainAddressBook';
31
+ export type { IOrdersService } from './orders';
32
+ export type { IPaymentMethodsService } from './paymentMethods';
33
+ export type { IPortfoliosService } from './portfolios';
34
+ export type { IPositionsService } from './positions';
35
+ export type { IProductsService } from './products';
36
+ export type { IStakingService } from './staking';
37
+ export type { ITransactionsService } from './transactions';
38
+ export type { IUsersService } from './users';
39
+ export type { IWalletsService } from './wallets';
@@ -0,0 +1,18 @@
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, CoinbasePrimeClientWithServices, CoinbasePrimeClientConfig, IPrimeApiClient, CoinbaseClient, CoinbaseHttpClientRetryOptions, CoinbaseCallOptions, Method, CoinbaseClientException, CoinbaseError, CoinbaseResponse, TransformRequestFn, TransformResponseFn, } from './clients';
17
+ export { CoinbasePrimeCredentials } from './credentials';
18
+ export { createCredentialsFromEnv } from './shared/envUtils';
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Copyright 2024-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 { CoinbaseClient } from '@coinbase-sample/core-ts';
17
+ import { CoinbasePrimeCredentials } from '../credentials';
18
+ import type { CoinbasePrimeClientConfig, IPrimeApiClient } from './types';
19
+ export declare class CoinbasePrimeClient extends CoinbaseClient implements IPrimeApiClient {
20
+ constructor(credentials?: CoinbasePrimeCredentials, apiBasePath?: string, options?: CoinbasePrimeClientConfig);
21
+ /**
22
+ * Create a client from environment variables
23
+ * Requires PRIME_CREDENTIALS environment variable with JSON containing:
24
+ * { "AccessKey": "...", "SecretKey": "...", "Passphrase": "..." }
25
+ */
26
+ static fromEnv(apiBaseUrl?: string, options?: CoinbasePrimeClientConfig): CoinbasePrimeClient;
27
+ }
@@ -0,0 +1,229 @@
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 { CoinbaseClient } from '@coinbase-sample/core-ts';
17
+ import { CoinbasePrimeCredentials } from '../credentials';
18
+ import type { CoinbasePrimeClientConfig, IPrimeApiClient } from './types';
19
+ import { LazyServiceGetters } from './clientWithServicesTypes';
20
+ import type { IActivitiesService } from '../activities';
21
+ import type { IAddressBooksService } from '../addressBooks';
22
+ import type { IAllocationService } from '../allocations';
23
+ import type { IAssetsService } from '../assets';
24
+ import type { IBalancesService } from '../balances';
25
+ import type { ICommissionService } from '../commission';
26
+ import type { IFinancingService } from '../financing';
27
+ import type { IFuturesService } from '../futures';
28
+ import type { IInvoicesService } from '../invoices';
29
+ import type { OnchainAddressBookService } from '../onchainAddressBook';
30
+ import type { IOrdersService } from '../orders';
31
+ import type { IPaymentMethodsService } from '../paymentMethods';
32
+ import type { IPortfoliosService } from '../portfolios';
33
+ import type { IPositionsService } from '../positions';
34
+ import type { IProductsService } from '../products';
35
+ import type { IStakingService } from '../staking';
36
+ import type { ITransactionsService } from '../transactions';
37
+ import type { IUsersService } from '../users';
38
+ import type { IWalletsService } from '../wallets';
39
+ /**
40
+ * Enhanced Coinbase Prime Client with lazy-loaded service getters.
41
+ * Services are only instantiated when first accessed, improving tree-shaking
42
+ * and reducing initial bundle size.
43
+ */
44
+ export declare class CoinbasePrimeClientWithServices extends CoinbaseClient implements LazyServiceGetters, IPrimeApiClient {
45
+ private _activitiesService?;
46
+ private _addressBooksService?;
47
+ private _allocationService?;
48
+ private _assetsService?;
49
+ private _balancesService?;
50
+ private _commissionService?;
51
+ private _financingService?;
52
+ private _futuresService?;
53
+ private _invoicesService?;
54
+ private _onchainAddressBookService?;
55
+ private _ordersService?;
56
+ private _paymentMethodsService?;
57
+ private _portfoliosService?;
58
+ private _positionsService?;
59
+ private _productsService?;
60
+ private _stakingService?;
61
+ private _transactionsService?;
62
+ private _usersService?;
63
+ private _walletsService?;
64
+ constructor(credentials?: CoinbasePrimeCredentials, apiBasePath?: string, options?: CoinbasePrimeClientConfig);
65
+ /**
66
+ * Create a client from environment variables
67
+ * Requires PRIME_CREDENTIALS environment variable with JSON containing:
68
+ * { "AccessKey": "...", "SecretKey": "...", "Passphrase": "..." }
69
+ */
70
+ static fromEnv(baseUrl?: string, options?: CoinbasePrimeClientConfig): CoinbasePrimeClientWithServices;
71
+ /**
72
+ * Lazy getter for ActivitiesService
73
+ * @example
74
+ * ```typescript
75
+ * const activities = await client.activities.listPortfolioActivities({ portfolioId });
76
+ * ```
77
+ */
78
+ get activities(): IActivitiesService;
79
+ /**
80
+ * Lazy getter for AddressBooksService
81
+ * @example
82
+ * ```typescript
83
+ * const addressBooks = await client.addressBooks.listAddressBooks({ portfolioId });
84
+ * ```
85
+ */
86
+ get addressBooks(): IAddressBooksService;
87
+ /**
88
+ * Lazy getter for AllocationService
89
+ * @example
90
+ * ```typescript
91
+ * const allocation = await client.allocations.createAllocation({ portfolioId, ... });
92
+ * ```
93
+ */
94
+ get allocations(): IAllocationService;
95
+ /**
96
+ * Lazy getter for AssetsService
97
+ * @example
98
+ * ```typescript
99
+ * const assets = await client.assets.listAssets({ entityId });
100
+ * ```
101
+ */
102
+ get assets(): IAssetsService;
103
+ /**
104
+ * Lazy getter for BalancesService
105
+ * @example
106
+ * ```typescript
107
+ * const balance = await client.balances.getWalletBalance({ portfolioId, walletId });
108
+ * ```
109
+ */
110
+ get balances(): IBalancesService;
111
+ /**
112
+ * Lazy getter for CommissionService
113
+ * @example
114
+ * ```typescript
115
+ * const commission = await client.commission.getPortfolioCommission({ portfolioId });
116
+ * ```
117
+ */
118
+ get commission(): ICommissionService;
119
+ /**
120
+ * Lazy getter for FinancingService
121
+ * @example
122
+ * ```typescript
123
+ * const buyingPower = await client.financing.getPortfolioBuyingPower({ portfolioId });
124
+ * ```
125
+ */
126
+ get financing(): IFinancingService;
127
+ /**
128
+ * Lazy getter for FuturesService
129
+ * @example
130
+ * ```typescript
131
+ * const positions = await client.futures.getEntityFuturesPositions({ entityId });
132
+ * ```
133
+ */
134
+ get futures(): IFuturesService;
135
+ /**
136
+ * Lazy getter for InvoicesService
137
+ * @example
138
+ * ```typescript
139
+ * const invoices = await client.invoices.listInvoices({ entityId });
140
+ * ```
141
+ */
142
+ get invoices(): IInvoicesService;
143
+ /**
144
+ * Lazy getter for OnchainAddressBookService
145
+ * @example
146
+ * ```typescript
147
+ * const addressBook = await client.onchainAddressBook.listOnchainAddressBook({ portfolioId });
148
+ * ```
149
+ */
150
+ get onchainAddressBook(): OnchainAddressBookService;
151
+ /**
152
+ * Lazy getter for OrdersService
153
+ * @example
154
+ * ```typescript
155
+ * const order = await client.orders.createOrder({
156
+ * portfolioId: "123",
157
+ * side: "BUY",
158
+ * productId: "BTC-USD",
159
+ * type: "MARKET",
160
+ * baseQuantity: "0.001"
161
+ * });
162
+ * ```
163
+ */
164
+ get orders(): IOrdersService;
165
+ /**
166
+ * Lazy getter for PaymentMethodsService
167
+ * @example
168
+ * ```typescript
169
+ * const paymentMethods = await client.paymentMethods.listEntityPaymentMethods({ entityId });
170
+ * ```
171
+ */
172
+ get paymentMethods(): IPaymentMethodsService;
173
+ /**
174
+ * Lazy getter for PortfoliosService
175
+ * @example
176
+ * ```typescript
177
+ * const portfolios = await client.portfolios.listPortfolios();
178
+ * ```
179
+ */
180
+ get portfolios(): IPortfoliosService;
181
+ /**
182
+ * Lazy getter for PositionsService
183
+ * @example
184
+ * ```typescript
185
+ * const positions = await client.positions.listAggregateEntityPositions({ entityId });
186
+ * ```
187
+ */
188
+ get positions(): IPositionsService;
189
+ /**
190
+ * Lazy getter for ProductsService
191
+ * @example
192
+ * ```typescript
193
+ * const products = await client.products.listProducts({ portfolioId });
194
+ * ```
195
+ */
196
+ get products(): IProductsService;
197
+ /**
198
+ * Lazy getter for StakingService
199
+ * @example
200
+ * ```typescript
201
+ * const stake = await client.staking.createStake({ walletId, assetId, amount });
202
+ * ```
203
+ */
204
+ get staking(): IStakingService;
205
+ /**
206
+ * Lazy getter for TransactionsService
207
+ * @example
208
+ * ```typescript
209
+ * const transaction = await client.transactions.getTransaction({ portfolioId, transactionId });
210
+ * ```
211
+ */
212
+ get transactions(): ITransactionsService;
213
+ /**
214
+ * Lazy getter for UsersService
215
+ * @example
216
+ * ```typescript
217
+ * const users = await client.users.listUsers({ entityId });
218
+ * ```
219
+ */
220
+ get users(): IUsersService;
221
+ /**
222
+ * Lazy getter for WalletsService
223
+ * @example
224
+ * ```typescript
225
+ * const wallets = await client.wallets.listWallets({ portfolioId });
226
+ * ```
227
+ */
228
+ get wallets(): IWalletsService;
229
+ }