0.9.10 • Published 3 years ago

ts-crypto-cli v0.9.10

Weekly downloads
78
License
CC0-1.0
Repository
github
Last release
3 years ago

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

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
0.9.10

3 years ago

0.9.9

3 years ago

0.9.8

3 years ago

0.9.7

3 years ago

0.9.4

3 years ago

0.9.3

3 years ago

0.9.2

3 years ago

0.9.1

3 years ago

0.9.0

3 years ago

0.8.13

4 years ago

0.8.12

4 years ago

0.8.11

4 years ago

0.8.10

4 years ago

0.8.9

4 years ago

0.8.8

4 years ago

0.8.7

4 years ago

0.8.6

4 years ago

0.8.5

4 years ago

0.8.4

4 years ago

0.8.3

4 years ago

0.8.2

4 years ago

0.8.1

4 years ago

0.8.0

4 years ago

0.7.4

4 years ago

0.7.3

4 years ago

0.7.2

4 years ago

0.7.1

4 years ago

0.7.0

4 years ago

0.6.2

4 years ago

0.6.1

4 years ago

0.6.0

4 years ago

0.5.16

4 years ago

0.5.14

4 years ago

0.5.15

4 years ago

0.5.13

4 years ago

0.5.12

4 years ago

0.5.8

4 years ago

0.5.9

4 years ago

0.5.7

4 years ago

0.5.5

4 years ago

0.5.0

4 years ago

0.5.1

4 years ago

0.4.3

4 years ago

0.4.2

4 years ago

0.3.25

4 years ago

0.4.1

4 years ago

0.4.0

4 years ago

0.3.24

4 years ago

0.3.22

4 years ago

0.3.21

4 years ago

0.3.20

4 years ago

0.3.19

4 years ago

0.3.18

4 years ago

0.3.17

4 years ago

0.3.16

4 years ago

0.3.15

4 years ago

0.3.9

4 years ago

0.3.14

4 years ago

0.3.12

4 years ago

0.3.6

4 years ago

0.3.8

4 years ago

0.3.7

4 years ago

0.3.5

4 years ago

0.3.4

4 years ago

0.3.3

4 years ago

0.3.2

4 years ago

0.3.0

4 years ago

0.2.7

4 years ago

0.2.6

4 years ago

0.2.5

4 years ago

0.2.4

4 years ago

0.2.3

4 years ago

0.2.2

4 years ago

0.2.1

4 years ago

0.2.0

4 years ago

0.1.8

4 years ago