Socket
Book a DemoInstallSign in
Socket

bitcoinfees-21co

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bitcoinfees-21co

realtime bitcoinfees from 21.co

0.0.3
latest
Source
npmnpm
Version published
Weekly downloads
3
Maintainers
1
Weekly downloads
 
Created
Source

node-bitcoinfees-21co

NPM
Build Status Coverage Status

bitcoinfees from 21.co

API Document

limit

Current API Rate Limit: 5000 requests per hour.
  • 5000 req/hour
  • 83.3 req/min
  • 1.3 req/sec

install

npm i bitcoinfees-21co

Usage

var bitcoinfees = require('bitcoinfees-21co');
bitcoinfees.FeesApi.recommended().then(function(res){
    console.log(res)
})
{ "fastestFee": 40, "halfHourFee": 20, "hourFee": 10 }

list

var bitcoinfees = require('bitcoinfees-21co');
bitcoinfees.FeesApi.list().then(console.log)
{ "fees": [ 
  {"minFee":0,"maxFee":0,"dayCount":545,"memCount":87,
  "minDelay":4,"maxDelay":32,"minMinutes":20,"maxMinutes":420},
...
 ] }

HTTP Error Handling

simple error control

bitcoinfees.FeesApi.recommended().catch(function(e){
    console.log(e.message)
})

technical error control

var errors = require('bitcoinfees-21co/errors')
bitcoinfees.FeesApi.recommended()
    .catch(errors.StatusCodeError, function (reason) {
        // HTTP STATUS ERROR(404 or 500, 502, etc...)
        console.log("HTTP StatusCodeError " + reason.statusCode, "HTTP", reason.statusCode)
    })
    .catch(errors.RequestError, function (reason) {
        // REQUEST ERROR(SYSTEMCALL, TIMEOUT)
        console.log(reason.message, "SYSCALL", reason.error.code)
    })
    .catch(function(e){
        // OTHER ERROR
        console.log(e.message)
    })

VALUE Error Handling

var bitcoinfees = require('bitcoinfees-21co');
var assert = require('assert');
var clamp = function(value, min, max){
    return Math.min(Math.max(min, value), max)
}
bitcoinfees.FeesApi.recommended().then(function(res){
    assert(res.hourFee > 0);
    return clamp(res.hourFee, 20, 200) // The API obstacle leads to loss
})

memo

It is better to store it in the database when using it on the server

Keywords

bitcoin

FAQs

Package last updated on 24 Jan 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.