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

cryptopay

v1.3.3

Published

The unofficial Node.js library for the Cryptopay API

Downloads

5

Readme

Cryptopay

The unofficial Node.js library for the Cryptopay API.

npm version npm ci

Credentials

In order to use the Cryptopay API, you need to register on their website. After registration, you can create API keys. Create one and provide the details from that to the constructor function.

Usage

Installation

npm i cryptopay

Setup

const CryptopayClient = require("cryptopay");

const client = new CryptopayClient({
  apiKey: "api key here", // Your Cryptopay API Key
  apiSecret: "api secret here", // Your Cryptopay API Secret
  sandbox: false // Uses sandbox/development endpoints if true
});

Methods

getAllRates()

Get all public rates for cryptocurrencies.

Parameters

None

Returns

  • Promise (Multiple Objects with buy_rate and sell_rate keys)

Example

client.getAllRates().then(rates => {
  //...do something with the rates
});

getPairRate()

Get rate for a specific cryptocurrency pair.

Parameters

| Parameter | Type | Required | Description | | --------- | ------ | :------: | ------------------------- | | Pair | string | + | Currency pair e.g. BTCEUR |

Returns

  • Promise (Object with buy_rate and sell_rate keys)

Example

client.getPairRate("BTCEUR").then(rate => {
  //...do something with the rate
});

getAccounts()

Get all user created accounts.

Parameters

None

Returns

  • Promise (Array of AccountObject's)

Example

client.getAccounts().then(accounts => {
  //...do something with the accounts
});

getAccountTransactions()

Get all account transactions.

Parameters

| Parameter | Type | Required | Description | | ---------- | ------ | :------: | ------------------------- | | Account ID | string | + | Account ID from cryptopay |

Returns

  • Promise (Array of TransactionObject's)

Example

client
  .getAccountTransactions("91202339-52e2-432d-8078-12d49d96ce02")
  .then(transactions => {
    //...do something with the transactions
  });

createChannel()

Create channel and crypto address for the user

Parameters

| Parameter | Type | Required | Description | | ----------------- | ------ | :------: | ----------------------------------------------------------------- | | pay_currency | string | + | The cryptocurrency which you want to accept | | receiver_currency | string | + | The currency which all incoming transactions will be converted to | | custom_id | string | + | Custom ID to indentify channel | | name | string | | Channel name | | description | string | | Channel description |

Returns

  • Promise (ChannelObject)

Example

client
  .createChannel({
    pay_currency: "BTC",
    receiver_currency: "EUR",
    custom_id: "123456",
    name: "Deposit",
    description: "Deposit Address for User X"
  })
  .then(channel => {
    //...do something with the channel
  });

getAllChannels()

Get all channels created

Parameters

None

Returns

  • Promise (Array of ChannelObject's)

Example

client.getAllChannels().then(channels => {
  //...do something with the channels
});

getChannelPayments()

Get all specific channel payments

Parameters

| Parameter | Type | Required | Description | | ---------- | ------ | :------: | ----------- | | Channel ID | string | + | Channel ID |

Returns

  • Promise (Array of PaymentObject's)

Example

client
  .getChannelPayments("50eb5775-f77e-4c64-870b-dc93624b5967")
  .then(channels => {
    //...do something with the channels
  });

createCoinPayment()

Create a coin withdrawal payment

Parameters

| Parameter | Type | Required | Description | | ----------------- | ------ | :------: | ----------------------------------------------------- | | charged_currency | string | + | An account currency to send a transaction from | | received_currency | string | + | Cryptocurrency type | | charged_amount | number | + | All applicable fees will be deducted from this amount | | address | string | + | A recipient's cryptocurrency wallet address | | custom_id | string | + | Payment reference ID in your system |

Returns

  • Promise (PaymentObject)

Example

client
  .createCoinPayment({
    charged_currency: "EUR",
    received_currency: "BTC",
    charged_amount: 10,
    address: "2N122JKRz52gokTmaVYNiMA43qvdSqnhLGV",
    custom_id: "123456"
  })
  .then(payment => {
    //...do something with the payment
  });

commitCoinPayment()

Commit a coin withdrawal payment

Parameters

| Parameter | Type | Required | Description | | ---------- | ------ | :------: | ----------- | | Payment ID | string | + | Payment ID |

Returns

  • Promise (PaymentObject)

Example

client
  .commitCoinPayment("50eb5775-f77e-4c64-870b-dc93624b5967")
  .then(payment => {
    //...do something with the payment
  });

Objects

AccountObject

| Parameter | Type | Description | | ---------- | ------ | -------------------------------------------------------------------------------------------- | | id | string | Account ID | | balance | string | Account balance | | currency | string | Account currency | | project_id | string | Project ID which the account belongs to. Learn more about projects |

TransactionObject

| Parameter | Type | Description | | -------------- | ------ | ------------------------------------- | | id | string | Account transaction ID | | custom_id | string | Transaction custom_id | | amount | string | Transaction amount | | currency | string | Transaction currency | | balance | string | Account subtotal | | fee | string | Transaction fee details | | fee_currency | string | Transaction fee currency | | referecnce_id | string | Transaction reference ID in Cryptopay | | reference_type | string | Transaction type | | description | string | Transaction description | | status | string | Transaction status | | status_context | string | Transaction status context | | created_at | string | Transaction creation date and time |

ChannelObject

| Parameter | Type | Description | | ----------------- | ------ | ----------------------------------------------------------------- | | id | string | Channel ID | | name | string | Channel name | | description | string | Channel description | | receiver_currency | string | The currency which all incoming transactions will be converted to | | pay_currency | string | The cryptocurrency which you want to accept | | address | string | Channel cryptocurrency address | | project_id | string | Project ID. Learn more about projects | | custom_id | string | The channel reference ID in your system | | uri | string | Channel URI. May be used for generating a QR code | | hosted_page_url | string | Channel hosted page that renders channel details |

PaymentObject

| Parameter | Type | Description | | ------------------ | ------ | --------------------------------------------------------------------------------------------- | | id | string | Channel payment ID | | paid_amount | string | Cryptocurrency transaction amount that was received | | paid_currency | string | Cryptocurrency type | | received_amount | string | Amount credited to your Cryptopay account | | received_currency | string | Account currency | | fee | string | Processing fee | | fee_currency | string | Processing fee currency | | txid | string | Cryptocurrency transaction ID on the blockchain | | exchange | object | Exchange details | | -pair | string | Currency pair | | -rate | string | Exchange rate | | -fee | string | Exchange fee | | -fee_currency | string | Exchange fee currency | | status | string | Channel payment status. Refer to a list of channel payment statuses | | custom_id | string | Channel payment custom_id value inherited from its parent channel | | channel_id | string | Channel ID | | address | string | Channel cryptocurrency address | | risk | Object | Cryptocurrency transaction risk level details | | -score | number | Transaction risk score | | -level | string | Transaction risk level. low, medium or high depending on the score value | | -resource_name | string | A resource name the transaction has been received from e.g. Bitstamp | | -resource_category | string | A resource category the transaction has been received from e.g. Exchange | | created_at | string | Channel payment creation date and time |