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

@cryptapi/api

v1.1.0

Published

CryptAPI's Library for NodeJS

Downloads

81

Readme

CryptAPI's NodeJS Library

NodeJS's implementation of CryptAPI's payment gateway

Install

npm install @cryptapi/api

Usage

Importing in your project file

const CryptAPI = require('@cryptapi/api')

Generating a new Address

const ca = new CryptAPI(coin, myAddress, callbackUrl, params, cryptapiParams)

const address = await ca.getAddress()

Where:

  • coin is the coin you wish to use, from CryptAPI's supported currencies (e.g 'btc', 'eth', 'erc20_usdt', ...).
  • myAddress is your own crypto address, where your funds will be sent to.
  • 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}.
  • cryptapiParams parameters that will be passed to CryptAPI _(check which extra parameters are available here: https://docs.cryptapi.io/#operation/create).
  • address is the newly generated address, that you will show your users in order to receive payments.

Getting notified when the user pays

Once your customer makes a payment, CryptAPI 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 cryptapiParams. The parameters sent by CryptAPI in this callback can be consulted here: https://docs.cryptapi.io/#operation/confirmedcallbackget

Checking the logs of a request

const ca = new CryptAPI(coin, myAddress, callbackUrl, params, cryptapiParams)

const data = await ca.checkLogs()

Same parameters as before, the data returned can b e checked here: https://docs.cryptapi.io/#operation/logs

Generating a QR code

const ca = new CryptAPI(coin, myAddress, callbackUrl, params, cryptapiParams)
    
const address = await ca.getAddress()

// ...

const qrCode = await ca.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.

For QR Code generation:

  • 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.

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

Estimating transaction fees

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

Where:

  • coin is the coin you wish to check, from CryptAPI's supported currencies (e.g 'btc', 'eth', 'erc20_usdt', ...)
  • 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.cryptapi.io/#operation/estimate for more information.

Converting between coins and fiat

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

Where:

  • coin the target currency to convert to, from CryptAPI's supported currencies (e.g 'btc', 'eth', 'erc20_usdt', ...)
  • value value to convert in from.
  • from currency to convert from, FIAT or crypto.

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

Getting supported coins

const supportedCoins = await CryptAPI.getSupportedCoins()

Response is an array with all support coins.

Help

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

Changelog

1.0.0

  • Initial Release

1.0.1

  • Minor fixes

1.0.2

  • Minor fixes

1.1.0

  • Minor bugfixes
  • Improve error handling