Compare commits

...
10 Commits
Author SHA1 Message Date
Chris Troutner 7631a25f4b Merge pull request #56 from Permissionless-Software-Foundation/ct-unstable
Removing Blockbook documentation
2020-11-08 17:26:39 -08:00
Chris Troutner f41f9d33c8 feat(blockbook): Removing Blockbook documentation 2020-11-08 17:25:05 -08:00
Chris Troutner 3475255444 Updating diagram 2020-11-08 17:22:57 -08:00
Chris Troutner bcc5c95bd6 Updating README 2020-11-08 17:20:58 -08:00
Chris Troutner 15fe66bdf3 Merge branch 'master' into ct-unstable 2020-11-08 17:19:43 -08:00
Chris Troutner 8ce0209e9a Updating README 2020-11-08 17:19:30 -08:00
Chris Troutner c7c19d1c2b Merge pull request #55 from Permissionless-Software-Foundation/ct-unstable
Updating README
2020-11-08 17:17:15 -08:00
Chris Troutner f36146ef24 Updating README 2020-11-08 17:15:53 -08:00
Chris Troutner edae956742 Updating README 2020-11-08 17:13:03 -08:00
Chris Troutner 3f2890661c Updating README 2020-11-08 17:04:17 -08:00
6 changed files with 33 additions and 94 deletions
+14 -24
View File
@@ -1,19 +1,12 @@
# bch-api # bch-api
This is a node.js JavaScript REST API server using Express.js. The purpose of this code is to create a REST API server that provides a common 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.
[![Build Status](https://travis-ci.org/christroutner/bch-api.svg?branch=master)](https://travis-ci.org/christroutner/bch-api) This repository is intended to be paired with [bch-js](https://github.com/christroutner/bch-js), an npm JavaScript library for building Bitcoin Cash apps.
This is a fork and alternative implementation of ![Cash Stack Network Diagram](./generic-network-diagram.png)
the [rest.bitcoin.com](https://github.com/Bitcoin-com/rest.bitcoin.com) repository.
The purpose of this code is to create a REST API server that provides a common
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.
This repository is intended to be paired with [bch-js](https://github.com/christroutner/bch-js), Both bch-api and bch-js are part of the 'Cash Stack' [full stack of BCH software](https://troutsblog.com/research/bitcoin-cash/how-to-bch-full-stack-developer).
an npm JavaScript library, and an alternative implementation
of [BITBOX SDK](https://github.com/Bitcoin-com/bitbox-sdk).
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://fullstack.cash/documentation) - [API Documentation](https://fullstack.cash/documentation)
- [Example Code](https://fullstack.cash/examples) - [Example Code](https://fullstack.cash/examples)
@@ -24,32 +17,29 @@ Have questions? Need help? Join our community support:
## Features ## Features
The following features set this repository apart from rest.bitcoin.com: The following features set this repository apart from rest.bitcoin.com:
- 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 - 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). [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). Can be used to monetize access to the REST API.
- 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. - Typescript removed and ES8 JavaScript used instead.
- npm audit run on all dependencies. - npm audit run on all dependencies.
- [Greenkeeper](https://greenkeeper.io/) implemented for automatic dependency management
and security updates.
## Live Demo ## Live Demo
You can test a live demo of the REST API by running the You can test a live demo of the REST API by running the
[bch-js examples](https://github.com/Permissionless-Software-Foundation/bch-js-examples). [bch-js examples](https://github.com/Permissionless-Software-Foundation/bch-js-examples).
Rate limits are 3 requests per minute, but you can increase them to 10 with a [free account](https://fullstack.cash/pricing). Rate limits are 20 requests per minute, but you can increase them to 100 with a [paid account](https://fullstack.cash/pricing).
This is fast enough to try out the examples You can bootstrap your own REST API server by downloading and installing the infrastructure listed on the [CashStrap](https://fullstack.cash/cashstrap) page.
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).
- Mainnet REST API server: https://api.fullstack.cash/v3/ ### Configure bch-js
- Testnet REST API server: https://tapi.fullstack.cash/v3/ The live servers can be used by [bch-js](https://github.com/christroutner/bch-js) by settings the `restURL` config property to one of these servers:
- BCHN Mainnet REST API server: https://bchn.fullstack.cash/v3/
- ABC Mainnet REST API server: https://abc.fullstack.cash/v3/
- Testnet3 REST API server: https://testnet3.fullstack.cash/v3/
- Check server status: https://metrics.fullstack.cash - Check server status: https://metrics.fullstack.cash
## Installation ## Installation
There are two installation paths, depending if you want a *development* or There are two installation paths, depending if you want a *development* or
*production* environment. You'll also need to set up the underlying infrastructure *production* environment. You'll also need to set up the underlying infrastructure
described [this page](https://troutsblog.com/research/bitcoin-cash/how-to-bch-full-stack-developer). described on [this page](https://troutsblog.com/research/bitcoin-cash/how-to-bch-full-stack-developer).
This code targets the Ubuntu 18.04 LTS Linux OS. This code targets the Ubuntu 18.04 LTS Linux OS.
+6
View File
@@ -24,4 +24,10 @@ export REDIS_HOST=172.17.0.1
# JWT Token Secret # JWT Token Secret
export TOKENSECRET=somelongsecretvalue export TOKENSECRET=somelongsecretvalue
# So that bch-api can call bch-js locally.
export LOCAL_RESTURL=http://127.0.0.1:3000/v3/
# slp-api alternative SLP validator.
export SLP_API_URL=http://10.0.0.5:5001/
npm start npm start
+6
View File
@@ -21,4 +21,10 @@ export REDIS_HOST=172.17.0.1
# JWT Token Secret # JWT Token Secret
export TOKENSECRET=somelongsecretvalue export TOKENSECRET=somelongsecretvalue
# So that bch-api can call bch-js locally.
export LOCAL_RESTURL=http://127.0.0.1:3000/v3/
# slp-api alternative SLP validator.
export SLP_API_URL=http://10.0.0.5:5001/
npm start npm start
Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

-70
View File
@@ -96,18 +96,6 @@ class Blockbook {
} }
} }
/**
* @api {get} /blockbook/balance/{addr} Get balance for a single address.
* @apiName Balance for a single address
* @apiGroup Blockbook
* @apiDescription Returns an object with balance and details about an address.
*
*
* @apiExample Example usage:
* curl -X GET "https://api.fullstack.cash/v3/blockbook/balance/bitcoincash:qrdka2205f4hyukutc2g0s6lykperc8nsu5u2ddpqf" -H "accept: application/json"
*
*/
// GET handler for single balance
async balanceSingle (req, res, next) { async balanceSingle (req, res, next) {
try { try {
const address = req.params.address const address = req.params.address
@@ -165,18 +153,6 @@ class Blockbook {
} }
} }
/**
* @api {post} /blockbook/balance Get balance for an array of addresses.
* @apiName Balance for an array of addresses
* @apiGroup Blockbook
* @apiDescription Return balances and details for an array of addresses.
* Limited to 20 items per request.
*
* @apiExample Example usage:
* curl -X POST "https://api.fullstack.cash/v3/blockbook/balance" -H "accept: application/json" -H "Content-Type: application/json" -d '{"addresses":["bitcoincash:qrdka2205f4hyukutc2g0s6lykperc8nsu5u2ddpqf","bitcoincash:qrdka2205f4hyukutc2g0s6lykperc8nsu5u2ddpqf"]}'
*
*
*/
// POST handler for bulk queries on address details // POST handler for bulk queries on address details
async balanceBulk (req, res, next) { async balanceBulk (req, res, next) {
try { try {
@@ -284,17 +260,6 @@ class Blockbook {
} }
} }
/**
* @api {get} /blockbook/utxos/{addr} Get utxos for a single address.
* @apiName UTXOs for a single address
* @apiGroup Blockbook
* @apiDescription Returns an object with UTXOs associated with an address.
*
*
* @apiExample Example usage:
* curl -X GET "https://api.fullstack.cash/v3/blockbook/utxos/bitcoincash:qr69kyzha07dcecrsvjwsj4s6slnlq4r8c30lxnur3" -H "accept: application/json"
*
*/
// GET handler for single balance // GET handler for single balance
async utxosSingle (req, res, next) { async utxosSingle (req, res, next) {
try { try {
@@ -352,18 +317,6 @@ class Blockbook {
} }
} }
/**
* @api {post} /blockbook/utxos Get UTXOs for an array of addresses.
* @apiName UTXOs for an array of addresses
* @apiGroup Blockbook
* @apiDescription Return UTXOs associate with an array of addresses.
* Limited to 20 items per request.
*
* @apiExample Example usage:
* curl -X POST "https://api.fullstack.cash/v3/blockbook/utxos" -H "accept: application/json" -H "Content-Type: application/json" -d '{"addresses":["bitcoincash:qr69kyzha07dcecrsvjwsj4s6slnlq4r8c30lxnur3","bitcoincash:qzy8wnj0dz927eu6kvh8v2pqsr5w8jh33ys757tdtq"]}'
*
*
*/
// POST handler for bulk queries on address utxos // POST handler for bulk queries on address utxos
async utxosBulk (req, res, next) { async utxosBulk (req, res, next) {
try { try {
@@ -461,17 +414,6 @@ class Blockbook {
} }
} }
/**
* @api {get} /blockbook/tx/{txid} Get details for a single transaction.
* @apiName Details for a single transaction
* @apiGroup Blockbook
* @apiDescription Returns an object with details for a single transaction
*
*
* @apiExample Example usage:
* curl -X GET "https://api.fullstack.cash/v3/blockbook/tx/6181c669614fa18039a19b23eb06806bfece1f7514ab457c3bb82a40fe171a6d" -H "accept: application/json"
*
*/
// GET handler for single transaction details. // GET handler for single transaction details.
async txSingle (req, res, next) { async txSingle (req, res, next) {
try { try {
@@ -514,18 +456,6 @@ class Blockbook {
} }
} }
/**
* @api {post} /blockbook/tx Get details for an array of transactions.
* @apiName Details for an array of transactions
* @apiGroup Blockbook
* @apiDescription Return details for an array of transactions.
* Limited to 20 items per request.
*
* @apiExample Example usage:
* curl -X POST "https://api.fullstack.cash/v3/blockbook/tx" -H "accept: application/json" -H "Content-Type: application/json" -d '{"txids":["6181c669614fa18039a19b23eb06806bfece1f7514ab457c3bb82a40fe171a6d","6181c669614fa18039a19b23eb06806bfece1f7514ab457c3bb82a40fe171a6d"]}'
*
*
*/
// POST handler for bulk queries on tx details // POST handler for bulk queries on tx details
async txBulk (req, res, next) { async txBulk (req, res, next) {
try { try {
+7
View File
@@ -20,4 +20,11 @@ export FULCRUM_PORT=50002
export TOKENSECRET=somelongpassword export TOKENSECRET=somelongpassword
# So that bch-api can call bch-js locally.
export LOCAL_RESTURL=http://127.0.0.1:3000/v3/
# slp-api alternative SLP validator.
export SLP_API_URL=http://10.0.0.5:5001/
npm start npm start