Coder Social home page Coder Social logo

yeikiu / ts-crypto-cli Goto Github PK

View Code? Open in Web Editor NEW
1.0 2.0 4.0 2.11 MB

☠️ UNMAINTAINED - 📈 Handy npm cli/lib to operate against some of the most known Crypto Exchanges

Home Page: https://www.npmjs.com/package/ts-crypto-cli

License: Creative Commons Zero v1.0 Universal

TypeScript 84.44% JavaScript 15.56%
cryptocurrency-exchanges binance hitbtc kraken

ts-crypto-cli's Introduction

🚨 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.

import { krakenPrivateApiRequest } from 'ts-crypto-cli'

const krakenWithdrawAsset = async (asset: string, key: string, withdrawAmount: number): Promise<unknown> => {
  const withdrawInfo = await krakenPrivateApiRequest({ url: 'WithdrawInfo', data: {
      asset,
      key,
      amount: withdrawAmount
  }})

  const { limit } = withdrawInfo

  if (Number(limit) < Number(withdrawAmount)) {
    throw new Error(`Can´t withdraw ${withdrawAmount} ${asset}. Max. available ${limit}`)
  }

  return krakenPrivateApiRequest({ url: 'Withdraw', data: {
    asset,
    key,
    amount: withdrawAmount
  }})
}

export {
  krakenWithdrawAsset
}

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

##
# Each REST request/response can be optionally recorded to a log file if you set a path here
##
#TS_CRYPTO_CLI_LOGS_PATH=./ts_crypto_cli_logs

KRAKEN_API_KEY=<...>
KRAKEN_API_SECRET=<...>

HITBTC_API_KEY=<...>
HITBTC_API_SECRET=<...>

BINANCE_API_KEY=<...>
BINANCE_API_SECRET=<...>

##
# DEV only
##
#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

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

ts-crypto-cli's People

Contributors

actions-user avatar dependabot[bot] avatar yeikiu avatar

Stargazers

 avatar

Watchers

 avatar  avatar

ts-crypto-cli's Issues

Secret inside constructor instead of env var

It would be a more flexible and better practice to let the user set the API key and Secret key in the constructor rather than environment variables.

Using process env only to retrieve those keys make it not possible to use dynamic configuration as it would require to change the current env.

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.