npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

pollux-cryptomarket

v1.0.7

Published

The CryptoMarket for Node.js

Downloads

77

Readme

CryptoMarket-javascript

main page

sign up in CryptoMarket.

Installation

To install Cryptomarket use npm

npm install cryptomarket

Documentation

This sdk makes use of the api version 2 of cryptomarket.

Quick Start

rest client

const { Client } = require('cryptomarket')

// instance a client
let apiKey='AB32B3201'
let api_secret='21b12401'
let client = new Client(apiKey, api_secret)

// get currencies
let currencies = await client.getCurrencies()

// get order books
let orderBook = await client.getOrderBook('EOSETH')

// get your account balances
let accountBalance = await client.getAccountBalance()

// get your trading balances
let tradingBalance = await client.getTradingBalance()

// move balance from account to trading
let result = await client.transferMoneyFromAccountBalanceToTradingBalance('ETH', '3.2')

// get your active orders
let orders = await client.getActiveOrders('EOSETH')

// create a new order
let newOrder = await client.createOrder({'symbol':'EOSETH', 'side':'buy', 'quantity':'10', 'price':'10'})

websocket client

There are three websocket clients, one for public request (WSPublicClient), one for trading request (WSTradingClient) and one for the account requests (WSAccountClient).

Clients work with promises

Clients must be connected before any request. Authentication for WSTradingClient and WSAccountClient is automatic.

const { WSPublicClient, WSTradingClient, WSAccountClient} = require('cryptomarket')

let publicClient = new WSPublicClient()
await publicClient.connect()

// get currencies
await publicClient.getCurrencies()

let apiKey='AB32B3201'
let apiSecret='21b12401'
let tradingClient = new WSTradingClient(apiKey, apiSecret)

await tradingClient.connect()

// get your trading balance
let balance = await tradingClient.getTradingBalance()

// get your active orders
let activeOrders = await tradingClient.getActiveOrders()

await tradingClient.createOrder({
    clientOrderId:"qqwe123qwe", 
    symbol:'EOSETH', 
    side:'buy', 
    quantity:'10',
    price:'10'
})

let accountClient = new WSAccountClient(apiKey, apiSecret)
await accountClient.connect()

// get your account balance
let accBalance = await accountCilent.getAccountBalance()

subscriptions

all subscriptions take a callback argument to call with each feed of the subscription


// callback is for the subscription feed
function callback(feed) {
    // handle feed
    console.log(feed)
}

await publicClient.subscribeToOrderBook('EOSETH', callabck)


await accountClient.subscribeToTransactions(callback)

error handling


{ CryptomarketSDKException, Client, WSPublicClient } = require('cryptomarket')
// exceptions derive from the CryptomarketSDKException class.

client = new Client()
// catch a failed transaction
try {
    order = client.createOrder({
        'symbol':'EOSETHH',  // non existant symbol
        'side':'sell',
        'quantity':'10', 
        'price':'10'})
} catch (error: any) {
    console.log(error)
}

wsclient = new WSPublicClient()
await wsclient.connect()

// catch a missing argument
try {
    await wsclient.subscribeToOrderbook('ETHBTC') // needs a callback
} catch (error: any) {
    console.log(error)
}

// also catches forwarded errors from the cryptomarket exchange server
try {
    let trades = await wsclient.getTrades("abcde", myCallback) // not a real symbol
} catch (err) {
    console.log(err)
}

Checkout our other SDKs

python sdk

java sdk

go sdk

ruby sdk