This API is hosted publicly at https://b.map.sv
It is a Bitcoin transaction indexer and API for building 'BMAP' Bitcoin apps. It uses junglebus to crawl for transactions and transforms them with bmapjs. It runs two processes:
A crawler and indexer that saves transaction data into a MongoDB database.
A REST API supporting BitQuery syntax.
{
"find": {
"MAP.app": "tonicpow"
}
}
It then provides support for a number of known OP_RETURN protocols making queries nicer:
{
"find": {
"BITPIC.paymail": "satchmo@moneybutton.com"
}
}
For a full list of what protocols are supported see bmapjs.com
It also makes working with the results from your frontend much friendlier
let res = await fetch('https://b.map.sv/q/...')
let j = res.json()
console.log('Got tx', j[0].tx.h, 'app:', j[0].MAP.app)
Using the same query syntax you can listen for changes:
var sock = {
v: 3,
q: {
find: {
'MAP.type': { $in: ['post', 'message'] },
},
sort: {
'blk.t': -1,
},
},
}
var sock_b64 = btoa(JSON.stringify(sock))
var socket_url = 'https://b.map.sv/s/' + sock_b64
// socket
bmapSocket = new EventSource(socket_url)
bmapSocket.onmessage = function (e) {
var res = JSON.parse(e.data)
if (res.type === 'push') {
// do something with res.data
}
}
Docker & Docker-Compose
Install dependencies
yarn
Start the app (make sure your env vars are set first)
yarn start
Build the image
docker build -t bmap-api.
Start the app `bash docker-compose up
### Configuration
`config.js` hold config values.
Set the `from` value to the block to begin indexing.
#### Install MongoDB
To run locally you will need mongodb installed.
See their [installation guide](https://docs.mongodb.com/manual/installation)
# Config
Set the following environmental variables:
- `MONGO_URL` A connection string to your mongo database. ex: mongodb://127.0.0.1:27017/bmap when running locally, or mongodb://mongo:27017/bmap from within a container.
# Run
```bash
node index
BITPIC.paymail = satchmo@moneybutton.com
BITKEY.paymail = satchmo@moneybutton.com
With BitQuery you can search in all sorts of ways.
- Set a timestamp in the expected format.
let timestamp = Math.floor(new Date().getTime() / 1000 - 86400)
- Search for records since that timestamp:
{
"v": 3,
"q": {
"blk.t": { "$gt": <timestamp> }
}
}
This API returns data in BMAP format which is a derivative of BOB: BMAPjs