From 268fd7c04ca26d48b305d91c9682c3df9121d68e Mon Sep 17 00:00:00 2001 From: Jerko J <83344666+JJ-Cro@users.noreply.github.com> Date: Mon, 18 Nov 2024 13:56:40 +0100 Subject: [PATCH 1/4] v1.0.5 feat(): added 4 new INTX Index endpoints --- docs/endpointFunctionList.md | 92 ++++++++++--------- .../CBInternationalClient/getIndexCandles.js | 20 ++++ .../getIndexComposition.js | 20 ++++ .../getIndexCompositionHistory.js | 20 ++++ .../CBInternationalClient/getIndexPrice.js | 20 ++++ package-lock.json | 4 +- package.json | 2 +- src/CBInternationalClient.ts | 50 ++++++++++ src/types/request/coinbase-international.ts | 20 ++++ 9 files changed, 201 insertions(+), 47 deletions(-) create mode 100644 examples/apidoc/CBInternationalClient/getIndexCandles.js create mode 100644 examples/apidoc/CBInternationalClient/getIndexComposition.js create mode 100644 examples/apidoc/CBInternationalClient/getIndexCompositionHistory.js create mode 100644 examples/apidoc/CBInternationalClient/getIndexPrice.js diff --git a/docs/endpointFunctionList.md b/docs/endpointFunctionList.md index 211a80b..77a91cd 100644 --- a/docs/endpointFunctionList.md +++ b/docs/endpointFunctionList.md @@ -223,50 +223,54 @@ This table includes all endpoints from the official Exchange API docs and corres | Function | AUTH | HTTP Method | Endpoint | | -------- | :------: | :------: | -------- | -| [getAssets()](https://github.com/tiagosiebler/coinbase-api/blob/master/src/CBInternationalClient.ts#L54) | | GET | `/api/v1/assets` | -| [getAssetDetails()](https://github.com/tiagosiebler/coinbase-api/blob/master/src/CBInternationalClient.ts#L63) | | GET | `/api/v1/assets/{asset}` | -| [getSupportedNetworksPerAsset()](https://github.com/tiagosiebler/coinbase-api/blob/master/src/CBInternationalClient.ts#L72) | | GET | `/api/v1/assets/{asset}/networks` | -| [getInstruments()](https://github.com/tiagosiebler/coinbase-api/blob/master/src/CBInternationalClient.ts#L87) | | GET | `/api/v1/instruments` | -| [getInstrumentDetails()](https://github.com/tiagosiebler/coinbase-api/blob/master/src/CBInternationalClient.ts#L96) | | GET | `/api/v1/instruments/{instrument}` | -| [getQuotePerInstrument()](https://github.com/tiagosiebler/coinbase-api/blob/master/src/CBInternationalClient.ts#L105) | | GET | `/api/v1/instruments/{instrument}/quote` | -| [getDailyTradingVolumes()](https://github.com/tiagosiebler/coinbase-api/blob/master/src/CBInternationalClient.ts#L114) | | GET | `/api/v1/instruments/volumes/daily` | -| [getAggregatedCandlesData()](https://github.com/tiagosiebler/coinbase-api/blob/master/src/CBInternationalClient.ts#L123) | | GET | `/api/v1/instruments/{instrument}/candles` | -| [getHistoricalFundingRates()](https://github.com/tiagosiebler/coinbase-api/blob/master/src/CBInternationalClient.ts#L133) | | GET | `/api/v1/instruments/{instrument}/funding` | -| [getPositionOffsets()](https://github.com/tiagosiebler/coinbase-api/blob/master/src/CBInternationalClient.ts#L153) | | GET | `/api/v1/position-offsets` | -| [submitOrder()](https://github.com/tiagosiebler/coinbase-api/blob/master/src/CBInternationalClient.ts#L168) | :closed_lock_with_key: | POST | `/api/v1/orders` | -| [getOpenOrders()](https://github.com/tiagosiebler/coinbase-api/blob/master/src/CBInternationalClient.ts#L179) | :closed_lock_with_key: | GET | `/api/v1/orders` | -| [cancelOrders()](https://github.com/tiagosiebler/coinbase-api/blob/master/src/CBInternationalClient.ts#L188) | :closed_lock_with_key: | DELETE | `/api/v1/orders` | -| [updateOpenOrder()](https://github.com/tiagosiebler/coinbase-api/blob/master/src/CBInternationalClient.ts#L199) | :closed_lock_with_key: | PUT | `/api/v1/orders/{id}` | -| [getOrderDetails()](https://github.com/tiagosiebler/coinbase-api/blob/master/src/CBInternationalClient.ts#L209) | :closed_lock_with_key: | GET | `/api/v1/orders/{id}` | -| [cancelOrder()](https://github.com/tiagosiebler/coinbase-api/blob/master/src/CBInternationalClient.ts#L219) | :closed_lock_with_key: | DELETE | `/api/v1/orders/{id}` | -| [getUserPortfolios()](https://github.com/tiagosiebler/coinbase-api/blob/master/src/CBInternationalClient.ts#L237) | :closed_lock_with_key: | GET | `/api/v1/portfolios` | -| [createPortfolio()](https://github.com/tiagosiebler/coinbase-api/blob/master/src/CBInternationalClient.ts#L246) | :closed_lock_with_key: | POST | `/api/v1/portfolios` | -| [updatePortfolioParameters()](https://github.com/tiagosiebler/coinbase-api/blob/master/src/CBInternationalClient.ts#L255) | :closed_lock_with_key: | PATCH | `/api/v1/portfolios` | -| [getUserPortfolio()](https://github.com/tiagosiebler/coinbase-api/blob/master/src/CBInternationalClient.ts#L266) | :closed_lock_with_key: | GET | `/api/v1/portfolios/{portfolio}` | -| [updatePortfolio()](https://github.com/tiagosiebler/coinbase-api/blob/master/src/CBInternationalClient.ts#L275) | :closed_lock_with_key: | PUT | `/api/v1/portfolios/{portfolio}` | -| [getPortfolioDetails()](https://github.com/tiagosiebler/coinbase-api/blob/master/src/CBInternationalClient.ts#L285) | :closed_lock_with_key: | GET | `/api/v1/portfolios/{portfolio}/detail` | -| [getPortfolioSummary()](https://github.com/tiagosiebler/coinbase-api/blob/master/src/CBInternationalClient.ts#L294) | :closed_lock_with_key: | GET | `/api/v1/portfolios/{portfolio}/summary` | -| [getPortfolioBalances()](https://github.com/tiagosiebler/coinbase-api/blob/master/src/CBInternationalClient.ts#L303) | :closed_lock_with_key: | GET | `/api/v1/portfolios/{portfolio}/balances` | -| [getBalanceForPortfolioAsset()](https://github.com/tiagosiebler/coinbase-api/blob/master/src/CBInternationalClient.ts#L312) | :closed_lock_with_key: | GET | `/api/v1/portfolios/{portfolio}/balances/{asset}` | -| [getPortfolioPositions()](https://github.com/tiagosiebler/coinbase-api/blob/master/src/CBInternationalClient.ts#L326) | :closed_lock_with_key: | GET | `/api/v1/portfolios/{portfolio}/positions` | -| [getPositionForPortfolioInstrument()](https://github.com/tiagosiebler/coinbase-api/blob/master/src/CBInternationalClient.ts#L335) | :closed_lock_with_key: | GET | `/api/v1/portfolios/{portfolio}/positions/{instrument}` | -| [getFillsByPortfolios()](https://github.com/tiagosiebler/coinbase-api/blob/master/src/CBInternationalClient.ts#L349) | :closed_lock_with_key: | GET | `/api/v1/portfolios/fills` | -| [getPortfolioFills()](https://github.com/tiagosiebler/coinbase-api/blob/master/src/CBInternationalClient.ts#L358) | :closed_lock_with_key: | GET | `/api/v1/portfolios/{portfolio}/fills` | -| [setCrossCollateral()](https://github.com/tiagosiebler/coinbase-api/blob/master/src/CBInternationalClient.ts#L368) | :closed_lock_with_key: | POST | `/api/v1/portfolios/{portfolio}/cross-collateral-enabled` | -| [setAutoMargin()](https://github.com/tiagosiebler/coinbase-api/blob/master/src/CBInternationalClient.ts#L385) | :closed_lock_with_key: | POST | `/api/v1/portfolios/{portfolio}/auto-margin-enabled` | -| [setPortfolioMarginOverride()](https://github.com/tiagosiebler/coinbase-api/blob/master/src/CBInternationalClient.ts#L398) | :closed_lock_with_key: | POST | `/api/v1/portfolios/margin` | -| [transferFundsBetweenPortfolios()](https://github.com/tiagosiebler/coinbase-api/blob/master/src/CBInternationalClient.ts#L410) | :closed_lock_with_key: | POST | `/api/v1/portfolios/transfer` | -| [transferPositionsBetweenPortfolios()](https://github.com/tiagosiebler/coinbase-api/blob/master/src/CBInternationalClient.ts#L422) | :closed_lock_with_key: | POST | `/api/v1/portfolios/transfer-position` | -| [getPortfolioFeeRates()](https://github.com/tiagosiebler/coinbase-api/blob/master/src/CBInternationalClient.ts#L435) | :closed_lock_with_key: | GET | `/api/v1/portfolios/fee-rates` | -| [getRankings()](https://github.com/tiagosiebler/coinbase-api/blob/master/src/CBInternationalClient.ts#L449) | :closed_lock_with_key: | GET | `/api/v1/rankings/statistics` | -| [getMatchingTransfers()](https://github.com/tiagosiebler/coinbase-api/blob/master/src/CBInternationalClient.ts#L468) | :closed_lock_with_key: | GET | `/api/v1/transfers` | -| [getTransfer()](https://github.com/tiagosiebler/coinbase-api/blob/master/src/CBInternationalClient.ts#L477) | :closed_lock_with_key: | GET | `/api/v1/transfers/{transfer_uuid}` | -| [withdrawToCryptoAddress()](https://github.com/tiagosiebler/coinbase-api/blob/master/src/CBInternationalClient.ts#L486) | :closed_lock_with_key: | POST | `/api/v1/transfers/withdraw` | -| [createCryptoAddress()](https://github.com/tiagosiebler/coinbase-api/blob/master/src/CBInternationalClient.ts#L497) | :closed_lock_with_key: | POST | `/api/v1/transfers/address` | -| [createCounterpartyId()](https://github.com/tiagosiebler/coinbase-api/blob/master/src/CBInternationalClient.ts#L510) | :closed_lock_with_key: | POST | `/api/v1/transfers/create-counterparty-id` | -| [validateCounterpartyId()](https://github.com/tiagosiebler/coinbase-api/blob/master/src/CBInternationalClient.ts#L521) | :closed_lock_with_key: | POST | `/api/v1/transfers/validate-counterparty-id` | -| [withdrawToCounterpartyId()](https://github.com/tiagosiebler/coinbase-api/blob/master/src/CBInternationalClient.ts#L532) | :closed_lock_with_key: | POST | `/api/v1/transfers/withdraw/counterparty` | -| [getFeeRateTiers()](https://github.com/tiagosiebler/coinbase-api/blob/master/src/CBInternationalClient.ts#L550) | :closed_lock_with_key: | GET | `/api/v1/fee-rate-tiers` | +| [getAssets()](https://github.com/tiagosiebler/coinbase-api/blob/master/src/CBInternationalClient.ts#L56) | | GET | `/api/v1/assets` | +| [getAssetDetails()](https://github.com/tiagosiebler/coinbase-api/blob/master/src/CBInternationalClient.ts#L65) | | GET | `/api/v1/assets/{asset}` | +| [getSupportedNetworksPerAsset()](https://github.com/tiagosiebler/coinbase-api/blob/master/src/CBInternationalClient.ts#L74) | | GET | `/api/v1/assets/{asset}/networks` | +| [getIndexComposition()](https://github.com/tiagosiebler/coinbase-api/blob/master/src/CBInternationalClient.ts#L89) | | GET | `/api/v1/index/{index}/composition` | +| [getIndexCompositionHistory()](https://github.com/tiagosiebler/coinbase-api/blob/master/src/CBInternationalClient.ts#L99) | | GET | `/api/v1/index/{index}/composition-history` | +| [getIndexPrice()](https://github.com/tiagosiebler/coinbase-api/blob/master/src/CBInternationalClient.ts#L111) | | GET | `/api/v1/index/{index}/price` | +| [getIndexCandles()](https://github.com/tiagosiebler/coinbase-api/blob/master/src/CBInternationalClient.ts#L121) | | GET | `/api/v1/index/{index}/candles` | +| [getInstruments()](https://github.com/tiagosiebler/coinbase-api/blob/master/src/CBInternationalClient.ts#L137) | | GET | `/api/v1/instruments` | +| [getInstrumentDetails()](https://github.com/tiagosiebler/coinbase-api/blob/master/src/CBInternationalClient.ts#L146) | | GET | `/api/v1/instruments/{instrument}` | +| [getQuotePerInstrument()](https://github.com/tiagosiebler/coinbase-api/blob/master/src/CBInternationalClient.ts#L155) | | GET | `/api/v1/instruments/{instrument}/quote` | +| [getDailyTradingVolumes()](https://github.com/tiagosiebler/coinbase-api/blob/master/src/CBInternationalClient.ts#L164) | | GET | `/api/v1/instruments/volumes/daily` | +| [getAggregatedCandlesData()](https://github.com/tiagosiebler/coinbase-api/blob/master/src/CBInternationalClient.ts#L173) | | GET | `/api/v1/instruments/{instrument}/candles` | +| [getHistoricalFundingRates()](https://github.com/tiagosiebler/coinbase-api/blob/master/src/CBInternationalClient.ts#L183) | | GET | `/api/v1/instruments/{instrument}/funding` | +| [getPositionOffsets()](https://github.com/tiagosiebler/coinbase-api/blob/master/src/CBInternationalClient.ts#L203) | | GET | `/api/v1/position-offsets` | +| [submitOrder()](https://github.com/tiagosiebler/coinbase-api/blob/master/src/CBInternationalClient.ts#L218) | :closed_lock_with_key: | POST | `/api/v1/orders` | +| [getOpenOrders()](https://github.com/tiagosiebler/coinbase-api/blob/master/src/CBInternationalClient.ts#L229) | :closed_lock_with_key: | GET | `/api/v1/orders` | +| [cancelOrders()](https://github.com/tiagosiebler/coinbase-api/blob/master/src/CBInternationalClient.ts#L238) | :closed_lock_with_key: | DELETE | `/api/v1/orders` | +| [updateOpenOrder()](https://github.com/tiagosiebler/coinbase-api/blob/master/src/CBInternationalClient.ts#L249) | :closed_lock_with_key: | PUT | `/api/v1/orders/{id}` | +| [getOrderDetails()](https://github.com/tiagosiebler/coinbase-api/blob/master/src/CBInternationalClient.ts#L259) | :closed_lock_with_key: | GET | `/api/v1/orders/{id}` | +| [cancelOrder()](https://github.com/tiagosiebler/coinbase-api/blob/master/src/CBInternationalClient.ts#L269) | :closed_lock_with_key: | DELETE | `/api/v1/orders/{id}` | +| [getUserPortfolios()](https://github.com/tiagosiebler/coinbase-api/blob/master/src/CBInternationalClient.ts#L287) | :closed_lock_with_key: | GET | `/api/v1/portfolios` | +| [createPortfolio()](https://github.com/tiagosiebler/coinbase-api/blob/master/src/CBInternationalClient.ts#L296) | :closed_lock_with_key: | POST | `/api/v1/portfolios` | +| [updatePortfolioParameters()](https://github.com/tiagosiebler/coinbase-api/blob/master/src/CBInternationalClient.ts#L305) | :closed_lock_with_key: | PATCH | `/api/v1/portfolios` | +| [getUserPortfolio()](https://github.com/tiagosiebler/coinbase-api/blob/master/src/CBInternationalClient.ts#L316) | :closed_lock_with_key: | GET | `/api/v1/portfolios/{portfolio}` | +| [updatePortfolio()](https://github.com/tiagosiebler/coinbase-api/blob/master/src/CBInternationalClient.ts#L325) | :closed_lock_with_key: | PUT | `/api/v1/portfolios/{portfolio}` | +| [getPortfolioDetails()](https://github.com/tiagosiebler/coinbase-api/blob/master/src/CBInternationalClient.ts#L335) | :closed_lock_with_key: | GET | `/api/v1/portfolios/{portfolio}/detail` | +| [getPortfolioSummary()](https://github.com/tiagosiebler/coinbase-api/blob/master/src/CBInternationalClient.ts#L344) | :closed_lock_with_key: | GET | `/api/v1/portfolios/{portfolio}/summary` | +| [getPortfolioBalances()](https://github.com/tiagosiebler/coinbase-api/blob/master/src/CBInternationalClient.ts#L353) | :closed_lock_with_key: | GET | `/api/v1/portfolios/{portfolio}/balances` | +| [getBalanceForPortfolioAsset()](https://github.com/tiagosiebler/coinbase-api/blob/master/src/CBInternationalClient.ts#L362) | :closed_lock_with_key: | GET | `/api/v1/portfolios/{portfolio}/balances/{asset}` | +| [getPortfolioPositions()](https://github.com/tiagosiebler/coinbase-api/blob/master/src/CBInternationalClient.ts#L376) | :closed_lock_with_key: | GET | `/api/v1/portfolios/{portfolio}/positions` | +| [getPositionForPortfolioInstrument()](https://github.com/tiagosiebler/coinbase-api/blob/master/src/CBInternationalClient.ts#L385) | :closed_lock_with_key: | GET | `/api/v1/portfolios/{portfolio}/positions/{instrument}` | +| [getFillsByPortfolios()](https://github.com/tiagosiebler/coinbase-api/blob/master/src/CBInternationalClient.ts#L399) | :closed_lock_with_key: | GET | `/api/v1/portfolios/fills` | +| [getPortfolioFills()](https://github.com/tiagosiebler/coinbase-api/blob/master/src/CBInternationalClient.ts#L408) | :closed_lock_with_key: | GET | `/api/v1/portfolios/{portfolio}/fills` | +| [setCrossCollateral()](https://github.com/tiagosiebler/coinbase-api/blob/master/src/CBInternationalClient.ts#L418) | :closed_lock_with_key: | POST | `/api/v1/portfolios/{portfolio}/cross-collateral-enabled` | +| [setAutoMargin()](https://github.com/tiagosiebler/coinbase-api/blob/master/src/CBInternationalClient.ts#L435) | :closed_lock_with_key: | POST | `/api/v1/portfolios/{portfolio}/auto-margin-enabled` | +| [setPortfolioMarginOverride()](https://github.com/tiagosiebler/coinbase-api/blob/master/src/CBInternationalClient.ts#L448) | :closed_lock_with_key: | POST | `/api/v1/portfolios/margin` | +| [transferFundsBetweenPortfolios()](https://github.com/tiagosiebler/coinbase-api/blob/master/src/CBInternationalClient.ts#L460) | :closed_lock_with_key: | POST | `/api/v1/portfolios/transfer` | +| [transferPositionsBetweenPortfolios()](https://github.com/tiagosiebler/coinbase-api/blob/master/src/CBInternationalClient.ts#L472) | :closed_lock_with_key: | POST | `/api/v1/portfolios/transfer-position` | +| [getPortfolioFeeRates()](https://github.com/tiagosiebler/coinbase-api/blob/master/src/CBInternationalClient.ts#L485) | :closed_lock_with_key: | GET | `/api/v1/portfolios/fee-rates` | +| [getRankings()](https://github.com/tiagosiebler/coinbase-api/blob/master/src/CBInternationalClient.ts#L499) | :closed_lock_with_key: | GET | `/api/v1/rankings/statistics` | +| [getMatchingTransfers()](https://github.com/tiagosiebler/coinbase-api/blob/master/src/CBInternationalClient.ts#L518) | :closed_lock_with_key: | GET | `/api/v1/transfers` | +| [getTransfer()](https://github.com/tiagosiebler/coinbase-api/blob/master/src/CBInternationalClient.ts#L527) | :closed_lock_with_key: | GET | `/api/v1/transfers/{transfer_uuid}` | +| [withdrawToCryptoAddress()](https://github.com/tiagosiebler/coinbase-api/blob/master/src/CBInternationalClient.ts#L536) | :closed_lock_with_key: | POST | `/api/v1/transfers/withdraw` | +| [createCryptoAddress()](https://github.com/tiagosiebler/coinbase-api/blob/master/src/CBInternationalClient.ts#L547) | :closed_lock_with_key: | POST | `/api/v1/transfers/address` | +| [createCounterpartyId()](https://github.com/tiagosiebler/coinbase-api/blob/master/src/CBInternationalClient.ts#L560) | :closed_lock_with_key: | POST | `/api/v1/transfers/create-counterparty-id` | +| [validateCounterpartyId()](https://github.com/tiagosiebler/coinbase-api/blob/master/src/CBInternationalClient.ts#L571) | :closed_lock_with_key: | POST | `/api/v1/transfers/validate-counterparty-id` | +| [withdrawToCounterpartyId()](https://github.com/tiagosiebler/coinbase-api/blob/master/src/CBInternationalClient.ts#L582) | :closed_lock_with_key: | POST | `/api/v1/transfers/withdraw/counterparty` | +| [getFeeRateTiers()](https://github.com/tiagosiebler/coinbase-api/blob/master/src/CBInternationalClient.ts#L600) | :closed_lock_with_key: | GET | `/api/v1/fee-rate-tiers` | # CBPrimeClient.ts diff --git a/examples/apidoc/CBInternationalClient/getIndexCandles.js b/examples/apidoc/CBInternationalClient/getIndexCandles.js new file mode 100644 index 0000000..d2727d2 --- /dev/null +++ b/examples/apidoc/CBInternationalClient/getIndexCandles.js @@ -0,0 +1,20 @@ +const { CBInternationalClient } = 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: /api/v1/index/{index}/candles + // METHOD: GET + // PUBLIC: YES + +const client = new CBInternationalClient({ + apiKey: 'insert_api_key_here', + apiSecret: 'insert_api_secret_here', +}); + +client.getIndexCandles(params) + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/CBInternationalClient/getIndexComposition.js b/examples/apidoc/CBInternationalClient/getIndexComposition.js new file mode 100644 index 0000000..52f853a --- /dev/null +++ b/examples/apidoc/CBInternationalClient/getIndexComposition.js @@ -0,0 +1,20 @@ +const { CBInternationalClient } = 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: /api/v1/index/{index}/composition + // METHOD: GET + // PUBLIC: YES + +const client = new CBInternationalClient({ + apiKey: 'insert_api_key_here', + apiSecret: 'insert_api_secret_here', +}); + +client.getIndexComposition(params) + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/CBInternationalClient/getIndexCompositionHistory.js b/examples/apidoc/CBInternationalClient/getIndexCompositionHistory.js new file mode 100644 index 0000000..798d263 --- /dev/null +++ b/examples/apidoc/CBInternationalClient/getIndexCompositionHistory.js @@ -0,0 +1,20 @@ +const { CBInternationalClient } = 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: /api/v1/index/{index}/composition-history + // METHOD: GET + // PUBLIC: YES + +const client = new CBInternationalClient({ + apiKey: 'insert_api_key_here', + apiSecret: 'insert_api_secret_here', +}); + +client.getIndexCompositionHistory(params) + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/CBInternationalClient/getIndexPrice.js b/examples/apidoc/CBInternationalClient/getIndexPrice.js new file mode 100644 index 0000000..8e87d4e --- /dev/null +++ b/examples/apidoc/CBInternationalClient/getIndexPrice.js @@ -0,0 +1,20 @@ +const { CBInternationalClient } = 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: /api/v1/index/{index}/price + // METHOD: GET + // PUBLIC: YES + +const client = new CBInternationalClient({ + apiKey: 'insert_api_key_here', + apiSecret: 'insert_api_secret_here', +}); + +client.getIndexPrice(params) + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/package-lock.json b/package-lock.json index be57ff4..0515988 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "coinbase-api", - "version": "1.0.4", + "version": "1.0.5", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "coinbase-api", - "version": "1.0.4", + "version": "1.0.5", "license": "MIT", "dependencies": { "axios": "^1.7.4", diff --git a/package.json b/package.json index 53ad1b6..76c9710 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "coinbase-api", - "version": "1.0.4", + "version": "1.0.5", "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/CBInternationalClient.ts b/src/CBInternationalClient.ts index 36e37d6..1592663 100644 --- a/src/CBInternationalClient.ts +++ b/src/CBInternationalClient.ts @@ -11,6 +11,8 @@ import { GetINTXAggregatedCandlesData, GetINTXDailyTradingVolumes, GetINTXFillsByPortfoliosRequest, + GetINTXIndexCandlesRequest, + GetINTXIndexCompositionHistory, GetINTXMatchingTransfersRequest, GetINTXOpenOrdersRequest, GetINTXPortfolioFillsRequest, @@ -73,6 +75,54 @@ export class CBInternationalClient extends BaseRestClient { return this.get(`/api/v1/assets/${params.asset}/networks`); } + /** + * + * Index Endpoints + * + */ + + /** + * Get index composition + * + * Retrieves the latest index composition (metadata) with an ordered set of constituents. + */ + getIndexComposition(params: { index: string }): Promise { + return this.get(`/api/v1/index/${params.index}/composition`); + } + + /** + * Get index composition history + * + * Retrieves a history of index composition records in a descending time order. + * The results are an array of index composition data recorded at different "timestamps". + */ + getIndexCompositionHistory( + params: GetINTXIndexCompositionHistory, + ): Promise { + const { index, ...query } = params; + return this.get(`/api/v1/index/${index}/composition-history`, query); + } + + /** + * Get index price + * + * Retrieves the latest index price. + */ + getIndexPrice(params: { index: string }): Promise { + return this.get(`/api/v1/index/${params.index}/price`); + } + + /** + * Get index candles + * + * Retrieves the historical daily index prices in time descending order. + * The daily values are represented as aggregated entries for the day in typical OHLC format. + */ + getIndexCandles(params: GetINTXIndexCandlesRequest): Promise { + const { index, ...query } = params; + return this.get(`/api/v1/index/${index}/candles`, query); + } + /** * * Instruments Endpoints diff --git a/src/types/request/coinbase-international.ts b/src/types/request/coinbase-international.ts index 41d3f37..d56ecf2 100644 --- a/src/types/request/coinbase-international.ts +++ b/src/types/request/coinbase-international.ts @@ -4,6 +4,26 @@ * */ +/** + * + * Index Endpoints + * + */ + +export interface GetINTXIndexCompositionHistory { + index: string; + time_from?: string; + result_limit?: number; + result_offset?: number; +} + +export interface GetINTXIndexCandlesRequest { + index: string; + granularity: string; + start: string; + end?: string; +} + /** * * Instruments Endpoints From 6e4f4428ff815230162bcaada9cef37a21384916 Mon Sep 17 00:00:00 2001 From: Jerko J <83344666+JJ-Cro@users.noreply.github.com> Date: Mon, 18 Nov 2024 16:13:54 +0100 Subject: [PATCH 2/4] chore(): updated type name --- src/CBInternationalClient.ts | 4 ++-- src/types/request/coinbase-international.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/CBInternationalClient.ts b/src/CBInternationalClient.ts index 1592663..5011867 100644 --- a/src/CBInternationalClient.ts +++ b/src/CBInternationalClient.ts @@ -11,7 +11,7 @@ import { GetINTXAggregatedCandlesData, GetINTXDailyTradingVolumes, GetINTXFillsByPortfoliosRequest, - GetINTXIndexCandlesRequest, + GetINTXIndexCandles, GetINTXIndexCompositionHistory, GetINTXMatchingTransfersRequest, GetINTXOpenOrdersRequest, @@ -118,7 +118,7 @@ export class CBInternationalClient extends BaseRestClient { * Retrieves the historical daily index prices in time descending order. * The daily values are represented as aggregated entries for the day in typical OHLC format. */ - getIndexCandles(params: GetINTXIndexCandlesRequest): Promise { + getIndexCandles(params: GetINTXIndexCandles): Promise { const { index, ...query } = params; return this.get(`/api/v1/index/${index}/candles`, query); } diff --git a/src/types/request/coinbase-international.ts b/src/types/request/coinbase-international.ts index d56ecf2..8a8defd 100644 --- a/src/types/request/coinbase-international.ts +++ b/src/types/request/coinbase-international.ts @@ -17,7 +17,7 @@ export interface GetINTXIndexCompositionHistory { result_offset?: number; } -export interface GetINTXIndexCandlesRequest { +export interface GetINTXIndexCandles { index: string; granularity: string; start: string; From b1fea7529f261fa23dfe912ca81cbb21b6504b04 Mon Sep 17 00:00:00 2001 From: Jerko J <83344666+JJ-Cro@users.noreply.github.com> Date: Mon, 18 Nov 2024 16:38:29 +0100 Subject: [PATCH 3/4] chore(): updated type name --- src/CBInternationalClient.ts | 4 ++-- src/types/request/coinbase-international.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/CBInternationalClient.ts b/src/CBInternationalClient.ts index 5011867..dadfa9e 100644 --- a/src/CBInternationalClient.ts +++ b/src/CBInternationalClient.ts @@ -11,7 +11,7 @@ import { GetINTXAggregatedCandlesData, GetINTXDailyTradingVolumes, GetINTXFillsByPortfoliosRequest, - GetINTXIndexCandles, + GetINTXIndexCandlesRequest as GetINTXIndexCandlesRequest, GetINTXIndexCompositionHistory, GetINTXMatchingTransfersRequest, GetINTXOpenOrdersRequest, @@ -118,7 +118,7 @@ export class CBInternationalClient extends BaseRestClient { * Retrieves the historical daily index prices in time descending order. * The daily values are represented as aggregated entries for the day in typical OHLC format. */ - getIndexCandles(params: GetINTXIndexCandles): Promise { + getIndexCandles(params: GetINTXIndexCandlesRequest): Promise { const { index, ...query } = params; return this.get(`/api/v1/index/${index}/candles`, query); } diff --git a/src/types/request/coinbase-international.ts b/src/types/request/coinbase-international.ts index 8a8defd..d56ecf2 100644 --- a/src/types/request/coinbase-international.ts +++ b/src/types/request/coinbase-international.ts @@ -17,7 +17,7 @@ export interface GetINTXIndexCompositionHistory { result_offset?: number; } -export interface GetINTXIndexCandles { +export interface GetINTXIndexCandlesRequest { index: string; granularity: string; start: string; From ca7141cc94ccecce7e5a08cc39d3917125e266d3 Mon Sep 17 00:00:00 2001 From: Jerko J <83344666+JJ-Cro@users.noreply.github.com> Date: Mon, 18 Nov 2024 16:46:58 +0100 Subject: [PATCH 4/4] chore(): fixed name --- src/CBInternationalClient.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/CBInternationalClient.ts b/src/CBInternationalClient.ts index dadfa9e..1592663 100644 --- a/src/CBInternationalClient.ts +++ b/src/CBInternationalClient.ts @@ -11,7 +11,7 @@ import { GetINTXAggregatedCandlesData, GetINTXDailyTradingVolumes, GetINTXFillsByPortfoliosRequest, - GetINTXIndexCandlesRequest as GetINTXIndexCandlesRequest, + GetINTXIndexCandlesRequest, GetINTXIndexCompositionHistory, GetINTXMatchingTransfersRequest, GetINTXOpenOrdersRequest,