It is a microservice that collect data from several crypto data providers using its API.
This microservice uses:
- gin-gonic/gin package to start and serve HTTP server
- nhooyr.io/websocket package to manage websocket connection
- go-sql-driver/mysql package to work with mysql database
- lib/pg package to work with postgresql database
List of the implemented endpoints:
♦ | /healthz | [GET] | check node status |
♦ | /v1/collect/add | [GET] | add new worker to collect data about selected pair in database |
♦ | /v1/collect/remove | [GET] | stop and remove worker and collecting data for selected pair |
♦ | /v1/collect/status | [GET] | show info about running workers |
♦ | /v1/collect/update | [GET] | update pulling interval for selected pair |
♦ | /v1/symbols/add | [GET] | add new currency symbol to the db |
♦ | /v1/symbols/update | [GET] | update currency symbol in the db |
♦ | /v1/symbols/remove | [GET] | remove currency symbol from the db |
♦ | /v1/price | [POST, GET] | get actual (or cached if dataprovider is unavailable) info for selected pair |
♦ | /v1/ws | [GET] | websocket connection url, when you connected, try to send request like {"fsym":"BTC","tsym":"USD"} |
♦ | /v1/ws/subscribe | [POST, GET] | subscribe to collect data for the selected pair |
♦ | /v1/ws/unsubscribe | [POST, GET] | unsubscribe to stop collect data for the selected pair |
♦ | /v1/symbols | [POST, PUT, DELETE] | add, update, delete currency symbol |
♦ | /v1/collect | [POST, PUT, DELETE] | add, update, delete worker to collect data |
Example getting a GET request for getting actual info about selected pair:
$ curl "http://localhost:8080/v1/price?fsym=ETH&tsym=USDT"
Example of sending a POST request to add a new worker:
$ curl -X POST -H "Content-Type: application/json" -d '{ "fsym":"BTC", "tsym": "USDT", "interval": 60}' "http://localhost:8080/v1/collect"
Example of sending a GET request to remove worker:
$ curl "http://localhost:8080/v1/collect/remove?fsym=BTC&tsym=USDT&interval=60"
Example of sending a GET request to subscribe wss channel:
$ curl "http://localhost:8080/v1/ws/subscribe?fsym=BTC&tsym=USDT"