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

crypto-bot-js

v0.0.2

Published

Promise based Crypto Bot client for the browser and node.js

Downloads

1

Readme

CryptoBotJs

NPM Module for Crypto Pay API published for contest.

Installing

Using npm:

$ npm install crypto-bot-js

Using yarn:

$ yarn add crypto-bot-js

Usage

Javascript

//Import module as
const cb = require('crypto-bot-js');

//Then create new instance like
const cryptoBot = new cb.CryptoBot({
  target: 'testnet', //or mainnet
  token: 'YOUR-TOKEN_HERE' //Example 3274:AAOBNJIheTfZ3Gwp3lTH4IwxAYXNnA38M5u
});

//And then you can call any method you want like
cryptoBot.getMe().then((r) => {
  console.log(`My App name is ${r.name}`);
});

Typescript

import {CryptoBot, CryptoBotApp} from 'crypto-bot-js';

//Then you should create a new instance of CryptoBot
const cryptoBot = new CryptoBot({
  target: 'testnet',
  token: 'YOUR-TOKEN_HERE' //Example 3274:AAOBNJIheTfZ3Gwp3lTH4IwxAYXNnA38M5u
});

//Here you can execute any method you want.
cryptoBot.getMe().then((r: CryptoBotApp) => {
  console.log(`My App name is ${r.name}`);
});

Methods

| Method | Description | Request Params | Response Result | | ---------------- | ---------------------------------------------------------------- | ------------------------------------------------------------- | --------------------------------------------------------- | | getMe | A simple method for testing your app's authentication token | None | CryptoBotApp | | getBalance | Use this method to get balance of your app | None | Array of CryptoBotBalance | | getCurrencies | Use this method to get supported currencies | None | Array of CryptoBotCurrency | | getExchangeRates | Use this method to get exchange rates of supported currencies. | None | Array of CryptoBotExchangeRate | | createInvoice | Use this method to create a new invoice | CryptoBotInvoiceInput | CryptoBotInvoice | | getInvoices | Use this method to get invoices of your app | CryptoBotGetInvoicesInput | CryptoBotGetInvoicesResult | | confirmPayment | Use this method to confirm paid invoice of your app. | CryptoBotConfirmPaymentInput | CryptoBotPayment | | getPayments | Use this method to get paid and unconfirmed invoices of your app | CryptoBotGetPaymentsInput | CryptoBotGetPaymentsResult |

Request Parameters

These are the parameters you send in your request.

CryptoBotConfirmPaymentInput

| Name | Type | Optional | Default | Description | | ---------- | ------ | -------- | ------- | ----------- | | invoice_id | number | No | None | |

CryptoBotGetInvoicesInput

| Name | Type | Optional | Default | Description | | ----------- | --------------------------------- | -------- | ------- | ------------------------------------------------------------------------------ | | asset | CryptoBotAsset | Yes | None | Currency code. | | invoice_ids | string | Yes | None | Invoice IDs separated by comma. | | status | string | Yes | None | Status of invoices. Available statusses active or paid. Default all statusses. | | offset | number | Yes | 0 | Offset needed to return a specific subset of invoices. | | count | number | Yes | 100 | Number of invoices to return. Default 100, max 1000. |

CryptoBotGetPaymentsInput

| Name | Type | Optional | Default | Description | | ------ | ------ | -------- | ------- | ------------------------------------------------------ | | offset | number | Yes | 0 | Offset needed to return a specific subset of invoices. | | count | number | Yes | 100 | Number of invoices to return. |

CryptoBotInvoiceInput

| Name | Type | Optional | Default | Description | | --------------- | ------------------------------------------------------- | -------- | -------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | | asset | CryptoBotAsset | No | None | Currency code. | | amount | string | No | None | Amount of the invoice in float. For example 125.50 | | description | string | Yes | None | Description of the invoice. Up to 1024 symbols | | paid_btn_name | 'viewItem ' or 'openChannel' or 'openBot' or 'callback' | Yes | callback | This button will be shown when your invoice was paid | | paid_btn_url | string | Yes | None | This is required when you use paid_btn_name. Paid button URL.You can set any payment success link (for example link on your bot). Start with https or http. | | payload | string | Yes | None | Some data. User ID, payment id, or any data you want to attach to the invoice. | | allow_comments | boolean | Yes | true | Allow adding comments when paying an invoice. | | allow_anonymous | boolean | Yes | true | Allow pay invoice as anonymous |

Response Parameters

These are the parameters contained in a response of your request.

CryptoBotApp

| Name | Type | Description | | ------------------------------- | ------ | ----------- | | app_id | string | | | name | string | | | payment_processing_bot_username | string | |

CryptoBotAsset

Supported assets are

BTC, TON, ETH (only testnet), USDT, USDC, BUSD.

CryptoBotBalance

| Name | Type | Description | | ------------- | ------ | ----------- | | currency_code | string | | | available | string | |

CryptoBotCurrency

| Name | Type | Description | | ------------- | ------- | ----------- | | is_blockchain | boolean | | | is_stablecoin | boolean | | | is_fiat | boolean | | | name | string | | | code | string | | | url | string | | | decimals | number | |

CryptoBotExchangeRate

| Name | Type | Description | | -------- | ------- | ----------- | | is_valid | boolean | | | source | string | | | target | string | | | rate | string | |

CryptoBotGetInvoicesResult

| Name | Type | Description | | ----- | ---------------------------------------------- | ----------- | | count | number | | | items | Array of CryptoBotInvoice | |

CryptoBotGetPaymentsResult

| Name | Type | Description | | ----- | ---------------------------------------------- | ----------- | | count | number | | | items | Array of CryptoBotPayment | |

CryptoBotInvoice

| Name | Type | Description | | --------------- | --------------------------------- | ----------- | | invoice_id | number | | | status | string | | | hash | string | | | asset | CryptoBotAsset | | | amount | string | | | pay_url | string | | | created_at | string | | | allow_comments | boolean | | | allow_anonymous | boolean | | | is_confirmed | boolean | |

CryptoBotPayment

| Name | Type | Description | | --------------- | --------------------------------- | -------------------------------------------- | | invoice_id | number | | | status | string | | | hash | string | | | asset | CryptoBotAsset | | | amount | string | | | pay_url | string | | | created_at | string | | | paid_at | string | | | allow_comments | boolean | | | allow_anonymous | boolean | | | is_confirmed | boolean | | | confirmed_at | string or undefined | Won't be available in array of getPayments() |

Tests

Run

yarn test

Things to consider before running tests:

  • For the confirmTest to pass you need to manually pay for invoice using CryptoTestnetBot
  • For the getPayments to pass you need to at have at least one unconfirmed payment.
  • Also, you need to have your own app key since I may delete my app any time. You can get here.