1.0.2 • Published 3 years ago

rapidcoin-api v1.0.2

Weekly downloads
8
License
MIT
Repository
github
Last release
3 years ago

RapidCoin API

A nodejs library to communicate with the RapidCoin API.

Installation

npm i --save rapidcoin-api

Example Usage

const rapidCoinApi = require("rapidcoin-api");

const config = {
  url: "https://www.rapidcoin.com/api",
  apiKey: "my-api-key",
  apiVersion: "1.0"
};

const rc = new rapidCoinApi(config);
const response = await rc.createInvoice({});

Invoices

Creating an invoice

const response = await rc.createInvoice(params);

Parameters

The object parameters for creating an invoice are

keytypedescriptionrequired?
reference_idstringCustom reference id associated with invoiceno
customer_idstringCustom customer id associated with invoiceno
descriptionstringCustom description associated with invoiceno
confirmations_requiredintegerNumber of blockchains required to complete invoice transaction & trigger confirmation_url IPNno
notification_urlstringNotification URL to POST when transaction is received on addressno
confirmation_urlstringNotification URL to POST when blockchain confirmations reaches confirmations_requiredno
redirect_urlstringURL to redirect to after successful payment (web flow)no
currencystringThree character currency code, either USD or BTC. Used with amount to calculate rate & amount_btcno
amountnumberAmount of invoice in specified currencyno

Note: currency and amount are optional, if they are not specified the invoice will be created an "open" invoice

Response

keydescription
idUnique id of invoice
statusInvoice status, "open", pending", "confirming", "complete", "expired"
tokenUnique token of invoice
invoice_timeUNIX timestamp when invoice was created
expiration_timeUNIX timestamp of when invoice address is expired of invoice
exception_statusException status of invoice
currencyThree character currency code, either USD or BTC. Used with amount to calculate rate & amount_btc
rateRate used to convert amount in currency to amount_btc in BTC
amountAmount of invoice in specified currency (0 for open invoices)
amount_btcAmount of invoice in BTC, calculated from currency, amount, and rate (0 for open invoices)
paid_currencyThree character currency code, either USD or BTC. Used to show what currency customer will be paid out in
paid_rateRate used to convert amount in BTC to paid amount in paid_currency
paid_amountAmount paid out to customer in paid_currency
paid_amount_btcAmount paid out to customer in BTC
redirect_urlURL to redirect to after successful payment
notification_urlNotification URL to POST when transaction is received on address
confirmation_urlNotification URL to POST when blockchain confirmations reaches required_confirmations
confirmations_requiredNumber of blockchain confirmations required to complete invoice and trigger POST to confirmation_notification_url
reference_idCustom reference id associated with invoice provided on creation
customer_idCustom customer id associated with invoice provided on creation
descriptionCustom description associated with invoice provided on creation (if second deposit on address - description becomes SUB_INVOICE)
parent_invoice_idUnique Id of parent invoice (if second deposit made on the same address - will reference the first invoice created. null if first invoice)
addressBitcoin deposit address of invoice
paid_btcAmount paid by customer in BTC.
transactionsarray of blockchain transactions of payments to invoice invoice eg. "transactions": {"hash":"f7b0989105b03d69e1ef913b3f7a12df3886d334d0d8706ff77ea78e6602493f", "amount": 0, "confirmations" : 6, "time": 0, "received_time": 0}
current_timeCurrent timestamp of request

Reading information from an existing invoice

const response = await rc.readInvoice(id);

Parameters

The id passed in is the uuid of an existing invoice.

Response

keydescription
idUnique id of invoice
statusInvoice status, "open", pending", "confirming", "complete", "expired"
tokenUnique token of invoice
invoice_timeUNIX timestamp when invoice was created
expiration_timeUNIX timestamp of when invoice address is expired of invoice
exception_statusException status of invoice
currencyThree character currency code, either USD or BTC. Used with amount to calculate rate & amount_btc
rateRate used to convert amount in currency to amount_btc in BTC
amountAmount of invoice in specified currency (0 for open invoices)
amount_btcAmount of invoice in BTC, calculated from currency, amount, and rate (0 for open invoices)
paid_currencyThree character currency code, either USD or BTC. Used to show what currency customer will be paid out in
paid_rateRate used to convert amount in BTC to paid amount in paid_currency
paid_amountAmount paid out to customer in paid_currency
paid_amount_btcAmount paid out to customer in BTC
redirect_urlURL to redirect to after successful payment
notification_urlNotification URL to POST when transaction is received on address
confirmation_urlNotification URL to POST when blockchain confirmations reaches required_confirmations
confirmations_requiredNumber of blockchain confirmations required to complete invoice and trigger POST to confirmation_notification_url
reference_idCustom reference id associated with invoice provided on creation
customer_idCustom customer id associated with invoice provided on creation
descriptionCustom description associated with invoice provided on creation (if second deposit on address - description becomes SUB_INVOICE)
parent_invoice_idUnique Id of parent invoice (if second deposit made on the same address - will reference the first invoice created. null if first invoice)
addressBitcoin deposit address of invoice
paid_btcAmount paid by customer in BTC.
transactionsarray of blockchain transactions of payments to invoice invoice eg. "transactions": {"hash":"f7b0989105b03d69e1ef913b3f7a12df3886d334d0d8706ff77ea78e6602493f", "amount": 0, "confirmations" : 6, "time": 0, "received_time": 0}
current_timeCurrent timestamp of request

Updating an invoice

const response = await rc.updateInvoice(id, params);

Parameters

The id passed in is the uuid of an existing invoice.

The object parameters for updating an invoice are

keytypedescriptionrequired?
reference_idstringCustom reference id associated with invoiceno
customer_idstringCustom customer id associated with invoiceno
descriptionstringCustom description associated with invoiceno

Response

keydescription
idUnique id of invoice
statusInvoice status, "open", pending", "confirming", "complete", "expired"
tokenUnique token of invoice
invoice_timeUNIX timestamp when invoice was created
expiration_timeUNIX timestamp of when invoice address is expired of invoice
exception_statusException status of invoice
currencyThree character currency code, either USD or BTC. Used with amount to calculate rate & amount_btc
rateRate used to convert amount in currency to amount_btc in BTC
amountAmount of invoice in specified currency (0 for open invoices)
amount_btcAmount of invoice in BTC, calculated from currency, amount, and rate (0 for open invoices)
paid_currencyThree character currency code, either USD or BTC. Used to show what currency customer will be paid out in
paid_rateRate used to convert amount in BTC to paid amount in paid_currency
paid_amountAmount paid out to customer in paid_currency
paid_amount_btcAmount paid out to customer in BTC
redirect_urlURL to redirect to after successful payment
notification_urlNotification URL to POST when transaction is received on address
confirmation_urlNotification URL to POST when blockchain confirmations reaches required_confirmations
confirmations_requiredNumber of blockchain confirmations required to complete invoice and trigger POST to confirmation_notification_url
reference_idCustom reference id associated with invoice provided on creation
customer_idCustom customer id associated with invoice provided on creation
descriptionCustom description associated with invoice provided on creation (if second deposit on address - description becomes SUB_INVOICE)
parent_invoice_idUnique Id of parent invoice (if second deposit made on the same address - will reference the first invoice created. null if first invoice)
addressBitcoin deposit address of invoice
paid_btcAmount paid by customer in BTC.
transactionsarray of blockchain transactions of payments to invoice invoice eg. "transactions": {"hash":"f7b0989105b03d69e1ef913b3f7a12df3886d334d0d8706ff77ea78e6602493f", "amount": 0, "confirmations" : 6, "time": 0, "received_time": 0}
current_timeCurrent timestamp of request

Payouts

Creating a payout

const response = await rc.createPayout(params);

Parameters

The object parameters for creating an invoice are

keytypedescriptionrequired?
currencystringThree character currency code, either USD or BTC. Used with amount to calculate rate & amount_btcyes
amountnumberAmount of payout to send in specified currencyyes
addressstringBitcoin address to send payout tooyes
reference_idstringCustom reference id associated with payoutno
customer_idstringCustom customer id associated with payoutno
descriptionstringCustom description associated with payoutno

Response

keydescription
idUnique id of payout
statusPayout status, "pending", "complete", "exception"
addressBitcoin address of payout
currencyThree character currency code, either USD or BTC. Used with amount to calculate rate & amount_btc
amountAmount of payout to send in specified currency
amount_btcAmount of payout to send in BTC, calculated from currency, amount, and rate
rateRate used to convert amount in currency to amount_btc in BTC
reference_idCustom reference id associated with payout provided on creation
customer_idCustom customer id associated with payout provided on creation
descriptionCustom description associated with payout provided on creation
created_atDatetime payout transaction was created
completed_atDatetime payout transaction was completed
transactionDetails of blockchain transaction of payout eg. "transaction": {"hash":"f7b0989105b03d69e1ef913b3f7a12df3886d334d0d8706ff77ea78e6602493f"}

Reading information from an existing payout

const response = await rc.readPayout(id);

Parameters

The id passed in is the uuid of an existing invoice.

Response

keydescription
idUnique id of payout
statusPayout status, "pending", "complete", "exception"
addressBitcoin address of payout
currencyThree character currency code, either USD or BTC. Used with amount to calculate rate & amount_btc
amountAmount of payout to send in specified currency
amount_btcAmount of payout to send in BTC, calculated from currency, amount, and rate
rateRate used to convert amount in currency to amount_btc in BTC
reference_idCustom reference id associated with payout provided on creation
customer_idCustom customer id associated with payout provided on creation
descriptionCustom description associated with payout provided on creation
created_atDatetime payout transaction was created
completed_atDatetime payout transaction was completed
transactionDetails of blockchain transaction of payout eg. "transaction": {"hash":"f7b0989105b03d69e1ef913b3f7a12df3886d334d0d8706ff77ea78e6602493f"}

Other

Finding the currency exchange rate

const response = await rc.getRate(currency);

Parameters

The currency to look up for the exchange rate (currently only BTC or USD).

Response

keydescription
currencythe currency
ratecurrency exchange rate

Getting the available balance

const response = await rc.getOrganizationBalance();

Response

keydescription
btcthe BTC balance
usdthe amount in USD using the current exchange rate
1.0.2

3 years ago

1.0.1

5 years ago

1.0.0

5 years ago