Creating an API to List the Internal Marketplace

in HiveDevs3 years ago (edited)

We've got some really cool stuff going on with Hive. The new hardfork as well as the HBD stabilizer have really made our stable coin ~stable. The only thing that's missing is external tracking of our internal market.

To this end I followed CoinGecko's API Guide for spot exchanges and built this:
hive_market_api

Installation:
$ git clone https://github.com/disregardfiat/hive_market_api.git
$ cd hive_market_api
$ npm i
$ node index.js || $ npm start

It's meant to be run from a witness server WITH the market_history plugin. But you can just as easily point to one. I won't go into any details of routing this through a reverse proxy, but I will say the CACHEMILSEC is set to 60 secs because that's the query interval for coingecko. You can make a .env file to store your config variables.

exports.PORT = ENV.PORT || 3000;
exports.clientURL = ENV.CLIENTURL || "https://rpc.ecency.com/"  // 'http://127.0.0.1:8091/' //Run from same server.
exports.CACHEMILSEC = ENV.CACHEMILSEC || 60000 //1 minute

Here's the short list of API

/api/orderbook/HIVE_HBD
/api/historical_trades/HIVE_HBD
/api/pairs
/api/tickers
/api/coin_detail

Sort:  

Your content has been voted as a part of Encouragement program. Keep up the good work!

Use Ecency daily to boost your growth on platform!

Support Ecency
Vote for Proposal
Delegate HP and earn more

Congratulations @disregardfiat! You have completed the following achievement on the Hive blockchain and have been rewarded with new badge(s) :

Your post got the highest payout of the day

You can view your badges on your board and compare yourself to others in the Ranking
If you no longer want to receive notifications, reply to this comment with the word STOP

To support your work, I also upvoted your post!

Witness server shouldn't be running anything more than required for a block production. A public seed node, which witnesses are expected to run might be a good place for it, as the extra overhead is negligible for the state file and such seed nodes could serve also as basic API nodes (pretty much everything except for account history, that's the most resource hungry could be handled by such simple node)

I have no idea what this all means! But it sounds amazing!

Screenshot from 2021-07-18 18-51-07.png
This kind of quote are aggregated from exchanges like Bittrex... but a lot of volume happens on our internal market that isn't part of these quotes. This should help get better quotes for us.

idk why I wasn't following you before.. I am now.

Good job. You might want to add helmet

import helmet from 'helmet'
api.use(helmet())

This is the kind of feedback we need!

Looks promising, following you up for the next updates!

untitled.gif

Very good job!

good job!

Nice work m8!

Many thanks for this 😃
It's nice to see some big stake holders have voted for you. Sad your proposal for DHF didn't get this good reactions so fast.
!PIZZA

Connect

Trade


@disregardfiat! I sent you a slice of $PIZZA on behalf of @d-zero.

Learn more about $PIZZA Token at hive.pizza (5/10)