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

just-mining

v0.0.1

Published

Node.js wrapper around Just Mining's API

Downloads

4

Readme

just-mining

Node.js wrapper around Just Mining’s API.

Actions Status npm JavaScript Style Guide license

:book: Table of contents

:floppy_disk: Installation

npm install just-mining --save # or yarn add just-mining

Node.js version 6 or higher is required.

Note: while Node.js from version 6 is supported, keep in mind that this library is only tested against Node.js 10+.

Back to top

:beginner: Usage

const JM = require('just-mining')

const client = new JM({ apiKey: 'YOUR_API_KEY' })

await JM.walletAddresses.list()
await JM.hardwares.get('bobs', 12345)
await JM.get('all')
await JM.get(['masternodes', 'operations'])
await JM.get({
  walletAddresses: 'all',
  clouds: [12345, 67890],
  hardwares: ['bobs', {
    type: 'asics',
    id: 12345
  }],
  stakings: 'KAVA'
})

Back to top

:building_construction: Constructor

When instanciating the constructor, you have to provide parameters as an object with following properties :

  • apiKey (required): API key provided by Just Mining.
  • version (optional): target a specific version of Just Mining’s API.
    • As of today, the only available version is v1.

I do not know how Just Mining is planning to handle next versions. Will they disable older versions, keep all versions in parallel, keep older versions for some time before disabling them? I do not know. I will try to keep this library up-to-date with available versions.

Back to top

:scroll: Methods

Just Mining’s API is organized around resources. Available resources are:

  • Cloud contracts
  • Hardwares
  • Masternodes
  • Operations
  • Staking contracts
  • Wallet addresses
  • Wallets

Each resource is available as a property of the client object:

client.masternodes
client.hardwares
...and so on

Each and every resource property has two exposed methods which are the following: get and list.

Back to top

client.clouds.get(id)

Get an owned cloud contract.

Arguments

  • id (Number): cloud contract identifier

Returns

  • (Object): Returns an object describing the cloud contract

Throws

  • if id is not provided
  • if id is not a number
  • if cloud contract was not found

Example

await client.clouds.get(571)
// => {
//   id: 571,
//   status: 'inactive',
//   startDate: false,
//   expirationDate: 1535932800,
//   hashrate: 1000000,
//   currencyCode: 'ETC',
//   mined: {
//     ETH: 0.05191667,
//     ZEC: 0.00160224,
//     ETC: 0.09365148
//   }
// }

Back to top

client.clouds.list()

Get all owned cloud contracts.

Returns

  • (Array): Returns an array of objects describing cloud contracts

Throws

  • if cloud contracts were not found

Example

await client.clouds.list()
// => [{
//   id: 571,
//   status: 'inactive',
//   startDate: false,
//   expirationDate: 1535932800,
//   hashrate: 1000000,
//   currencyCode: 'ETC',
//   mined: {
//     ETH: 0.05191667,
//     ZEC: 0.00160224,
//     ETC: 0.09365148
//   }
// }, {
//   id: 6904,
//   status: 'active',
//   startDate: false,
//   expirationDate: 1653682867,
//   hashrate: 100000000,
//   currencyCode: 'GRIN',
//   mined: {
//     GRIN: 0.19518281
//   }
// }]

Back to top

client.hardwares.get(type, id)

Get an owned machine.

Arguments

  • type (String): machine type (asics or bobs)
  • id (Number): machine identifier

Returns

  • (Object): Returns an object describing the machine

Throws

  • if type is not one of asics or bobs
  • if type is not a string
  • if id is not provided
  • if id is not a number
  • if hardware was not found

Example

await client.hardwares.get('bobs', 580099)
// => {
//   serial: 580099,
//   status: 'inactive',
//   uptime: '285',
//   lastActivity: 1568986845,
//   hashrate: 175260000,
//   currencyCode: 'ETH',
//   mined: {
//     ETH: 0.00003053
//   }
// }

Back to top

client.hardwares.list(type)

Get all machines. If type is provided, get all machines of this type.

Returns

If type is provided:

  • (Array): Returns an array of objects describing machines

If type is omitted:

  • (Object): Returns an object with properties matching machine types and containing an array of objects describing machines

Throws

  • if machines were not found

Example

await client.hardwares.list()
// => {
//   asics: [{
//     id: 330,
//     type: 'S17+',
//     status: 'active',
//     hashrate: 36270000000000,
//     currencyCode: 'BTC',
//     uptime: 71640,
//     mined: {
//       BTC: 0.02070824
//     }
//   }],
//   bobs: [{
//     serial: 580099,
//     status: 'inactive',
//     uptime: '285',
//     lastActivity: 1568986845,
//     hashrate: 175260000,
//     currencyCode: 'ETH',
//     mined: {
//       ETH: 5.00003053
//     }
//   }]
// }

await client.hardwares.list('bobs')
// => [{
//   serial: 580099,
//   status: 'inactive',
//   uptime: '285',
//   lastActivity: 1568986845,
//   hashrate: 175260000,
//   currencyCode: 'ETH',
//   mined: {
//     ETH: 5.00003053
//   }
// }]

Back to top

client.masternodes.get(id)

Get an owned masternode.

Arguments

  • id (Number): masternode identifier

Returns

  • (Object): Returns an object describing the masternode

Throws

  • if id is not provided
  • if id is not a number
  • if masternode was not found

Example

await client.masternodes.get(9208)
// => {
//   id: 9208,
//   status: 'active',
//   collateral: 250,
//   currencyCode: 'BITG',
//   reward: 0.00149775,
//   startDate: 1590739635,
//   endDate: null
// }

Back to top

client.masternodes.list()

Get all owned masternodes.

Returns

  • (Array): Returns an array of objects describing masternodes

Throws

  • if masternodes were not found

Example

await client.masternodes.list()
// => [{
//   id: 9208,
//   status: 'active',
//   collateral: 250,
//   currencyCode: 'BITG',
//   reward: 0.00149775,
//   startDate: 1590739635,
//   endDate: null
// }, {
//   id: 9224,
//   status: 'active',
//   collateral: 4.2,
//   currencyCode: 'ZEN-42',
//   reward: 0.00001253,
//   startDate: 1590739640,
//   endDate: null
// }]

Back to top

client.operations.get(id)

Get an operation (withdrawal, exchange, debit or credit).

Arguments

  • id (Number): operation identifier

Returns

  • (Object): Returns an object describing the operation

Throws

  • if id is not provided
  • if id is not a number
  • if operation was not found

Example

await client.operations.get(5412)
// => {
//   id: 5412,
//   type: 'withdraw',
//   status: 'paid',
//   date: 1544977587,
//   sourceCurrencyCode: 'ETC',
//   sourceAmount: 1,
//   destinationCurrencyCode: 'ETC',
//   destinationAmount: 0,
//   destinationAddress: '0x........................',
//   memo: null
// }

Back to top

client.operations.list()

Get all account operations.

Returns

  • (Array): Returns an array of objects describing operations

Throws

  • if operations were not found

Example

await client.operations.list()
// => [{
//   id: 3010,
//   type: 'withdraw',
//   status: 'paid',
//   date: 1538914035,
//   sourceCurrencyCode: 'ETH',
//   sourceAmount: 3.7,
//   destinationCurrencyCode: 'ETH',
//   destinationAmount: 0,
//   destinationAddress: '0x..................',
//   memo: null
// }, {
//   id: 4027,
//   type: 'withdraw',
//   status: 'paid',
//   date: 1537115656,
//   sourceCurrencyCode: 'ETH',
//   sourceAmount: 0.517,
//   destinationCurrencyCode: 'ETH',
//   destinationAmount: 0,
//   destinationAddress: '0x....................',
//   memo: null
// }, {
//   id: 5181,
//   type: 'exchange',
//   status: 'paid',
//   date: 1536862720,
//   sourceCurrencyCode: 'ZEC',
//   sourceAmount: 0.00370617,
//   destinationCurrencyCode: 'ETH',
//   destinationAmount: 0.00233272
// }, {
//   id: 4522,
//   type: 'credit',
//   status: 'paid',
//   date: 1532299229,
//   currencyCode: 'BCARD',
//   amount: 5,
//   details: 'Masternode sale'
// }]

Back to top

client.stakings.get(currencyCode)

Get an owned staking contract.

Arguments

  • currencyCode (String): staking contract currency code

Returns

  • (Object): Returns an object describing the staking contract

Throws

  • if currencyCode is not provided
  • if currencyCode is not a string
  • if staking contract was not found

Example

await client.stakings.get('KAVA')
// => {
//   currencyCode: 'KAVA',
//   amount: 75,
//   reward: 0.01027898,
//   lockedReward: 0,
//   startDate: 1590582716,
//   variations: [
//     {
//       amount: 75,
//       date: 1590582716,
//       effectiveDate: 1590669116,
//       applied: 1
//     }
//   ],
//   credits: [
//     {
//       amount: 0.00432936,
//       date: 1590710400,
//       releaseDate: false,
//       released: 1
//     },
//     {
//       amount: 0.00594962,
//       date: 1590624000,
//       releaseDate: false,
//       released: 1
//     }
//   ]
// }

Back to top

client.stakings.list()

Get all owned staking contracts.

Returns

  • (Array): Returns an array of objects describing staking contracts

Throws

  • if staking contracts were not found

Example

await client.stakings.list()
// => [{
//   currencyCode: 'KAVA',
//   amount: 75,
//   reward: 0.01027898,
//   lockedReward: 0,
//   startDate: 1590582716,
//   variations: [
//     {
//       amount: 75,
//       date: 1590582716,
//       effectiveDate: 1590669116,
//       applied: 1
//     }
//   ],
//   credits: [
//     {
//       amount: 0.00432936,
//       date: 1590710400,
//       releaseDate: false,
//       released: 1
//     },
//     {
//       amount: 0.00594962,
//       date: 1590624000,
//       releaseDate: false,
//       released: 1
//     }
//   ]
// }, {
//   currencyCode: 'SNX',
//   amount: 500,
//   reward: 0,
//   lockedReward: 0,
//   startDate: 1590594695,
//   variations: [
//     {
//       amount: 500,
//       date: 1590594695,
//       effectiveDate: 1590681095,
//       applied: 1
//     }
//   ],
//   credits: []
// }]

Back to top

client.walletAddresses.get(currencyCode, id)

Get an owned address.

Arguments

  • currencyCode (String): address currency code
  • id (Number): address identifier

Returns

  • (Object): Returns an object describing the address

Throws

  • if currencyCode is not provided
  • if currencyCode is not a string
  • if id is not provided
  • if id is not a number
  • if address was not found

Example

await client.walletAddresses.get('BNB', 11402)
// => {
//   id: 11402,
//   currencyCode: 'BNB',
//   name: null,
//   address: 'bnb.....................',
//   isBEP2: true,
//   memo: 'memo',
// }

Back to top

client.walletAddresses.list(currencyCode)

Get all addresses. If currencyCode is provided, returns all addresses for this currency code.

Returns

  • (Array): Returns an array of objects describing addresses

Throws

  • if addresses were not found

Example

await client.walletAddresses.list()
// => [{
//   id: 11401,
//   currencyCode: 'ETH',
//   name: null,
//   address: '0x............................',
//   isBEP2: false,
//   memo: null,
// }, {
//   id: 11402,
//   currencyCode: 'BNB',
//   name: null,
//   address: 'bnb.....................',
//   isBEP2: true,
//   memo: 'memo',
// }]

await client.walletAddresses.list('ETH')
// => [{
//   id: 11401,
//   currencyCode: 'ETH',
//   name: null,
//   address: '0x............................',
//   isBEP2: false,
//   memo: null,
// }]

Back to top

client.wallets.get(currencyCode)

Get an owned wallet.

Arguments

  • currencyCode (String): wallet currency code

Returns

  • (Object): Returns an object describing the wallet

Throws

  • if currencyCode is not provided
  • if currencyCode is not a string
  • if wallet was not found

Example

await client.wallets.get('ETH')
// => {
//   currencyCode: 'ETH',
//   balance: 0.03190596
// }

Back to top

client.wallets.list()

Get all owned wallets.

Returns

  • (Array): Returns an array of objects describing wallets

Throws

  • if wallets were not found

Example

await client.wallets.list()
// => [{
//   currencyCode: 'ZEC',
//   balance: 0.00160223
// }, {
//   currencyCode: 'ETH',
//   balance: 0.03190596
// }, {
//   currencyCode: 'ETC',
//   balance: 0.09259209
// }]

Back to top

:beetle: Debugging

This library uses debug package internally. You can enable debug logs by setting the DEBUG environment variable to just-mining:*.

You can target a specific resource debug logs by being more specific: DEBUG=just-mining:v1:walletAddresses.

Back to top

:game_die: Running tests

This package is tested against multiple different scenarios with Mocha and chai (through expect BDD style). It also rely on nock to mock API responses.

In order to run tests locally, you have to:

  • clone this repository
  • install development dependencies with npm install (or yarn install)
  • run tests with npm test (or yarn test)

Tests are run in bail mode. This means that whenever a test fails, all following tests are aborted.

Back to top

:busts_in_silhouette: Contributing

See CONTRIBUTING.md.

Back to top

:1234: Versioning

This project uses SemVer for versioning. For the versions available, see the tags on this repository.

Back to top