From c98de2f6e476ca8b3f397ecb681a3d66cb4aa961 Mon Sep 17 00:00:00 2001 From: gannicus Date: Wed, 13 Nov 2024 16:20:12 +0800 Subject: [PATCH 1/2] feat: Added some APIs --- CHANGELOG.md | 19 ++++++++++++++++++- demo/index.js | 11 ++++++++++- demo/user.js | 36 ++++++++++++++++++++++++++++++++++++ package.json | 2 +- src/rest/Market/Symbols.js | 11 +++++++++++ src/rest/Others.js | 17 +++++++++++++++++ src/rest/User/Account.js | 10 ++++++++++ src/rest/User/Withdrawals.js | 6 ++++++ 8 files changed, 109 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6919eb9..727e253 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,21 @@ -## [1.0.10] - 2024-06-15 +## [1.1.1] - 2024-11-12 + +### Added +- **Spot High-Frequency Upgrade**: All users can now use high-frequency interfaces without a whitelist. The system is more stable, and the rate limits are more relaxed. +- **User Type API**: Added `GET /api/v1/hf/accounts/opened` to determine the user type. +- **Fetch Announcements** API: Added `GET /api/v3/announcements` to retrieve news and announcements. + +### Modified +- **Get Currency Details API**: `GET /api/v3/currencies/{currency}` now includes additional fields: `withdrawPrecision`, `needTag`, `maxWithdraw`, and `maxDeposit`. +- **Get Currency List API**: `GET /api/v3/currencies` now includes additional fields: `withdrawPrecision`, `needTag`, `maxWithdraw`, and `maxDeposit`. + +### Deprecated +- **Get Deposit Address API**: Deprecated `GET /api/v1/deposit-addresses`, replaced by `GET /api/v3/deposit-addresses`. +- **Get Deposit Address API (V2)**: Deprecated `GET /api/v2/deposit-addresses`, replaced by `GET /api/v3/deposit-addresses`. +- **Apply for Deposit Address API**: Deprecated `POST /api/v1/deposit-addresses`, replaced by `POST /api/v3/deposit-address/create`. +- **Apply for Withdrawal API**: Deprecated `POST /api/v1/withdrawals`, replaced by `POST /api/v3/withdrawals`. + +## [1.1.0] - 2024-06-15 ### Added APIs - `GET /api/v3/hf/margin/order/active/symbols` diff --git a/demo/index.js b/demo/index.js index 11f77f9..5c3d392 100644 --- a/demo/index.js +++ b/demo/index.js @@ -164,6 +164,10 @@ console.log(transferToHFAccountResult ,"transferToHFAccountResult---"); const getSymbolsListResult = await API.rest.Market.Symbols.getSymbolsList({market:"BTC"}); console.log(getSymbolsListResult ,"getSymbolsListResult---"); + + const getSymbolDetail = await API.rest.Market.Symbols.getSymbolDetail("BTC-USDT"); + console.log(getSymbolDetail,"getSymbolDetailResult---"); + /** * @name getCurrencyDetail * @description Get Currency Detail(Recommend) @@ -362,6 +366,11 @@ const getHighFrequencyAccountLedgerResult = await API.rest.User.Account.getHighF }); console.log(getHighFrequencyAccountLedgerResult ,"getHighFrequencyAccountLedgerResult---"); + +const getUserTypeResult = await API.rest.User.Account.getUserType(); +console.log("User Type:", getUserTypeResult.data ? "High-Frequency" : "Low-Frequency"); + + /** * @name getHfTransactionRecords * @description HF transaction records @@ -742,4 +751,4 @@ console.log(queryHfAutoCancelOrderSettingResult ,"queryHfAutoCancelOrderSettingR // run rest main -main(); +main(); \ No newline at end of file diff --git a/demo/user.js b/demo/user.js index 028481e..5886d12 100644 --- a/demo/user.js +++ b/demo/user.js @@ -42,6 +42,42 @@ const userMain = async () => { } } universalTransfer(); + + + /** + * @name getAnnouncements + * @description Get the latest news announcements + * @updateTime 11/13/24 + * @param {Object} params + * @param {Number} [params.currentPage] - Page number (Optional) + * @param {Number} [params.pageSize] - Page size (Optional) + * @param {String} [params.annType] - Announcement types: latest-announcements, activities, new-listings, product-updates, vip, maintenance-updates, delistings, others, api-campaigns (Optional) + * @param {String} [params.lang] - Language type, default is en_US (Optional) + * @param {Number} [params.startTime] - Announcement online start time (milliseconds) (Optional) + * @param {Number} [params.endTime] - Announcement online end time (milliseconds) (Optional) + * @return {Promise} { code, data: { totalNum, items, currentPage, pageSize, totalPage } } + */ + async function getAnnouncementsDemo() { + try { + const response = await API.rest.Others.getAnnouncements({ + currentPage: 1, + pageSize: 10, + annType: 'latest-announcements', + lang: 'en_US' + }); + + console.log("Announcements:", response); + + if (response.data && response.data.items) { + console.log("Total announcements:", response.data.totalNum); + console.log("First announcement title:", response.data.items[0].annTitle); + } + } catch (error) { + console.error("Error fetching announcements:", error); + } + } + + getAnnouncementsDemo(); }; // run rest userMain diff --git a/package.json b/package.json index a1b2684..7f8001e 100755 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "kucoin-node-sdk", - "version": "1.1.0", + "version": "1.1.1", "description": "KuCoin API SDK for Node.js language", "main": "src/index.js", "scripts": { diff --git a/src/rest/Market/Symbols.js b/src/rest/Market/Symbols.js index 368df9b..02145d5 100644 --- a/src/rest/Market/Symbols.js +++ b/src/rest/Market/Symbols.js @@ -132,4 +132,15 @@ exports.getSymbolsList = async function getSymbolsList({ market = undefined } = return await Http().GET("/api/v2/symbols", { market, }); +}; + +/** + * @name getSymbolDetail + * @description Request via this endpoint to get detail currency pairs for trading. + * @param {String} symbol - Symbol (e.g., BTC-USDT) + * @return {Object} { code, success, data } + */ +exports.getSymbolDetail = async function getSymbolDetail(symbol) { + // Make the GET request to the API endpoint + return await Http().GET(`/api/v2/symbols/${symbol}`); }; \ No newline at end of file diff --git a/src/rest/Others.js b/src/rest/Others.js index 0a11031..dd4fce0 100644 --- a/src/rest/Others.js +++ b/src/rest/Others.js @@ -34,3 +34,20 @@ exports.getStatus = async function getStatus() { */ return await Http().GET('/api/v1/status'); }; + +/** + * @name getAnnouncements + * @description Get the latest news announcements + * @updateTime 11/13/24 + * @param {Object} params + * @param {Number} [params.currentPage] - Page number (Optional) + * @param {Number} [params.pageSize] - Page size (Optional) + * @param {String} [params.annType] - Announcement types: latest-announcements, activities, new-listings, product-updates, vip, maintenance-updates, delistings, others, api-campaigns (Optional) + * @param {String} [params.lang] - Language type, default is en_US (Optional) + * @param {Number} [params.startTime] - Announcement online start time (milliseconds) (Optional) + * @param {Number} [params.endTime] - Announcement online end time (milliseconds) (Optional) + * @return {Promise} { code, data: { totalNum, items, currentPage, pageSize, totalPage } } + */ +exports.getAnnouncements = async function getAnnouncements(params = {}) { + return await Http().GET("/api/v3/announcements", params); +}; \ No newline at end of file diff --git a/src/rest/User/Account.js b/src/rest/User/Account.js index 555cf6f..dbd1739 100644 --- a/src/rest/User/Account.js +++ b/src/rest/User/Account.js @@ -588,6 +588,16 @@ exports.getHighFrequencyAccountLedger = async function getHighFrequencyAccountLe }); } +/** + * @name getUserType + * @description Determines whether the current user is a spot high-frequency user or a spot low-frequency user. + * @return {Object} { code, success, data } + */ +exports.getUserType = async function getUserType() { + return await Http().GET('/api/v1/hf/accounts/opened'); +}; + + /** * @name universalTransfer diff --git a/src/rest/User/Withdrawals.js b/src/rest/User/Withdrawals.js index 8f898b2..b05db1f 100644 --- a/src/rest/User/Withdrawals.js +++ b/src/rest/User/Withdrawals.js @@ -151,6 +151,10 @@ exports.getWithdrawalQuotas = async function getWithdrawalQuotas(currency, { * - {boolean} isInner - [Optional] Internal withdrawal or not. Default setup: false * - {string} remark - [Optional] Remark * - {string} chain - [Optional] The chain name of currency, e.g. The available value for USDT are OMNI, ERC20, TRC20, default is ERC20. This only apply for multi-chain currency, and there is no need for single chain currency. + * - {string} feeDeductType - [Optional] Withdrawal fee deduction type: INTERNAL or EXTERNAL or not specified +1. INTERNAL- deduct the transaction fees from your withdrawal amount +2. EXTERNAL- deduct the transaction fees from your main account +3. If you don't specify the feeDeductType parameter, when the balance in your main account is sufficient to support the withdrawal, the system will initially deduct the transaction fees from your main account. But if the balance in your main account is not sufficient to support the withdrawal, the system will deduct the fees from your withdrawal amount. For example: Suppose you are going to withdraw 1 BTC from the KuCoin platform (transaction fee: 0.0001BTC), if the balance in your main account is insufficient, the system will deduct the transaction fees from your withdrawal amount. In this case, you will be receiving 0.9999BTC. * @return {Object} { code, success, data } */ exports.applyWithdraw = async function applyWithdraw(currency, address, amount, { @@ -158,6 +162,7 @@ exports.applyWithdraw = async function applyWithdraw(currency, address, amount, isInner, remark, chain, + feeDeductType } = {}) { /* { @@ -175,6 +180,7 @@ exports.applyWithdraw = async function applyWithdraw(currency, address, amount, isInner, remark, chain, + feeDeductType }); }; From 68c5ef643b38e848a9d5eeb3669e12de6309264b Mon Sep 17 00:00:00 2001 From: gannicus Date: Wed, 13 Nov 2024 16:32:56 +0800 Subject: [PATCH 2/2] feat: Added some APIs --- README.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 5ece0c8..ba69748 100644 --- a/README.md +++ b/README.md @@ -100,6 +100,7 @@ Signature is required for this part. - [x] getPaginatedSubAccountInformation - [x] transferToHFAccount - [x] getHighFrequencyAccountLedger +- [x] getUserType #### Rest/User/Deposit - [x] createDepositAddress @@ -184,7 +185,8 @@ Signature is not required for this part - [x] getAllTickers - [x] get24hrStats - [x] getMarketList -- [x] getSymbolsList +- [x] getSymbolDetail + #### Rest/Market/OrderBook - [x] getLevel2_20 - [x] getLevel2_100 @@ -277,6 +279,7 @@ Signature is not required for this part #### Rest/Others - [x] getTimestamp - [x] getStatus +- [x] getAnnouncements ## Websocket Datafeed