Files
bch-api/README.md
T

100 lines
4.5 KiB
Markdown
Raw Normal View History

2019-08-11 09:10:14 -07:00
# bch-api
2019-05-21 08:11:14 -07:00
2019-05-31 14:56:08 +00:00
[![Greenkeeper badge](https://badges.greenkeeper.io/christroutner/bch-api.svg)](https://greenkeeper.io/)
2019-08-11 09:40:47 -07:00
[![Build Status](https://travis-ci.org/christroutner/bch-api.svg?branch=master)](https://travis-ci.org/christroutner/bch-api)
2019-05-21 08:11:14 -07:00
This is a fork and alternative implementation of
the [rest.bitcoin.com](https://github.com/Bitcoin-com/rest.bitcoin.com) repository.
2019-08-11 09:10:14 -07:00
The purpose of this code is to create a REST API server that provides a common
2020-03-21 08:50:13 -07:00
interface for working with a Bitcoin Cash full node and various indexers. See [this article](https://troutsblog.com/research/bitcoin-cash/how-to-bch-full-stack-developer) to learn about the 'Cash Stack'. Visit [FullStack.cash](https://fullstack.cash), sign up for a free account, and use this REST API right away with the [bch-js](https://github.com/christroutner/bch-js) JavaScript library.
2019-05-21 08:11:14 -07:00
2019-12-08 08:28:00 -08:00
This repository is intended to be paired with [bch-js](https://github.com/christroutner/bch-js),
an npm JavaScript library, and an alternative implementation
of [BITBOX SDK](https://github.com/Bitcoin-com/bitbox-sdk).
2019-05-21 08:11:14 -07:00
2019-12-08 08:28:00 -08:00
Both bch-api and bch-js are part of the
[full stack of BCH software](https://troutsblog.com/research/bitcoin-cash/how-to-bch-full-stack-developer).
- [API Documentation](https://api.bchjs.cash/docs/)
2020-03-21 08:57:25 -07:00
- [BCH Example Applications](https://github.com/Permissionless-Software-Foundation/bch-js-examples)
- [slp-cli-wallet](https://github.com/christroutner/slp-cli-wallet): a hacker-friendly, command-line BCH and SLP token wallet using this REST API.
2019-05-21 08:15:12 -07:00
2019-08-11 09:39:17 -07:00
Have questions? Need help? Join our community support
[Telegram channel](https://t.me/bch_js_toolkit)
2019-05-21 08:15:12 -07:00
## Features
2019-08-11 09:36:20 -07:00
The following features set this repository apart from rest.bitcoin.com:
2019-12-08 08:28:00 -08:00
- Address balance and UTXO queries use the [Blockbook](https://github.com/trezor/blockbook)
indexer instead of Insight.
- Fine grain access is controlled with a JWT token using
[this back end auth server](https://github.com/Permissionless-Software-Foundation/jwt-bch-api) and [this front end](https://github.com/Permissionless-Software-Foundation/jwt-bch-frontend).
2020-03-21 08:57:25 -07:00
- Default rate limits are set to 3 RPM for anonymous connections, 10 RPM for [free accounts](https://fullstack.cash/pricing), up to 100 RPM if a full-access JWT token is used.
- Typescript removed and ES8 JavaScript used instead.
2019-08-11 09:36:20 -07:00
- npm audit run on all dependencies.
- [Greenkeeper](https://greenkeeper.io/) implemented for automatic dependency management
and security updates.
2019-08-11 09:36:20 -07:00
## Live Demo
You can test a live demo of the REST API by running the
2019-12-08 08:28:00 -08:00
[bch-js examples](https://github.com/Permissionless-Software-Foundation/bch-js-examples).
2020-03-21 08:57:25 -07:00
Rate limits are 3 requests per minute, but you can increase them to 10 with a [free account](https://fullstack.cash/pricing).
2019-12-08 08:28:00 -08:00
This is fast enough to try out the examples
2019-08-11 09:36:20 -07:00
but these servers are not intended as a freemium service. You can run your own
REST server by purchasing the hard drive at [bchjs.cash](https://bchjs.cash).
2020-03-21 08:57:25 -07:00
- Mainnet REST API server: https://api.fullstack.cash/v3/
- Testnet REST API server: https://tapi.fullstack.cash/v3/
- Check server status: https://metrics.fullstack.cash
2019-08-11 09:36:20 -07:00
## Installation
There are two installation paths, depending if you want a *development* or
*production* environment. You'll also need to set up the underlying infrastructure
2020-03-21 08:57:25 -07:00
described [this page](https://troutsblog.com/research/bitcoin-cash/how-to-bch-full-stack-developer).
2019-08-11 09:36:20 -07:00
This code targets the Ubuntu 18.04 LTS Linux OS.
2019-08-11 09:36:20 -07:00
### Development
This is a standard node.js project. The installation is as follows:
2019-08-11 09:36:20 -07:00
- Clone this repository:
2019-08-11 09:36:20 -07:00
`git clone https://github.com/christroutner/bch-api && cd bch-api`
2019-08-11 09:36:20 -07:00
- Install dependencies:
2019-08-11 09:36:20 -07:00
`npm install`
2019-08-11 09:36:20 -07:00
- Customize the [start-dev-example.sh](start-dev-example.sh) shell script to
point to the required infrastructure. Start the bch-api REST API by running
this script:
2019-08-11 09:36:20 -07:00
`./start-dev-example.sh`
2019-08-11 09:36:20 -07:00
### Production
For a production environment, a Docker container is provided in the
[docker](docker) directory. One for mainnet and one for testnet. Again, these
containers target the Ubuntu 18.04 LTS Linux OS.
2019-08-11 09:36:20 -07:00
- Install Docker and Docker Compose by following the commands on
[this Dev Ops page](https://troutsblog.com/research/dev-ops/overview).
2019-08-11 09:36:20 -07:00
- Customize the [bash script](docker/mainnet/start-local-mainnet.sh) for your
installation.
2019-08-11 09:36:20 -07:00
- Build the Docker container with:
2019-08-11 09:36:20 -07:00
`docker-compose build --no-cache`
2019-08-11 09:36:20 -07:00
- Run the Docker container with:
2019-08-11 09:36:20 -07:00
`docker-compose up`
2019-08-11 09:48:04 -07:00
## Support
Have questions? Need help? Join our community support
[Telegram channel](https://t.me/bch_js_toolkit)
2019-08-11 09:36:20 -07:00
## License
[MIT](LICENSE.md)