coinhive-lib.js
node wrapper for Coinhive HTTP API
Install:
npm i coinhive-lib
Simple to use
coinhive-lib.js is a wrapper for the Coinhive HTTP API, its really simple and it comes in two flavours, traditional with callback and a promise api
const CoinhiveLib CoinhivePromiseLib = const coinhivePromise = const coinhive = coinhivePromise ; coinhive
Like it? buy me a beer!
BTC: 1M8sQivGiMx2f3R6rP3raTq5PDbnTHeC5n
XMR: 4A76foXYghp1WBDjLjA4EDPwsvAisHRQY3tq8cUkBuducW6WkyhcU2EX5qiSxFdLQFLVaeeZcUhJULjwyBYeJFRdKVh2BxM
Methods
- Token verify
- User: balance
- User: withdraw
- User: top users
- User: list users
- User: reset user
- User: reset all users
- Link: create
- Stats: payout
- Stats: site
- Stats: history
Token verify
Coinhive endpoint: /token/verify
Verify that a token from a CoinHive.Token miner has reached a number of hashes. Tokens are only valid for 1 hour. Note that a token can only be verified once. All subsequent requests to verify the same token will result in the invalid_token error.
Usage
const coinhive = coinhive
Usage with promise
const coinhivePromise = coinhivePromise })
User: balance
Coinhive endpoint: /user/balance
Get the total number of hashes, the withdrawn hashes and the current balance for a user name. Think of it as the balance of a bank account. Hashes can be paid in through mining, and withdrawn through /user/withdraw.
Usage
const coinhive = coinhive
Usage with promise
const coinhivePromise = coinhivePromise })
User: withdraw
Coinhive endpoint: /user/withdraw
Withdraw a number of hashes for a user name. If successful, the requested amount will be subtracted from the user's balance.
Usage
const coinhive = coinhive
Usage with promise
const coinhivePromise = coinhivePromise })
User: top users
Coinhive endpoint: /user/top
Get a list of top users ordered by total number of hashes, balance or hashes withdrawn.
Usage
const coinhive = coinhive
Usage with promise
const coinhivePromise = coinhivePromise })
User: list users
Coinhive endpoint: /user/list
Get a paginated list of all users in alphabetical order. Note that this will only return users with a total number of hashes greater than 0.
Usage
const coinhive = coinhive
Usage with promise
const coinhivePromise = coinhivePromise })
User: reset user
Coinhive endpoint: /user/reset
Reset a user's total hashes and withdrawn amount to 0.
Usage
const coinhive = coinhive
Usage with promise
const coinhivePromise = coinhivePromise })
User: reset all users
Coinhive endpoint: /user/reset-all
Reset the hashes and withdrawn amount for all users for this site to 0.
Usage
const coinhive = coinhive
Usage with promise
const coinhivePromise = coinhivePromise })
Link: create
Coinhive endpoint: /link/create
Create a new shortlink. You can also do this by hand, directly from your dashboard.
Usage
const coinhive = coinhive
Usage with promise
const coinhivePromise = coinhivePromise })
Stats: payout
Coinhive endpoint: /stats/payout
Get the current payout rate and stats about the network.
Usage
const coinhive = coinhive
Usage with promise
const coinhivePromise = coinhivePromise })
Stats: site
Coinhive endpoint: /stats/site
Get the current hashrate, total hashes, paid & pending xmr, and the hourly history for the past seven days for the site.
Usage
const coinhive = coinhive
Usage with promise
const coinhivePromise = coinhivePromise })
Stats: history
Coinhive endpoint: /stats/history
Get the hourly history of total hashes and hashes/s for a time period for the site.
Usage
const coinhive = coinhive
Usage with promise
const coinhivePromise = coinhivePromise })