https://github.com/trustwallet/watchmarket
Watchmarket is an aggregation and caching service for blockchain market information
https://github.com/trustwallet/watchmarket
exchange-rates marketdata prices trustwallet watchmarket
Last synced: 7 months ago
JSON representation
Watchmarket is an aggregation and caching service for blockchain market information
- Host: GitHub
- URL: https://github.com/trustwallet/watchmarket
- Owner: trustwallet
- Archived: true
- Created: 2020-02-15T18:43:39.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2022-03-25T20:08:35.000Z (over 3 years ago)
- Last Synced: 2024-11-05T21:45:17.426Z (12 months ago)
- Topics: exchange-rates, marketdata, prices, trustwallet, watchmarket
- Language: Go
- Homepage:
- Size: 3.28 MB
- Stars: 91
- Watchers: 10
- Forks: 61
- Open Issues: 13
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Watchmarket

[](https://codecov.io/gh/trustwallet/watchmarket)
[](https://goreportcard.com/report/github.com/TrustWallet/watchmarket)
[](https://dependabot.com)
> Watchmarket is a Blockchain explorer API aggregator and caching layer. It's your one-stop-shop to get information for (almost) any coin in a common format
Watchmarket comes with three apps:
* API: RESTful API to retrieve coin info, charts, and tickers
* Worker: fetch and parse data from market APIs and store it at DB
* Swagger: API explorer
#### Supported Market APIs
## Getting started
### Setup
```
make install
make start-docker-services
make seed-db
```
### Start the app:
```
make start
# Alternative
cd cmd/api && go run main.go
cd cmd/worker && go run main.go
```
### ID system
We are using a asset id system. For each coin we have a unique asset_id of type string.
#### How to build asset id?
Asset ID consists of 2 parts and it possible to add new parts later.
Example: `c714_tTWT-8C2`
Where:
- 714 is id of `coin` (c for coin). We use standarts of [BIP-44 slips for coins](https://github.com/satoshilabs/slips/blob/master/slip-0044.md)
- TWT-8C2 is token id - unique identifier of token for blockchain. It could be an address for ETH for example.
### Using API:
A. Get coin details about Ehtereum (coin 60 according to SLIPs)
- ```curl -v "http://localhost:8421/v1/market/info?coin=60" | jq .```
- ```curl -v "http://localhost:8421/v2/market/info/c60" | jq .```
B. Get current ticker price of Ethereum in USD:
- ```curl -v -X POST 'http://localhost:8421/v1/market/ticker' -H 'Content-Type: application/json' -d '{"currency":"USD","assets":[{"type":"coin","coin":60}]}'```
- ```curl -v -X POST 'http://localhost:8421/v2/market/tickers' -H 'Content-Type: application/json' -d '{"currency":"USD","assets":["c60","c0","c714","c714_tTWT-8C2","c459","c61"]}'```
- ```curl -v "http://localhost:8421/v2/market/ticker/c60" | jq .```
- ```curl -v "http://localhost:8421/v2/market/tickers?assets=c60,c714,c714_TWT-8C2" | jq .```
C. Get price interval of Ethereum to build chart starting from 1574483028 (UNIX time)
- ```curl -v "http://localhost:8421/v1/market/charts?coin=60&time_start=1574483028" | jq .```
- ```curl -v "http://localhost:8421/v2/market/charts/c60?time_start=1574483028" | jq .```
Use `make stop` to stop the services
Run `make` to see a list of all available build directives.
## Local development with Kubernetes
### Setup Docs
1. Install [Tilt](https://docs.tilt.dev/install.html)
2. Install [Docker+Kubernetes](https://docs.docker.com/docker-for-mac/#kubernetes)
3. Install [Helm3](https://helm.sh/docs/intro/install/)
### Setup for MacOS
1. [Enable Kubernetes in Docker Desktop preferences](https://docs.docker.com/docker-for-mac/#kubernetes)
2. `kubectl config use-context docker-desktop`
3. `curl -fsSL https://raw.githubusercontent.com/tilt-dev/tilt/master/scripts/install.sh | bash`
4. `curl https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3 | bash`
### Development with Tilt
#### Start
1. Run `tilt up` to start the project
2. Press `space` to open browser
#### Cleanup
1. Press `Ctrl+C` to stop tilt local server
2. Run `tilt down` to stop and clear allocated resources in local kubernetes