1.0.2 • Published 7 years ago

nicehash v1.0.2

Weekly downloads
3
License
ISC
Repository
github
Last release
7 years ago

nicehash

Node NiceHash API Wrapper

A simple API wrapper for the cloud mining site NiceHash.

Installation

If you want to place or modify orders you need a NiceHash account. Under Account > General, you'll find your API ID and Key. You cannot use your read-only API Key.

npm install nicehash --save

Initialization

First, import the module:

const NiceHashClient = require('nicehash');

Next, initialize a new NiceHash client object with your API ID and Key:

const nh = new NiceHashClient({apiId: '123456', apiKey: '66666666-6666-6666-6666-666666666666'});

Note: If you aren't purchasing or modifying orders, you do not need to include API Id or Key.

Methods

All of the methods correspond to NiceHash's API documentation.

Private API Methods (Require Authentication)

nh.getMyOrders(location, algo)

Get all orders for certain algorithm owned by the customer. Refreshed every 30 seconds.

paramtypedescription
locationNumberLocation, 0 for Europe, 1 for USA.
algoNumberAlgorithm marked with ID

nh.createOrder(orderOptions)

Create new order. Only standard orders can be created with use of API.

paramtypedescription
orderOptions.locationNumber0 for Europe (NiceHash), 1 for USA (WestHash).
orderOptions.algoNumberAlgorithm marked with ID.
orderOptions.amountNumberPay amount in BTC.
orderOptions.priceNumberPrice in BTC/GH/Day or BTC/TH/Day.
orderOptions.limitNumberSpeed limit in GH/s or TH/s (0 for no limit).
orderOptions.codeNumberRequired code if 2FA is enabled
orderOptions.pool_hostStringPool hostname or IP.
orderOptions.pool_portStringPool port.
orderOptions.pool_userStringPool username.
orderOptions.pool_passStringPool password.

nh.refillOrder(orderOptions)

Refill order with extra Bitcoins.

paramtypedescription
orderOptions.locationNumber0 for Europe (NiceHash), 1 for USA (WestHash).
orderOptions.algoNumberAlgorithm marked with ID.
orderOptions.amountNumberPay amount in BTC.
orderOptions.orderNumberExisting Order ID

nh.removeOrder(orderOptions)

Remove existing order.

paramtypedescription
orderOptions.locationNumber0 for Europe (NiceHash), 1 for USA (WestHash).
orderOptions.algoNumberAlgorithm marked with ID.
orderOptions.orderNumberExisting Order ID

nh.setOrderPrice(orderOptions)

Set new price for the existing order. Only increase is possible.

paramtypedescription
orderOptions.locationNumber0 for Europe (NiceHash), 1 for USA (WestHash).
orderOptions.algoNumberAlgorithm marked with ID.
orderOptions.priceNumberPrice in BTC/GH/Day or BTC/TH/Day
orderOptions.orderNumberExisting Order ID

nh.decreaseOrderPrice(orderOptions)

Decrease price for the existing order. Price decrease possible every 10 minutes.

paramtypedescription
orderOptions.locationNumber0 for Europe (NiceHash), 1 for USA (WestHash).
orderOptions.algoNumberAlgorithm marked with ID.
orderOptions.orderNumberExisting Order ID

nh.setOrderLimit(orderOptions)

paramtypedescription
orderOptions.locationNumber0 for Europe (NiceHash), 1 for USA (WestHash).
orderOptions.algoNumberAlgorithm marked with ID.
orderOptions.limitNumberSpeed limit in GH/s or TH/s (0 for no limit).
orderOptions.orderNumberExisting Order ID

nh.getMyBalance()

Get current Bitcoin balance (confirmed and pending).


Public API Methods

getApiVersion()

Returns the current API version

getNiceHashAlgorithmNumberByName(algoName)

Returns the internal NiceHash algorithm ID (or null if not found) for the given hashing algorithm.

paramtypedescription
algoNameStringName of algorithm

getAlgorithmNameByNiceHashNumber(number)

Returns the internal NiceHash algorithm ID (or null if not found) for the given hashing algorithm.

paramtypedescription
numberNumberInternal NiceHash algo ID

nh.getGlobalCurrentStats(location)

paramtypedescription
locationNumber(Optional) Location, 0 for Europe, 1 for USA. Optional

getGlobal24hStats()

Get average profitability (price) and hashing speed for all algorithms in past 24 hours.

nh.getProviderStats(addr)

Get current stats for provider for all algorithms. Refreshed every 30 seconds. It also returns past 56 payments.

paramtypedescription
addrStringProviders BTC address

nh.getDetailedProviderStats(addr, from)

Get details stats for provider for all algorithms including history data and past 56 payments

paramtypedescription
addrStringProviders BTC address
fromStringGet history from this time (Unix timestamp)

nh.getProviderWorkersStats(addr, algo)

Get detailed stats for provider's workers (rigs).

paramtypedescription
addrStringProviders BTC address
algoNumberAlgorithm marked with ID

nh.getOrders(location, algo)

Get all orders for certain algorithm. Refreshed every 30 seconds.

paramtypedescription
locationNumberLocation, 0 for Europe, 1 for USA.
algoNumberAlgorithm marked with ID

nh.getMultiAlgorithmMiningInfo()

Get information about Multi-Algorithm Mining.

nh.getSimpleMultiAlgorithmMiningInfo()

Get information about Simple Multi-Algorithm Mining. More Here

nh.getNeededBuyingInfo()

Get needed information for buying hashing power using NiceHashBot (https://github.com/nicehash/NiceHashBot)


Contribute

Contributions are welcome and would be awesome. It's a fairly straightforward app. Everything lives in NiceHashClient.js, and tests can be run with mocha.

Donate

BTC 1SUACoD5zyienrajU5PAKADGwySQYVD8G

ETH 0x4E821B7F5Ce9F04dbd7aDe5B98dC597a43e3a6C6