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

@blockbee/api

v2.1.0

Published

BlockBee's Library for NodeJS

Downloads

157

Readme

BlockBee's NodeJS Library

NodeJS's implementation of BlockBee's payment gateway

Table of Contents

  1. Requirements
  2. Installation
  3. API and utils
  4. Checkout
  5. Payouts
  6. Help
  7. Changelog

Requirements:

NodeJS >= 20

Installation

npm install @blockbee/api

API and utils

Importing in your project file

var BlockBee = require('@blockbee/api')

Generating a new Address

const bb = new BlockBee(coin, myAddress, callbackUrl, params, blockbeeParams, apiKey)

const address = await bb.getAddress()

Where:

  • coin is the coin you wish to use, from BlockBee's supported currencies (e.g 'btc', 'eth', 'erc20_usdt', ...).
  • myAddress is your own crypto address, where your funds will be sent to. It's optional, you can leave it empty (e.g '') if you are setting it up in BlockBee's dashboard.
  • callbackUrl is the URL that will be called upon payment.
  • params is any parameter you wish to send to identify the payment, such as {orderId: 1234}.
  • blockbeeParams parameters that will be passed to BlockBee _(check which extra parameters are available here: https://docs.blockbee.io/#operation/create).
  • apiKey is the API Key provided by BlockBee's dashboard.
  • address is the newly generated address, that you will show your users in order to receive payments.

Response sample:

0x0E945b1554c8029A6B9bE1F7A24ae75d2F44d8DB

Getting notified when the user pays

Once your customer makes a payment, BlockBee will send a callback to your callbackUrl. This callback information is by default in GET but you can se it to POST by setting post: 1 in blockbeeParams. The parameters sent by BlockBee in this callback can be consulted here: https://docs.blockbee.io/#operation/confirmedcallbackget

Checking the logs of a request

const bb = new BlockBee(coin, myAddress, callbackUrl, params, blockbeeParams, apiKey)

const data = await bb.checkLogs()

Response sample:

{
  "status": "success",
  "callback_url": "https://example.com/?order_id=1235",
  "address_in": "0x58e90D31530A5566dA97e34205730323873eb88B",
  "address_out": "0xA6B78B56ee062185E405a1DDDD18cE8fcBC4395d",
  "notify_pending": false,
  "notify_confirmations": 1,
  "priority": "default",
  "callbacks": []
}

All the data returned in the response can be checked here: https://docs.blockbee.io/#operation/logs

Generating a QR code

const bb = new BlockBee(coin, myAddress, callbackUrl, params, blockbeeParams, apiKey)

const qrCode = await bb.getQrcode(value, size)

For object creation, same parameters as before. You must first call ``getAddress` as this method requires the payment address to have been created.

Where:

  • value is the value requested to the user in the coin to which the request was done. Optional, can be empty if you don't wish to add the value to the QR Code.
  • size Size of the QR Code image in pixels. Optional, leave empty to use the default size of 512.
  • apiKey is the API Key provided by BlockBee's dashboard.

Response is an object with qr_code (base64 encoded image data) and payment_uri (the value encoded in the QR), see https://docs.blockbee.io/#operation/qrcode for more information.

Response sample:

{
  "status": "success",
  "qr_code": "iVBORw0KGgoAAAANSUhEUgAAASwAAAEsCAIAAAD2HxkiAAAYeklEQVR4nO3daZQdZZkH8Od5q+quvXenO3tCQtg3WQLDOiwi4FEGRA96RhkRlEUd9cw5Ojif/DTOHEcF4YAwntFRhBEHBPWoKAECGNnXSICQBEL23m/fvkvV+8yHut3pEPoSaop6qjv/3wcOSbrurVv3/vutW8/7vMUiQgC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QRQhhACKEMIAZQ1K9bHWERWr0cnc6vgNL/MmUh9efhkjidGQgBlCCGAMoQQQBlCCKAMIQRQhhACKEMIAZRFaepNs2QaNONtEdZtOFbvqY33oWbiYtYYCQGUIYQAyhBCAGUIIYAyhBBAGUIIoAwhBFCGEAIoa1asn85MbF2Nt1YegXpFOALsWDI3fsZICKAMIQRQhhACKEMIAZQhhADKEEIAZQghgDKEEEBZlGJ9EzEWvhMryMa4Ane8dX/1lQ1wBCKIUN/HSAigDCEEUIYQAihDCAGUIYQAyhBCAGUIIYCymOuEqZXMms2JLbOdTAEt3lJtjPXYeMV7MCPsM0ZCAGUIIYAyhBBAGUIIoAwhBFCGEAIoQwgBlCGEAMr2l2J9vOItIiezzHMyNxKPMMFA/QbX6guNYyQEUIYQAihDCAGUIYQAyhBCAGUIIYAyhBBAGSdT2IlXMh26EUQ7MjGW49K8Wm4yTb3qtU0s/gsw8yCEAMoQQgBlCCGAMoQQQBlCCKAMIQRQhhACKItSrE8z3fKuet05AvVVw5PpkI79iWKEkRBAGUIIoAwhBFCGEAIoQwgBlCGEAMoQQgBlzeqEAJAAjIQAyhBCAGUIIYAyhBBAGUIIoAwhBFCGEAIoQwgBlP0fDDJ0PYOZxyEAAAAASUVORK5CYII=",
  "payment_uri": "0x0E945b1554c8029A6B9bE1F7A24ae75d2F44d8DB"
}

Usage

<img src={`data:image/png;base64,${qr_code}`}/>

Estimating transaction fees

const fees = await BlockBee.getEstimate(coin, apiKey, addresses, priority)

Where:

  • coin is the coin you wish to check, from BlockBee's supported currencies (e.g btc, eth, erc20_usdt, ...)
  • apiKey is the API Key provided by BlockBee's dashboard.
  • addresses The number of addresses to forward the funds to. Optional, defaults to 1.
  • priority Confirmation priority, (check this article to learn more about it). Optional, defaults to default.

Response is an object with estimated_cost and estimated_cost_usd, see https://docs.blockbee.io/#operation/estimate for more information.

Response sample:

{
  "status": "success",
  "estimated_cost": "0.00637010",
  "estimated_cost_currency": {
    "AED": "0.03",
    "AUD": "0.01",
    "BGN": "0.01",
    "BRL": "0.04"
  }
}

Converting between coins and fiat

const conversion = await BlockBee.getConvert(coin, value, from, apiKey)

Where:

  • coin the target currency to convert to, from BlockBee's supported currencies (e.g 'btc', 'eth', 'erc20_usdt', ...)
  • value value to convert in from.
  • from currency to convert from, FIAT or crypto.
  • apiKey is the API Key provided by BlockBee's dashboard.

Response is an object with value_coin and exchange_rate, see https://docs.blockbee.io/#operation/convert for more information.

Response sample:

{ 
  "status": "success", 
  "value_coin": "241.126", 
  "exchange_rate": "0.803753"
}

Getting supported coins

const supportedCoins = await BlockBee.getSupportedCoins(apiKey)

Where:

  • apiKey is the API Key provided by BlockBee's dashboard.

Response is an array with all supported coins.

Response sample:

{
  "btc": {
    "coin": "Bitcoin",
    "logo": "https://api.cryptapi.io/media/token_logos/btc.png",
    "ticker": "btc",
    "minimum_transaction": 8000,
    "minimum_transaction_coin": "0.00008000",
    "minimum_fee": 546,
    "minimum_fee_coin": "0.00000546",
    "fee_percent": "1.000",
    "network_fee_estimation": "0.00002518"
  },
  "bch": {
    "coin": "Bitcoin Cash",
    "logo": "https://api.cryptapi.io/media/token_logos/bch.png",
    "ticker": "bch",
    "minimum_transaction": 50000,
    "minimum_transaction_coin": "0.00050000",
    "minimum_fee": 546,
    "minimum_fee_coin": "0.00000546",
    "fee_percent": "1.000",
    "network_fee_estimation": "0.00000305"
  }
}

Checkout

Requesting Payment

const paymentRequest = await BlockBee.paymentRequest(redirectUrl, notifyUrl, value, params, bbParams, apiKey)

Where:

  • redirectUrl URL in your platform, where the user will be redirected to following the payment. Should be able to process the payment using the success_token, if you wish to use this URL to confirm payment.
  • notifyUrl URL in your platform, where the IPN will be sent notifying that a deposit was done. Parameters are available here: https://docs.blockbee.io/#operation/depositipn.
  • value amount in currency set in Payment Settings you want to receive from the user.
  • bbParams parameters that will be passed to BlockBee _(check which extra parameters are available here: https://docs.blockbee.io/#operation/create).
  • params is any parameter you wish to send to identify the payment, such as {order_id: 1234}.
  • apiKey is the API Key provided by our Dashboard.

Getting notified when the user completes the Payment

When receiving payments, you have the option to receive them in either the notify_url or the redirect_url, but adding the redirect_url is required (refer to our documentation at https://docs.blockbee.io/#operation/paymentipn).

Payment samples:

{
  "status": "success",
  "success_token": "G4asA2xwEr0UeY2IZqlZjX3IYrNofmnIAkzHPAoxmpmlYP9ZLTvQUolKN0X27Z0B",
  "payment_url": "https://pay.blockbee.io/payment/OcRrZGsKQFGsoi0asqZkr97WbitMxFMb/",
  "payment_id": "OcRrZGsKQFGsoi0asqZkr97WbitMxFMb"
}

Payment Logs

Fetch Payment information and IPN logs.

const logs = await BlockBee.paymentLogs(token, apiKey);

Where:

  • token is the payment_id returned by the payment creation endpoint.

Response sample:

{
  "status": "success",
  "is_paid": false,
  "is_pending": false,
  "is_expired": false,
  "is_partial": false,
  "payment_data": [
    {
      "value": "0.000137",
      "value_paid": "0",
      "value_outstanding": "0.000137",
      "exchange_rate": "0.0000137489",
      "coin": "btc",
      "txid": []
    }
  ],
  "notifications": []
}

Requesting Deposit

const deposit = await BlockBee.depositRequest( notifyUrl, apiKey, params, bbParams )

Where:

  • notifyUrl URL in your platform, where the IPN will be sent notifying that a deposit was done. Parameters are available here: https://docs.blockbee.io/#operation/depositipn.
  • apiKey is the API Key provided by our Dashboard.
  • params is any parameter you wish to send to identify the payment, such as {order_id: 1234}.
  • bbParams parameters that will be passed to BlockBee _(check which extra parameters are available here: https://docs.blockbee.io/#operation/deposit).

Response sample:

{
  "status": "success",
  "payment_url": "https://pay.blockbee.io/deposit/jv12du8IWqS96WVDjZK2J285WOBOBycc/",
  "payment_id": "jv12du8IWqS96WVDjZK2J285WOBOBycc"
}

Deposit Logs

Fetch Deposit information and IPN logs.

const logs = await BlockBee.depositLogs(token, apiKey);

Where:

  • token is the payment_id returned by the deposit creation endpoint.

Response sample:

{
  "status": "success",
  "deposits": [],
  "total_deposited": "0",
  "currency": "USDT",
  "notifications": []
}

Payouts

Create Payout / Payout Request

This function can be used by you to create Payouts.

const coin = 'polygon_matic'

const requests = {
    '0xA6B78B56ee062185E405a1DDDD18cE8fcBC4395d': 0.5,
    '0x18B211A1Ba5880C7d62C250B6441C2400d588589': 0.1
}

const createPayout =  await BlockBee.createPayout(coin, requests, apiKey, process);

Where:

  • coin The cryptocurrency you want to request the Payout in (e.g btc, eth, erc20_usdt, ...).

  • requests Address(es) together with the amount that must be sent.

  • process If the Payout Requests will be sent right away. Defaults to false. Note: if true will instantly queue the payouts to be sent to the destination addresses.

Response sample:

If process is false.

{
  "status": "success",
  "request_ids": [
    103227,
    103228
  ]
}

If process is true.

{
  "status": "success",
  "queued": true
}

List Payouts / Payout Requests

List all Payouts or Payout Requests in your account.

Note: If requests is true it will fetch a Payout Requests list.

const createPayout =  await BlockBee.listPayouts(coin, status, page, apiKey, requests);

Where:

  • coin The cryptocurrency you want to request the lists in (e.g btc, eth, erc20_usdt, ...).

  • status The status of the Payout / Payout Request. Possible statuses are:

    • Payout Request: [all, pending, rejected, processing, done]
    • Payout: [created, processing, done, error]
  • page This endpoint is paginated and will show only 50 items per page. Defaults to 1.

  • requests If true will fetch Payout Requests, otherwise will fetch Payouts. Defaults to false.

Response sample:

{
  "status": "success",
  "payouts": [
    {
      "id": 2460,
      "status": "Done",
      "total_requested": "0.6",
      "total_with_fee": "0.606",
      "total_fiat": "",
      "fee": "0.006",
      "coin": "polygon_matic",
      "timestamp": "13/03/2024 17:48:39"
    }
  ],
  "num_pages": 1
}

Get Payout Wallet

Gets your Payout Wallet for the specified coin. Can algo get the balance.

const wallet = await getPayoutWallet(coin, apiKey, balance)

Where:

  • coin The cryptocurrency you want to request the lists in (e.g btc, eth, erc20_usdt, ...).

  • balance If true will also fetch the balance of the address.

Response sample:

{
  "address": "0x18B211A1Ba5880C7d62C250B6441C2400d588589",
  "balance": "2.7"
}

Create Payout with Payout Request ID(s)

With this function you can create a Payout in the created status by simply providing an array with the Payout Requests ID.

const ids = [52211, 52212]

const payout = await createPayoutByIds(apiKey, ids)

Where:

  • ids its an array with the Payout Requests ID.

Response sample:

{
  "status": "success",
  "payout_info": {
    "id": 2461,
    "status": "Created",
    "from": "",
    "requests": {
      "0xA8EbeD50f2e05fB4a25b2DdCdc651A7CA769B5CF": "0.300000000000000000",
      "0xA6B78B56ee062185E405a1DDDD18cE8fcBC4395d": "0.200000000000000000"
    },
    "total_requested": "0.5",
    "total_with_fee": "0.505",
    "total_fiat": "",
    "fee": "0.005",
    "coin": "bep20_usdt",
    "txid": "",
    "timestamp": "05/03/2024 15:00:00"
  }
}

Process Payout by ID

By default, a Payout when created will be in created state. With this function you may finish it using its ID.

const payout = await BlockBee.processPayout(apiKey, ids)

Where:

  • id Its the ID of the Payout you wish to fulfill.

Response sample:

{ 
  "status": "success", 
  "queued": true
}

Check the Payout status

Will return all important information regarding a Payout, specially its status.

const id = 51621

const status = await BlockBee.checkPayoutStatus(apiKey, id)

Where:

  • id Its the ID of the Payout you wish to check.

Response sample:

{
  "status": "success",
  "payout_info": {
    "id": 2463,
    "status": "Done",
    "from": "0x18B211A1Ba5880C7d62C250B6441C2400d588589",
    "requests": {
      "0xA6B78B56ee062185E405a1DDDD18cE8fcBC4395d": "0.500000000000000000",
      "0x18B211A1Ba5880C7d62C250B6441C2400d588589": "0.100000000000000000"
    },
    "total_requested": "0.6",
    "total_with_fee": "0.606",
    "total_fiat": "",
    "fee": "0.006",
    "coin": "polygon_matic",
    "txid": "0xf9aa1618a7e460f8c68b6a02369b5058282c53a4ee23f967abef0d35203f328c",
    "timestamp": "13/03/2024 18:10:35"
  }
}

Help

Need help?
Contact us @ https://blockbee.io/contacts/

Changelog

1.0.0

  • Initial Release

1.0.2

  • Version Bump

1.0.3

  • Minor fixes

1.0.4

  • Minor fixes

1.1.0

  • Added Payouts
  • Minor bugfixes

1.1.1

  • Minor bugfixes

2.0.0

  • Automated Payouts
  • Support to BlockBee Checkout page
  • Various improvements

2.0.1

  • Minor fixes

2.1.0

  • Minor bugfixes
  • Improve error handling

Breaking Changes

2.0.0

  • createPayout parameters were changed and will require you to update your code.