Product
Introducing SSO
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
@cryptapi/api
Advanced tools
Readme
NodeJS's implementation of CryptAPI's payment gateway
npm install @cryptapi/api
const CryptAPI = require('@cryptapi/api')
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.Once your customer makes a payment, CryptAPI will send a callback to your
callbackUrl
. This callback information is by default inGET
but you can se it toPOST
by settingpost: 1
incryptapiParams
. The parameters sent by CryptAPI in this callback can be consulted here: https://docs.cryptapi.io/#operation/confirmedcallbackget
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
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) andpayment_uri
(the value encoded in the QR), see https://docs.cryptapi.io/#operation/qrcode for more information.
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
andestimated_cost_usd
, see https://docs.cryptapi.io/#operation/estimate for more information.
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
andexchange_rate
, see https://docs.cryptapi.io/#operation/convert for more information.
const supportedCoins = await CryptAPI.getSupportedCoins()
Response is an array with all support coins.
Need help?
Contact us @ https://cryptapi.io/contacts/
FAQs
CryptAPI's Library for NodeJS
The npm package @cryptapi/api receives a total of 36 weekly downloads. As such, @cryptapi/api popularity was classified as not popular.
We found that @cryptapi/api demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
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.
Product
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.