项目作者: yeikiu

项目描述 :
📈 Handy npm cli/lib to operate against some of the most known Crypto Exchanges
高级语言: TypeScript
项目地址: git://github.com/yeikiu/ts-crypto-cli.git
创建时间: 2020-06-27T23:42:06Z
项目社区:https://github.com/yeikiu/ts-crypto-cli

开源协议:Creative Commons Zero v1.0 Universal

下载


🚨 This package has been deprecated

This package is no longer supported. If you are still interested in a good cli/lib to operate on Kraken we recommend you check the ts-kraken project: https://github.com/yeikiu/ts-kraken


TS Crypto Cli

A handy npm to operate against some of the most known Crypto Exchanges

Option 1 - Use it as a library

  • npm i ts-crypto-cli

Library usage demo

Here is a little handler to perform a safe withdrawal from Kraken in <20 lines of code using the lib.

  1. import { krakenPrivateApiRequest } from 'ts-crypto-cli'
  2. const krakenWithdrawAsset = async (asset: string, key: string, withdrawAmount: number): Promise<unknown> => {
  3. const withdrawInfo = await krakenPrivateApiRequest({ url: 'WithdrawInfo', data: {
  4. asset,
  5. key,
  6. amount: withdrawAmount
  7. }})
  8. const { limit } = withdrawInfo
  9. if (Number(limit) < Number(withdrawAmount)) {
  10. throw new Error(`Can´t withdraw ${withdrawAmount} ${asset}. Max. available ${limit}`)
  11. }
  12. return krakenPrivateApiRequest({ url: 'Withdraw', data: {
  13. asset,
  14. key,
  15. amount: withdrawAmount
  16. }})
  17. }
  18. export {
  19. krakenWithdrawAsset
  20. }

Option 2 - Launch the REPL cli on a shell


Option 2.1 - Provide a .env file

Create a .env file under current working directory with your own API credentials and run

  • npx ts-crypto-cli

Environment Variables

  1. ##
  2. # Each REST request/response can be optionally recorded to a log file if you set a path here
  3. ##
  4. #TS_CRYPTO_CLI_LOGS_PATH=./ts_crypto_cli_logs
  5. KRAKEN_API_KEY=<...>
  6. KRAKEN_API_SECRET=<...>
  7. HITBTC_API_KEY=<...>
  8. HITBTC_API_SECRET=<...>
  9. BINANCE_API_KEY=<...>
  10. BINANCE_API_SECRET=<...>
  11. ##
  12. # DEV only
  13. ##
  14. #DEBUG=ts-crypto-cli:*

Option 2.2 - Inject your keys/secrets to enable private methods

This method is more secure as you won’t need to persist the KEYS to a file

Powershell (windows)

  • $env:KRAKEN_API_KEY="<...>" ; $env:KRAKEN_API_SECRET="<...>" ; $env:HITBTC_API_KEY="<...>" ; etc... ; npx ts-crypto-cli

cmd (windows)

  • set KRAKEN_API_KEY=<...> & set KRAKEN_API_SECRET=<...> & set HITBTC_API_KEY=<...> & etc... & npx ts-crypto-cli

Unix/OSx

  • KRAKEN_API_KEY=<...> KRAKEN_API_SECRET=<...> HITBTC_API_KEY=<...> etc.. npx ts-crypto-cli

Documentation

Handling multiple API credentials

You can use different API keys/secrets against the same exchange. Generate the new API client instances with one of the following methods:

  • createKrakenPrivateApiClient
  • createHitBTCPrivateApiClient
  • createBinancePrivateApiClient