xitong-0629 / bitcoin-api

:full_moon: Bitcoin RPC API with basic console commands (Node/Express)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Bitcoin API using Bitcoin Core, Node.js, and Express

Express API for querying data from your Bitcoin node to build web applications.

Sends HTTP requests to Bitcoin Core node using various RPC commands.

A full tutorial for this API can be found here.

Setup

To use the API first make sure to install Node.js (here) and Bitcoin Core here (here).

Clone this repo and add a .env file at the root level of your project. Replace the bitcoinuser and bitcoinpassword values with those in your Bitcoin configuration file (in Bitcoin Core under Settings > Options > Open Configuration File ).

.env:


RPC_USER=bitcoinuser
RPC_PASSWORD=bitcoinpassword

If they haven't yet been set, add the following entries to your bitcoin.conf and change both files (restarting bitcoin core) :

bitcoin.conf:

rpcuser=bitcoinuser
rpcpassword=bitcoinpassword

Next run

npm install

then

npm run server

to start the server.

View a test endpoint in the browser at 'localhost:4444/api/getblockchaininfo'

Methods used

  • getblockcount
  • getbestblockhash
  • getconnectioncount
  • getdifficulty
  • getblockchaininfo
  • getmininginfo
  • getpeerinfo
  • getrawmempool
  • getblockhash
  • getblock
  • getrawtransaction
  • decoderawtransaction

About

:full_moon: Bitcoin RPC API with basic console commands (Node/Express)


Languages

Language:JavaScript 100.0%