From 8de1a40a546158e515db18f206c242fe8cec05d9 Mon Sep 17 00:00:00 2001 From: Jerko J <83344666+JJ-Cro@users.noreply.github.com> Date: Tue, 5 Nov 2024 12:46:42 +0100 Subject: [PATCH] v1.0.3 feat(): - added new endpoint for Prime(getPortfolioFills) - updated types --- docs/endpointFunctionList.md | 81 ++++++++++--------- .../apidoc/CBPrimeClient/getPortfolioFills.js | 20 +++++ package-lock.json | 4 +- package.json | 2 +- src/CBPrimeClient.ts | 14 ++++ src/types/request/coinbase-international.ts | 1 + src/types/request/coinbase-prime.ts | 9 +++ 7 files changed, 88 insertions(+), 43 deletions(-) create mode 100644 examples/apidoc/CBPrimeClient/getPortfolioFills.js diff --git a/docs/endpointFunctionList.md b/docs/endpointFunctionList.md index 47ea7fa..211a80b 100644 --- a/docs/endpointFunctionList.md +++ b/docs/endpointFunctionList.md @@ -274,46 +274,47 @@ This table includes all endpoints from the official Exchange API docs and corres | Function | AUTH | HTTP Method | Endpoint | | -------- | :------: | :------: | -------- | -| [createPortfolioAllocations()](https://github.com/tiagosiebler/coinbase-api/blob/master/src/CBPrimeClient.ts#L64) | :closed_lock_with_key: | POST | `/v1/allocations` | -| [createPortfolioNetAllocations()](https://github.com/tiagosiebler/coinbase-api/blob/master/src/CBPrimeClient.ts#L75) | :closed_lock_with_key: | POST | `/v1/allocations/net` | -| [getPortfolioAllocations()](https://github.com/tiagosiebler/coinbase-api/blob/master/src/CBPrimeClient.ts#L86) | :closed_lock_with_key: | GET | `/v1/portfolios/{portfolio_id}/allocations` | -| [getAllocationById()](https://github.com/tiagosiebler/coinbase-api/blob/master/src/CBPrimeClient.ts#L98) | :closed_lock_with_key: | GET | `/v1/portfolios/{portfolio_id}/allocations/{allocation_id}` | -| [getNetAllocationsByNettingId()](https://github.com/tiagosiebler/coinbase-api/blob/master/src/CBPrimeClient.ts#L113) | :closed_lock_with_key: | GET | `/v1/portfolios/{portfolio_id}/allocations/net/{netting_id}` | -| [getInvoices()](https://github.com/tiagosiebler/coinbase-api/blob/master/src/CBPrimeClient.ts#L134) | :closed_lock_with_key: | GET | `/v1/entities/{entity_id}/invoices` | -| [getAssets()](https://github.com/tiagosiebler/coinbase-api/blob/master/src/CBPrimeClient.ts#L150) | :closed_lock_with_key: | GET | `/v1/entities/{entity_id}/assets` | -| [getEntityPaymentMethods()](https://github.com/tiagosiebler/coinbase-api/blob/master/src/CBPrimeClient.ts#L165) | :closed_lock_with_key: | GET | `/v1/entities/{entity_id}/payment-methods` | -| [getEntityPaymentMethod()](https://github.com/tiagosiebler/coinbase-api/blob/master/src/CBPrimeClient.ts#L174) | :closed_lock_with_key: | GET | `/v1/entities/{entity_id}/payment-methods/{payment_method_id}` | -| [getUsers()](https://github.com/tiagosiebler/coinbase-api/blob/master/src/CBPrimeClient.ts#L195) | :closed_lock_with_key: | GET | `/v1/entities/{entity_id}/users` | -| [getPortfolioUsers()](https://github.com/tiagosiebler/coinbase-api/blob/master/src/CBPrimeClient.ts#L205) | :closed_lock_with_key: | GET | `/v1/portfolios/{portfolio_id}/users` | -| [getPortfolios()](https://github.com/tiagosiebler/coinbase-api/blob/master/src/CBPrimeClient.ts#L221) | :closed_lock_with_key: | GET | `/v1/portfolios` | -| [getPortfolioById()](https://github.com/tiagosiebler/coinbase-api/blob/master/src/CBPrimeClient.ts#L230) | :closed_lock_with_key: | GET | `/v1/portfolios/{portfolio_id}` | -| [getPortfolioCreditInformation()](https://github.com/tiagosiebler/coinbase-api/blob/master/src/CBPrimeClient.ts#L239) | :closed_lock_with_key: | GET | `/v1/portfolios/{portfolio_id}/credit` | -| [getActivities()](https://github.com/tiagosiebler/coinbase-api/blob/master/src/CBPrimeClient.ts#L256) | :closed_lock_with_key: | GET | `/v1/portfolios/{portfolio_id}/activities` | -| [getActivityById()](https://github.com/tiagosiebler/coinbase-api/blob/master/src/CBPrimeClient.ts#L266) | :closed_lock_with_key: | GET | `/v1/portfolios/{portfolio_id}/activities/{activity_id}` | -| [getAddressBook()](https://github.com/tiagosiebler/coinbase-api/blob/master/src/CBPrimeClient.ts#L287) | :closed_lock_with_key: | GET | `/v1/portfolios/{portfolio_id}/address_book` | -| [createAddressBookEntry()](https://github.com/tiagosiebler/coinbase-api/blob/master/src/CBPrimeClient.ts#L300) | :closed_lock_with_key: | POST | `/v1/portfolios/{portfolio_id}/address_book` | -| [getPortfolioBalances()](https://github.com/tiagosiebler/coinbase-api/blob/master/src/CBPrimeClient.ts#L320) | :closed_lock_with_key: | GET | `/v1/portfolios/{portfolio_id}/balances` | -| [getWalletBalance()](https://github.com/tiagosiebler/coinbase-api/blob/master/src/CBPrimeClient.ts#L334) | :closed_lock_with_key: | GET | `/v1/portfolios/{portfolio_id}/wallets/{wallet_id}/balance` | -| [getWeb3WalletBalances()](https://github.com/tiagosiebler/coinbase-api/blob/master/src/CBPrimeClient.ts#L349) | :closed_lock_with_key: | GET | `/v1/portfolios/{portfolio_id}/wallets/{wallet_id}/web3_balances` | -| [getPortfolioCommission()](https://github.com/tiagosiebler/coinbase-api/blob/master/src/CBPrimeClient.ts#L370) | :closed_lock_with_key: | GET | `/v1/portfolios/{portfolio_id}/commission` | -| [getOpenOrders()](https://github.com/tiagosiebler/coinbase-api/blob/master/src/CBPrimeClient.ts#L385) | :closed_lock_with_key: | GET | `/v1/portfolios/{portfolio_id}/open_orders` | -| [submitOrder()](https://github.com/tiagosiebler/coinbase-api/blob/master/src/CBPrimeClient.ts#L395) | :closed_lock_with_key: | POST | `/v1/portfolios/{portfolio_id}/order` | -| [getOrderPreview()](https://github.com/tiagosiebler/coinbase-api/blob/master/src/CBPrimeClient.ts#L408) | :closed_lock_with_key: | POST | `/v1/portfolios/{portfolio_id}/order_preview` | -| [getPortfolioOrders()](https://github.com/tiagosiebler/coinbase-api/blob/master/src/CBPrimeClient.ts#L420) | :closed_lock_with_key: | GET | `/v1/portfolios/{portfolio_id}/orders` | -| [getOrderById()](https://github.com/tiagosiebler/coinbase-api/blob/master/src/CBPrimeClient.ts#L430) | :closed_lock_with_key: | GET | `/v1/portfolios/{portfolio_id}/orders/{order_id}` | -| [cancelOrder()](https://github.com/tiagosiebler/coinbase-api/blob/master/src/CBPrimeClient.ts#L443) | :closed_lock_with_key: | POST | `/v1/portfolios/{portfolio_id}/orders/{order_id}/cancel` | -| [getOrderFills()](https://github.com/tiagosiebler/coinbase-api/blob/master/src/CBPrimeClient.ts#L458) | :closed_lock_with_key: | GET | `/v1/portfolios/{portfolio_id}/orders/{order_id}/fills` | -| [getPortfolioProducts()](https://github.com/tiagosiebler/coinbase-api/blob/master/src/CBPrimeClient.ts#L477) | :closed_lock_with_key: | GET | `/v1/portfolios/{portfolio_id}/products` | -| [getPortfolioTransactions()](https://github.com/tiagosiebler/coinbase-api/blob/master/src/CBPrimeClient.ts#L493) | :closed_lock_with_key: | GET | `/v1/portfolios/{portfolio_id}/transactions` | -| [getTransactionById()](https://github.com/tiagosiebler/coinbase-api/blob/master/src/CBPrimeClient.ts#L508) | :closed_lock_with_key: | GET | `/v1/portfolios/{portfolio_id}/transactions/{transaction_id}` | -| [createConversion()](https://github.com/tiagosiebler/coinbase-api/blob/master/src/CBPrimeClient.ts#L523) | :closed_lock_with_key: | POST | `/v1/portfolios/{portfolio_id}/wallets/{wallet_id}/conversion` | -| [getWalletTransactions()](https://github.com/tiagosiebler/coinbase-api/blob/master/src/CBPrimeClient.ts#L536) | :closed_lock_with_key: | GET | `/v1/portfolios/{portfolio_id}/wallets/{wallet_id}/transactions` | -| [createTransfer()](https://github.com/tiagosiebler/coinbase-api/blob/master/src/CBPrimeClient.ts#L551) | :closed_lock_with_key: | POST | `/v1/portfolios/{portfolio_id}/wallets/{wallet_id}/transfers` | -| [createWithdrawal()](https://github.com/tiagosiebler/coinbase-api/blob/master/src/CBPrimeClient.ts#L564) | :closed_lock_with_key: | POST | `/v1/portfolios/{portfolio_id}/wallets/{wallet_id}/withdrawals` | -| [getPortfolioWallets()](https://github.com/tiagosiebler/coinbase-api/blob/master/src/CBPrimeClient.ts#L583) | :closed_lock_with_key: | GET | `/v1/portfolios/{portfolio_id}/wallets` | -| [createWallet()](https://github.com/tiagosiebler/coinbase-api/blob/master/src/CBPrimeClient.ts#L593) | :closed_lock_with_key: | POST | `/v1/portfolios/{portfolio_id}/wallets` | -| [getWalletById()](https://github.com/tiagosiebler/coinbase-api/blob/master/src/CBPrimeClient.ts#L605) | :closed_lock_with_key: | GET | `/v1/portfolios/{portfolio_id}/wallets/{wallet_id}` | -| [getWalletDepositInstructions()](https://github.com/tiagosiebler/coinbase-api/blob/master/src/CBPrimeClient.ts#L620) | :closed_lock_with_key: | GET | `/v1/portfolios/{portfolio_id}/wallets/{wallet_id}/deposit_instructions` | +| [createPortfolioAllocations()](https://github.com/tiagosiebler/coinbase-api/blob/master/src/CBPrimeClient.ts#L65) | :closed_lock_with_key: | POST | `/v1/allocations` | +| [createPortfolioNetAllocations()](https://github.com/tiagosiebler/coinbase-api/blob/master/src/CBPrimeClient.ts#L76) | :closed_lock_with_key: | POST | `/v1/allocations/net` | +| [getPortfolioAllocations()](https://github.com/tiagosiebler/coinbase-api/blob/master/src/CBPrimeClient.ts#L87) | :closed_lock_with_key: | GET | `/v1/portfolios/{portfolio_id}/allocations` | +| [getAllocationById()](https://github.com/tiagosiebler/coinbase-api/blob/master/src/CBPrimeClient.ts#L99) | :closed_lock_with_key: | GET | `/v1/portfolios/{portfolio_id}/allocations/{allocation_id}` | +| [getNetAllocationsByNettingId()](https://github.com/tiagosiebler/coinbase-api/blob/master/src/CBPrimeClient.ts#L114) | :closed_lock_with_key: | GET | `/v1/portfolios/{portfolio_id}/allocations/net/{netting_id}` | +| [getInvoices()](https://github.com/tiagosiebler/coinbase-api/blob/master/src/CBPrimeClient.ts#L135) | :closed_lock_with_key: | GET | `/v1/entities/{entity_id}/invoices` | +| [getAssets()](https://github.com/tiagosiebler/coinbase-api/blob/master/src/CBPrimeClient.ts#L151) | :closed_lock_with_key: | GET | `/v1/entities/{entity_id}/assets` | +| [getEntityPaymentMethods()](https://github.com/tiagosiebler/coinbase-api/blob/master/src/CBPrimeClient.ts#L166) | :closed_lock_with_key: | GET | `/v1/entities/{entity_id}/payment-methods` | +| [getEntityPaymentMethod()](https://github.com/tiagosiebler/coinbase-api/blob/master/src/CBPrimeClient.ts#L175) | :closed_lock_with_key: | GET | `/v1/entities/{entity_id}/payment-methods/{payment_method_id}` | +| [getUsers()](https://github.com/tiagosiebler/coinbase-api/blob/master/src/CBPrimeClient.ts#L196) | :closed_lock_with_key: | GET | `/v1/entities/{entity_id}/users` | +| [getPortfolioUsers()](https://github.com/tiagosiebler/coinbase-api/blob/master/src/CBPrimeClient.ts#L206) | :closed_lock_with_key: | GET | `/v1/portfolios/{portfolio_id}/users` | +| [getPortfolios()](https://github.com/tiagosiebler/coinbase-api/blob/master/src/CBPrimeClient.ts#L222) | :closed_lock_with_key: | GET | `/v1/portfolios` | +| [getPortfolioById()](https://github.com/tiagosiebler/coinbase-api/blob/master/src/CBPrimeClient.ts#L231) | :closed_lock_with_key: | GET | `/v1/portfolios/{portfolio_id}` | +| [getPortfolioCreditInformation()](https://github.com/tiagosiebler/coinbase-api/blob/master/src/CBPrimeClient.ts#L240) | :closed_lock_with_key: | GET | `/v1/portfolios/{portfolio_id}/credit` | +| [getActivities()](https://github.com/tiagosiebler/coinbase-api/blob/master/src/CBPrimeClient.ts#L257) | :closed_lock_with_key: | GET | `/v1/portfolios/{portfolio_id}/activities` | +| [getActivityById()](https://github.com/tiagosiebler/coinbase-api/blob/master/src/CBPrimeClient.ts#L267) | :closed_lock_with_key: | GET | `/v1/portfolios/{portfolio_id}/activities/{activity_id}` | +| [getAddressBook()](https://github.com/tiagosiebler/coinbase-api/blob/master/src/CBPrimeClient.ts#L288) | :closed_lock_with_key: | GET | `/v1/portfolios/{portfolio_id}/address_book` | +| [createAddressBookEntry()](https://github.com/tiagosiebler/coinbase-api/blob/master/src/CBPrimeClient.ts#L301) | :closed_lock_with_key: | POST | `/v1/portfolios/{portfolio_id}/address_book` | +| [getPortfolioBalances()](https://github.com/tiagosiebler/coinbase-api/blob/master/src/CBPrimeClient.ts#L321) | :closed_lock_with_key: | GET | `/v1/portfolios/{portfolio_id}/balances` | +| [getWalletBalance()](https://github.com/tiagosiebler/coinbase-api/blob/master/src/CBPrimeClient.ts#L335) | :closed_lock_with_key: | GET | `/v1/portfolios/{portfolio_id}/wallets/{wallet_id}/balance` | +| [getWeb3WalletBalances()](https://github.com/tiagosiebler/coinbase-api/blob/master/src/CBPrimeClient.ts#L350) | :closed_lock_with_key: | GET | `/v1/portfolios/{portfolio_id}/wallets/{wallet_id}/web3_balances` | +| [getPortfolioCommission()](https://github.com/tiagosiebler/coinbase-api/blob/master/src/CBPrimeClient.ts#L371) | :closed_lock_with_key: | GET | `/v1/portfolios/{portfolio_id}/commission` | +| [getPortfolioFills()](https://github.com/tiagosiebler/coinbase-api/blob/master/src/CBPrimeClient.ts#L389) | :closed_lock_with_key: | GET | `/v1/portfolios/{portfolio_id}/fills` | +| [getOpenOrders()](https://github.com/tiagosiebler/coinbase-api/blob/master/src/CBPrimeClient.ts#L399) | :closed_lock_with_key: | GET | `/v1/portfolios/{portfolio_id}/open_orders` | +| [submitOrder()](https://github.com/tiagosiebler/coinbase-api/blob/master/src/CBPrimeClient.ts#L409) | :closed_lock_with_key: | POST | `/v1/portfolios/{portfolio_id}/order` | +| [getOrderPreview()](https://github.com/tiagosiebler/coinbase-api/blob/master/src/CBPrimeClient.ts#L422) | :closed_lock_with_key: | POST | `/v1/portfolios/{portfolio_id}/order_preview` | +| [getPortfolioOrders()](https://github.com/tiagosiebler/coinbase-api/blob/master/src/CBPrimeClient.ts#L434) | :closed_lock_with_key: | GET | `/v1/portfolios/{portfolio_id}/orders` | +| [getOrderById()](https://github.com/tiagosiebler/coinbase-api/blob/master/src/CBPrimeClient.ts#L444) | :closed_lock_with_key: | GET | `/v1/portfolios/{portfolio_id}/orders/{order_id}` | +| [cancelOrder()](https://github.com/tiagosiebler/coinbase-api/blob/master/src/CBPrimeClient.ts#L457) | :closed_lock_with_key: | POST | `/v1/portfolios/{portfolio_id}/orders/{order_id}/cancel` | +| [getOrderFills()](https://github.com/tiagosiebler/coinbase-api/blob/master/src/CBPrimeClient.ts#L472) | :closed_lock_with_key: | GET | `/v1/portfolios/{portfolio_id}/orders/{order_id}/fills` | +| [getPortfolioProducts()](https://github.com/tiagosiebler/coinbase-api/blob/master/src/CBPrimeClient.ts#L491) | :closed_lock_with_key: | GET | `/v1/portfolios/{portfolio_id}/products` | +| [getPortfolioTransactions()](https://github.com/tiagosiebler/coinbase-api/blob/master/src/CBPrimeClient.ts#L507) | :closed_lock_with_key: | GET | `/v1/portfolios/{portfolio_id}/transactions` | +| [getTransactionById()](https://github.com/tiagosiebler/coinbase-api/blob/master/src/CBPrimeClient.ts#L522) | :closed_lock_with_key: | GET | `/v1/portfolios/{portfolio_id}/transactions/{transaction_id}` | +| [createConversion()](https://github.com/tiagosiebler/coinbase-api/blob/master/src/CBPrimeClient.ts#L537) | :closed_lock_with_key: | POST | `/v1/portfolios/{portfolio_id}/wallets/{wallet_id}/conversion` | +| [getWalletTransactions()](https://github.com/tiagosiebler/coinbase-api/blob/master/src/CBPrimeClient.ts#L550) | :closed_lock_with_key: | GET | `/v1/portfolios/{portfolio_id}/wallets/{wallet_id}/transactions` | +| [createTransfer()](https://github.com/tiagosiebler/coinbase-api/blob/master/src/CBPrimeClient.ts#L565) | :closed_lock_with_key: | POST | `/v1/portfolios/{portfolio_id}/wallets/{wallet_id}/transfers` | +| [createWithdrawal()](https://github.com/tiagosiebler/coinbase-api/blob/master/src/CBPrimeClient.ts#L578) | :closed_lock_with_key: | POST | `/v1/portfolios/{portfolio_id}/wallets/{wallet_id}/withdrawals` | +| [getPortfolioWallets()](https://github.com/tiagosiebler/coinbase-api/blob/master/src/CBPrimeClient.ts#L597) | :closed_lock_with_key: | GET | `/v1/portfolios/{portfolio_id}/wallets` | +| [createWallet()](https://github.com/tiagosiebler/coinbase-api/blob/master/src/CBPrimeClient.ts#L607) | :closed_lock_with_key: | POST | `/v1/portfolios/{portfolio_id}/wallets` | +| [getWalletById()](https://github.com/tiagosiebler/coinbase-api/blob/master/src/CBPrimeClient.ts#L619) | :closed_lock_with_key: | GET | `/v1/portfolios/{portfolio_id}/wallets/{wallet_id}` | +| [getWalletDepositInstructions()](https://github.com/tiagosiebler/coinbase-api/blob/master/src/CBPrimeClient.ts#L634) | :closed_lock_with_key: | GET | `/v1/portfolios/{portfolio_id}/wallets/{wallet_id}/deposit_instructions` | # CBCommerceClient.ts diff --git a/examples/apidoc/CBPrimeClient/getPortfolioFills.js b/examples/apidoc/CBPrimeClient/getPortfolioFills.js new file mode 100644 index 0000000..7b2808e --- /dev/null +++ b/examples/apidoc/CBPrimeClient/getPortfolioFills.js @@ -0,0 +1,20 @@ +const { CBPrimeClient } = require('coinbase-api'); + + // This example shows how to call this coinbase API endpoint with either node.js, javascript (js) or typescript (ts) with the npm module "coinbase-api" for coinbase exchange + // This coinbase API SDK is available on npm via "npm install coinbase-api" + // ENDPOINT: /v1/portfolios/{portfolio_id}/fills + // METHOD: GET + // PUBLIC: NO + +const client = new CBPrimeClient({ + apiKey: 'insert_api_key_here', + apiSecret: 'insert_api_secret_here', +}); + +client.getPortfolioFills(params) + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/package-lock.json b/package-lock.json index 3a04dac..864388a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "coinbase-api", - "version": "1.0.2", + "version": "1.0.3", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "coinbase-api", - "version": "1.0.2", + "version": "1.0.3", "license": "MIT", "dependencies": { "axios": "^1.7.4", diff --git a/package.json b/package.json index e557d96..b3b5baf 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "coinbase-api", - "version": "1.0.2", + "version": "1.0.3", "description": "Node.js SDK for Coinbase's REST APIs and WebSockets, with TypeScript & strong end to end tests.", "scripts": { "clean": "rm -rf dist", diff --git a/src/CBPrimeClient.ts b/src/CBPrimeClient.ts index 47c33a6..e5dc415 100644 --- a/src/CBPrimeClient.ts +++ b/src/CBPrimeClient.ts @@ -21,6 +21,7 @@ import { GetPrimeOrderFillsRequest, GetPrimeOrderPreviewRequest, GetPrimePortfolioAllocationsRequest, + GetPrimePortfolioFillsRequest, GetPrimePortfolioOrdersRequest, GetPrimePortfolioProductsRequest, GetPrimePortfolioTransactionsRequest, @@ -377,6 +378,19 @@ export class CBPrimeClient extends BaseRestClient { * */ + /** + * List Portfolio Fills + * + * Retrieve fills on a given portfolio. + * + * Note: This endpoint requires a start_date and returns a payload with a default + * limit of 100 if not specified. The maximum allowed limit is 3000. + */ + getPortfolioFills(params: GetPrimePortfolioFillsRequest): Promise { + const { portfolio_id, ...query } = params; + return this.getPrivate(`/v1/portfolios/${portfolio_id}/fills`, query); + } + /** * List Open Orders * diff --git a/src/types/request/coinbase-international.ts b/src/types/request/coinbase-international.ts index 5a43d0d..41d3f37 100644 --- a/src/types/request/coinbase-international.ts +++ b/src/types/request/coinbase-international.ts @@ -52,6 +52,7 @@ export interface SubmitINTXOrderRequest { stp_mode?: string; post_only?: boolean; close_only?: boolean; + algo_strategy: boolean; } export interface GetINTXOpenOrdersRequest { diff --git a/src/types/request/coinbase-prime.ts b/src/types/request/coinbase-prime.ts index 6e1cbcc..92f5831 100644 --- a/src/types/request/coinbase-prime.ts +++ b/src/types/request/coinbase-prime.ts @@ -158,6 +158,15 @@ export interface GetPrimeWeb3WalletBalancesRequest { * */ +export interface GetPrimePortfolioFillsRequest { + portfolio_id: string; + start_date: string; + end_date?: string; + limit?: number; + cursor?: string; + sort_direction?: 'DESC' | 'ASC'; +} + export interface GetPrimeOpenOrdersRequest { portfolio_id: string; product_ids?: string[];