Code Monkey home page Code Monkey logo

crypto-bot-api's Introduction

Crypto Bot API

Simple and minimalistic client for Telegram CryptoBot Crypto Pay API.

Installing

Using npm/yarn:

$ npm install crypto-bot-api
$ yarn add crypto-bot-api

For browsers use bundles from dist directory or add package to your project dependencies and import it.

Supported environments

  • >= Node.js 12
  • >= Chrome 32
  • >= Firefox 29
  • >= Edge 12
  • >= Safari 8
  • >= Safari on iOS 8
  • > Android Browser 4.4.4

Usage

In Node.js:

const CryptoBotAPI = require('crypto-bot-api');

const client = new CryptoBotAPI('1234:AAA...AAA');

const me = await client.getMe();
console.log(me);

In browsers:

<script src="crypto-bot-api.min.js"></script>
<script>
  var client = new CryptoBotAPI('1234:AAA...AAA');

  client.getMe().then(function(me) {
    console.log(me);
  });
</script>

Important: at the time of publication of version 0.2.0 (Dec 9, 2021), API servers do not return header Access-Control-Allow-Origin, which allows make requests to API from third-party domains, so client request from website environment won't work (but its work in browser extensions, Electron and similar apps)

More usage examples see in examples project directory.

Receiving updates

Crypto Pay API support events by sending webhooks requests. To handle webhooks request library proposes to use creating Node.js built-in HTTPS server or using Express.js-like middleware API. See examples with names starts with webhooks-.

Note: you need enable webhooks in CryptoBot app settings.

Important: at the time of publication of version 0.2.0 (Dec 9, 2021), API servers do not accept self-signed certificates

Documentation

Library documentation can be found in repository GitHub page.

For Node.js usage, we advise you to start studying documentation with library default exported ClientEmitter class.

For browsers usage, we advise you to start studying documentation with library default exported for browsers Client class.

Building

Files for Node.js compiled to lib directory. Browsers bundles compiled to dist directory.

$ git clone https://github.com/sergeiivankov/crypto-bot-api
$ cd crypto-bot-api
$ npm i
$ npm run build-docs # To build library documentation
$ npm run build-lib # To build for Node.js
$ npm run build-dist # To build for Browsers
$ npm run build # To build all

Also, project have watch commands to using it in development:

$ npm run watch-docs # To watch build library documentation
$ npm run watch-lib # To watch build for Node.js
$ npm run watch-dist # To watch build for Browsers
$ npm run watch # To watch all

Resources

Code quality

To maintain high quality of the code and bring source code to a consistent form, project use eslint linter and has high documentation requirements. If you want to make a pull request, check that documentation matches your changes and eslint does not signal errors with command:

$ npm run lint

License

MIT

crypto-bot-api's People

Contributors

sergeiivankov avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Forkers

tonnfu22 deyvan

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.