Giter VIP home page Giter VIP logo

kucoin-node-sdk's People

Contributors

1bazinga25 avatar allandy avatar apexrsq avatar bbreukelen avatar dazdeng avatar dependabot[bot] avatar gannicuszhou avatar qhxin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

kucoin-node-sdk's Issues

Incorrect domain name in http.js (api.kucoin.io)

Excerpt of file http.js around row 14:

if (!_baseUrl) {
    _baseUrl = process.env.PRODUCTION === 'prod'
        ? 'https://api.kucoin.io'
        : 'https://openapi-sandbox.kucoin.io';
}

The domain name kucoin.io needs to be changed to kucoin.com, otherwise GET requests are redirected to an HTML page, causing a JSON parse error:

get bullet error { FetchError: invalid json response body at https://www.kucoin.cc/api/v1/bullet-public reason: Unexpected token < in JSON at position 0
    at /home/user/pulse/node_modules/node-fetch/lib/index.js:272:32
    at process._tickCallback (internal/process/next_tick.js:68:7)
  message:
   'invalid json response body at https://www.kucoin.cc/api/v1/bullet-public reason: Unexpected token < in JSON at position 0',
  type: 'invalid-json' }

PageSize

Can you add pageSize as a parameter for the endpoints that support it? Or default the API to 500. It takes to long to fetch the data if we use 50 at a time.

Subscribing to private Websocket-channels

I can subscribe to public channels (e.g. '/market/ticker:') but can not get any private channel like '/spotMarket/tradeOrders' to work.
An example call which I think would work:

feed.subscribe('/spotMarket/tradeOrders', (message) => { console.log(message) }, true)

Authentication should be correct since requesting any private account data through REST works.
Am I doing something wrong or are private channels not supported?

Getting empty data for orders list api

I'm able to pull the deposit and withdrawal transactions. When trying to pull the orders list, Im getting empty data

/** Require SDK */
const API = require('kucoin-node-sdk');

/** Init Configure */
API.init({
    "baseUrl": "https://api.kucoin.com",
    "apiAuth": {
      "key": "key", // KC-API-KEY
      "secret": "secret", // API-Secret
      "passphrase": passphrase", // KC-API-PASSPHRASE
    },
    "authVersion": 2, // KC-API-KEY-VERSION. Notice: for v2 API-KEY, not required for v1 version.
  });

/** API use */
const main = async () => {
  const getTimestampRl = await API.rest.Others.getTimestamp();
  console.log(getTimestampRl.data);
  const orders =  await API.rest.Trade.Orders.getOrdersList('TRADE')
  console.log(JSON.stringify(orders))
};

/** Run Demo */
main();

How do I sign requests?

I am having trouble making api requests for anything that requires a signature. I am under the impression that I need to use base64 and hmac to encode the 'api_secret' and timestamp, as well as the 'api_secret' and the 'api_passphrase.' this is from the kucoin api docs:

signature = base64.b64encode(
hmac.new(api_secret.encode('utf-8'), str_to_sign.encode('utf-8'), hashlib.sha256).digest())
passphrase = base64.b64encode(
hmac.new(api_secret.encode('utf-8'), api_passphrase.encode('utf-8'), hashlib.sha256).digest())

and then the request object includes

headers = {
"KC-API-SIGN": signature,
"KC-API-TIMESTAMP": str(now),
"KC-API-KEY": api_key,
"KC-API-PASSPHRASE": passphrase,
"KC-API-KEY-VERSION": 2
"Content-Type": "application/json" # specifying content type or using json=data in request
}

Do I have a second export in config.js for this?

Websocket datafeed handshake bug

The websocket doesn't connect due to a timeout.
The handshake timeout is set to 30ms which is a bit short.
It might have been the intention to set this to 30sec so it should be 30000 instead.
datafeed.js line 307

How do you compile demo

Hi,
I'm trying to compile demo.
I've installed lodash and now I've an error "Uncaught Error: Cannot find module './config'"
I launch the level2_demo from the demo directory.
Thanks for your help

getLevel2_full doesn't work

In my code:
console.log(await API.rest.Market.OrderBook.getLevel2_full('BTC-USDT'))
In console I see { code: '404', msg: 'not exist' }

What should I do?

Getting empty JSON response from getAccountList, getAccountInformation, getSubUsers

Hi,
I'm using the sandbox to test out this SDK. Set up an account in the Sandbox, created API credentials and used it as the config. Getting empty JSON responses from all the operations related to User and Account. I'm able get data back from getStatus and getSymbolsList which doesn't require a signature. I don't think I'm getting authorized correctly since even when I purporsely provide the wrong Secret, I still get an empty JSON response (I expected a 401 unauthorized error). Any idea what I might be missing?

Here's a sample of my code

`const API = require('kucoin-node-sdk');

const express = require('express');
const router = express.Router();

//Init configure
API.init({
baseUrl: 'https://openapi-sandbox.kucoin.com',
apiAuth: {
key: '', // KC-API-KEY
secret: '', // API-Secret
passphrase: '', // KC-API-PASSPHRASE
},
authVersion: 2, // KC-API-KEY-VERSION. Notice: for v2 API-KEY, not required for v1 version.
})

router.get('/subUsers', async(req,res)=> {
res.send(getSubUsers())
})

async function getSubUsers() {
const subUsers = await API.rest.User.UserInfo.getSubUsers()
return subUsers
}

router.get('/accountList', async(req,res)=> {
res.send(getAccountList())
})

async function getAccountList() {
const accountList = await API.rest.User.Account.getAccountsList()
return accountList
}

module.exports = router;`

The response I keep getting is this:

{}

Config file - SyntaxError: Unexpected token :

I have renamed the config file to config.js, and I've entered my API details but it seems like after each comma I'm getting a SyntaxError: Unexpected token.

Can't understand what the issue is.

{
baseUrl: '',
apiAuth: {
key: '', // KC-API-KEY
secret: '', // API-Secret
passphrase: '', // KC-API-PASSPHRASE
},
authVersion: 2, // KC-API-KEY-VERSION. Notice: for v2 API-KEY, not required for v1 version.
}

I've just entered my API details between the '' and tried using all the baseUrls suggested.

Invalid-Json Response

I apologize as I am not experienced with javascript at all. I keep getting this error. I am running the code from index.js and I have already filled the config file with my API Key, secret, and passphrase. However I keep getting this error. I have looked into it extensively and can't seem to figure it out.

/Users/mustafasoby/node_modules/node-fetch/lib/index.js:273 return Body.Promise.reject(new FetchError(invalid json response body at ${_this2.url} reason: ${err.message}`, 'invalid-json'));
^
FetchError: invalid json response body at https://sandbox.kucoin.com/api/v1/timestamp? reason: Unexpected token < in JSON at position 0
at /Users/mustafasoby/node_modules/node-fetch/lib/index.js:273:32
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async HttpBase.makeRequest (/Users/mustafasoby/node_modules/kucoin-node-sdk/src/lib/createHttp.js:88:20)
at async Object.getTimestamp (/Users/mustafasoby/node_modules/kucoin-node-sdk/src/rest/Others.js:17:10)
at async main (/Users/mustafasoby/Documents/coding/JavaScript/KuCoinBot/demo/index.js:6:28) {
type: 'invalid-json'
}

Node.js v17.0.1 `

Api support for robots?

Hey, I recently started playing with the kucoin bots, and I'd like to access the robots data via API to create some charts. (And perform actions too if that would be possible). The code would be open sourced BTW.

Is adding the robots data to the API in the plans?

Thanks.

How do I get response headers of rate limit?

How do I get response headers with result on successful call?

apiV1KC.get('/timestamp', async function(req, res) {
   try {
    const getTimestampRl = await KucoinAPI.rest.Others.getTimestamp();
    //res.set(headers);
    res.send(getTimestampRl); // Send the response back to the requester
  } catch (error) {
    res.status(500).send(error); // Send error response in case of an error
  }
});

applyWithdraw empty result, no action

I'm attempting to use applyWithdraw on USDC to ALGO and there is no response and no record of withdrawal action

const result = await kucoin.rest.User.Withdrawals.applyWithdraw('USDC', address, availableAmount, {chain: 'ALGO'})

Websocket ticker_demo.js not working

Any idea?

I'm not receiving the data in the susbcriber callback and datafeed.trustConnected is always false

API.init(config);

const datafeed = new API.websocket.Datafeed();

// close callback
datafeed.onClose(() => {
  console.log('ws closed, status ', datafeed.trustConnected);
});

// connect
await datafeed.connectSocket();

// subscribe
setTimeout(() => {
  console.log(datafeed.trustConnected);
  const topic = `/market/level2:BTC-EUR`;
  const callbackId = datafeed.subscribe(topic, (message) => {
    console.log(message);
    if (message.topic === topic) {
      console.log(message.data);
    }
  });
  console.log( `subscribe id: ${callbackId}` );
}, 5000);

Shared config object

Hi, thanks for the package!
I have an app that works the following way: people trust me with their api keys and secrets, I add them to my app, the app makes api calls using their api credentials. Since the app makes calls on behalf of multiple different users, the shared config object becomes an issue. I have to be extra careful to not have simultaneous api calls with different user configs, because I'm afraid when calling init for request B while request A hasn't been sent yet, request A will use request B config. Can you please confirm that this sort of error is in fact possible during simultaneous requests ? If yes, is it possible to initiate multiple instances, each with their own config ?

cancelOrderByClientOid doesn't work

I'm trying to cancel my order with the custom client order id using rest.Trade.Orders.cancelOrderByClientOid(), but it doesn't do anything.

I was looking in the code, and it seems the function arguments are incorrect:

exports.cancelOrderByClientOid = async function cancelOrderByClientOid({ symbol, tradeType } = {}) {
  return await Http().DEL(`/api/v1/order/client-order/${clientOid}`);
};

Should be something like:

exports.cancelOrderByClientOid = async function cancelOrderByClientOid(clientOid) {
  return await Http().DEL(`/api/v1/order/client-order/${clientOid}`);
};

For now I have to use the unique order id with cancelOrder() as returned by postOrder(), but it's not ideal.

Several wallet address for one coin

Hi
Can I create several BTC wallet address to deposit and use them all in same time?

For example:
I create a BTC wallet for deposit, Then I create another wallet again. Is my first wallet still mine?

Thanks

websocket message type is wrong

hello everyone
I open WebSocket for my private account and get messages of order changes.
when I set buy order in Best Market Price Mode order filled but the message type:'canceled'
and when sell order filled the message type:'filled'

I think the 'type' of buying Best Market Price message is wrong And it should be 'filled' in Websocket messages

Allow for client instances instead of using global variables

Is there a reason why the config is a global variable?

This scheme makes it difficult to create different connections, as the config is centralized and there is no way to override it.

It is relatively insecure or at least not ideal to be replacing the config to be able to keep different connections.

I would like to recommend having an approach where you can create a client instance with a configuration and set of parameters.

This will allow the user to create diverse connections on the same node instance if required.

Catching "Too many request" error

When I make an overload test, calling getOrderById too many times in shot amount of time, i can't catch request limit error.

My intention is to catch this error, wait 10 seconds or more and retry the request.
But using a Try-Catch block to make this happen I get always next error:

FetchError: invalid json response body at https://api.kucoin.com/api/v1/orders/62d99d248d3eb700016140dc? reason: Unexpected token < in JSON at position 0

I was digging into the createHttp lib, I think this can be the problem

}).then(res => {

Can anyone give me some help on this?

typescript

Hello, Please make the package support typescript.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.