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

coinhiveapi

v1.0.1

Published

Unofficial module for Coinhive API

Downloads

13

Readme

CoinhiveAPI

Unofficial module for Coinhive API

##Constructor

    /**
     *
     * @param secret_key Coinhive Secret Key
     */
    constructor (secret_key)

##token/verify

    /**
     * @description The method to verify that a token from a CoinHive.Token miner has reached a number of hashes
     * @param token The name of the token you want to verify
     * @param hashes The number of hashes this token must have reached in order to be vali
     * @param callback The callback
     */
    verify(token, hashes, callback)

##user/balance

    /**
     * @description The method to get the total number of hashes, the withdrawn hashes and the current balance for a user name
     * @param name The user's name, analogous to the name specified for the CoinHive.User miner
     * @param callback The callback
     */
    balance(name, callback)

##user/withdraw

    /**
     * @description The method to withdraw a number of hashes for a user name
     * @param name The user's name, analogous to the name specified for the CoinHive.User miner
     * @param amount The amount of hashes to withdraw.
     * @param callback The callback
     */
    withdraw(name, amount, callback)

##user/top

    /**
     * @description The method to get a list of top users ordered by total number of hashes, balance or hashes withdrawn
     * @param count The number of users to return. Default 128, min 1, max 1024.
     * @param order Either total, balance or withdrawn. The default is total
     * @param callback The callback
     */
    top(count, order, callback)

##user/list

    /**
     * @description The method to get a paginated list of all users in alphabetical order
     * @param count The number of users to return. Default 4096, min 32, max 8192
     * @param page The page of users to return, obtained from the previous request's nextPage property
     * @param callback The callback
     */
    list(count, page, callback)

##user/reset

    /**
     * @description The method to reset a user's total hashes and withdrawn amount to 0.
     * @param name The user's name whose total and withdrawn values will be reset to 0
     * @param callback The callback
     */
    reset(name, callback)

##user/reset-all

    /**
     * @description The method to reset the hashes and withdrawn amount for all users for this site to 0
     * @param callback The callback
     */
    resetAll(callback)

##link/create

    /**
     * @description The method to create a new shortlink
     * @param url The target URL for the shortlink
     * @param hashes The number of hashes that have to be solved, before the user is redirected to the target URL
     * @param callback The callback
     */
    create(url, hashes, callback)

##stats/payout

    /**
     * @description The method to get the current payout rate and stats about the network
     * @param callback The callback
     */
    payout(callback)

##stats/site

/**
     * @description The method to get the current hashrate, total hashes, paid & pending xmr, and the hourly history for the past seven days for the site
     * @param callback The callback
     */
    site(callback)

##stats/history

    /**
     * @description The method to get the hourly history of total hashes and hashes/s for a time period for the site
     * @param begin Unix timestamp of the begin of the period you want to retrieve
     * @param end Unix timestamp of the end of the period you want to retrieve
     * @param callback The callback
     */
    history(begin, end, callback)

Example

    const CoinhiveAPI = require('coinhiveapi');

    let coinhivebapi = new CoinhiveAPI('azertyuiopqsdfghjklmwxcvbn');
    
    coinhivebapi.balance("johndoe",res => {
        if(res.total > 4068) {
            //Withdraw 4068 hashes
            coinhivebapi.withdraw('johndoe', 4068, res => {
                console.log(res);
            });
        }
    })