streamdp / ccd

It is a microservice that collect data from a several crypto data providers using its API.

Home Page:https://ccd.run.place

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ccd

Go Report Card Website ccdtest.gq GitHub release GitHub license

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/pq package to work with postgresql database

Build app

$ go build -o ccd .

Run app

You should previously export some environment variables:

export CCDC_DATAPROVIDER=cryptocompare
export CCDC_DATASOURCE=postgres://username:password@127.0.0.1:5432/dbname?sslmode=disable
export CCDC_APIKEY=put you api key here

if you want use huobi as data provider export this:

export CCDC_DATAPROVIDER=huobi

If you use mysql db, you should export something like this:

export CCDC_DATASOURCE=mysql://username:password@tcp(localhost:3306)/dbname

And run application:

$ ./ccd -debug

The default port is 8080, you can test the application in a browser or with curl:

$ curl 127.0.0.1:8080/v1/service/ping

You can choose a different port and run more than one copy of ccd on your local host. For example:

$ ./ccd -port 8081

You also can specify some setting before run application:

$ ./ccd -h
ccd is a microservice that collect data from several crypto data providers cryprocompare using its API.

Usage of ccd:
  -common string
        specify list possible common currencies (default "USD,EUR,GBP,JPY,RUR")
  -crypto string
        specify list possible crypto currencies (default "BTC,XRP,ETH,BCH,EOS,LTC,XMR,DASH")
  -dataprovider string
        use selected data provider ("cryptocompare", "huobi") (default "cryptocompare")
  -debug
        run the program in debug mode
  -h    display help
  -port string
        set specify port (default ":8080")
  -timeout int
        how long to wait for a response from the api server before sending data from the cache (default 1000)

List of the implemented endpoints:

  • /healthz [GET] check node status
  • /v1/collect/add [POST, GET] add new worker to collect data for the selected pair
  • /v1/collect/remove [POST, GET] stop and remove worker and collecting data for the selected pair
  • /v1/collect/status [GET] show info about running workers
  • /v1/collect/update [POST, GET] update pulling interval for the selected pair
  • /v1/price [POST, GET] get actual (or cached if dataprovider is unavailable) info for the 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

Example getting a GET request for getting actual info about selected pair:

$ curl "http://localhost:8080/v1/price?fsym=ETH&tsym=JPY"

Example of sending a POST request to add a new worker:

$ curl -X POST -H "Content-Type: application/json" -d '{ "fsym": "BTC", "tsym": "USD", "interval": 60}' "http://localhost:8080/v1/collect/add"

Example of sending a GET request to remove worker:

$ curl "http://localhost:8080/v1/collect/remove?fsym=BTC&tsym=USD&interval=60"

Example of sending a GET request to subscribe wss channel:

$ curl "http://localhost:8080/v1/ws/subscribe?fsym=BTC&tsym=USD"

Working example URL: https://ccdtest.gq/healthz

Web UI: https://ccdtest.gq

About

It is a microservice that collect data from a several crypto data providers using its API.

https://ccd.run.place

License:MIT License


Languages

Language:Go 67.3%Language:CSS 29.4%Language:JavaScript 2.6%Language:Dockerfile 0.7%