artblocks-stats
API to gather specific arblocks collection holders and their distribution by scores based on Artacle API.
Starting project
Just run:
$ make compose-build-up
And apply migrations with docker usage
of migrate:
$ docker run -v migrations:/migrations --network host migrate/migrate -path=/migrations/ -database 'postgres://user:pass@localhost:5432/holders?sslmode=disable' up
Swagger API specification can be found at http://localhost:8080/api-docs/ (with default service port configuration).
Tests
To start unit tests run:
$ make test
Usage example
Getting collection (№399) holders distribution:
$ curl http://localhost:8080/v1/collections/399/stats | jq .
{
"collection": {
"id": 399,
"holders_count": 220,
"holders_distribution": {
"by_commitment_score": {
"[3 - 3.5)": 43,
"[3.5 - 4)": 58,
"[4 - 4.5)": 59,
"[4.5 - 5]": 60
},
"by_portfolio_score": {
"[3 - 3.5)": 75,
"[3.5 - 4)": 78,
"[4 - 4.5)": 50,
"[4.5 - 5]": 17
},
"by_trading_score": {
"[3 - 3.5)": 42,
"[3.5 - 4)": 27,
"[4 - 4.5)": 106,
"[4.5 - 5]": 45
}
}
}
}
Getting collection (№399) holders with scores:
$ curl http://localhost:8080/v1/collections/399/holders | jq .
{
"holders": [
{
"address": "0xb9eb79e3e735ee636255dd8d65872a1287744e33",
"tokens_amount": 20,
"commitment_score": 3.798311122595867,
"portfolio_score": 4.03269501537506,
"trading_score": 4.494485581716837
},
{
"address": "0xcbbea7ec33d60db283ab79bdac9ffbfa46a83134",
"tokens_amount": 11,
"commitment_score": 4.331444471045636,
"portfolio_score": 3.6309881414241354,
"trading_score": 4.247808248625762
},
...
{
"address": "0xf9b7d79932b16c6bf8d08dbce15cd5e6942dd18f",
"tokens_amount": 1,
"commitment_score": 3,
"portfolio_score": 3.364766609678407,
"trading_score": 3
}
]
}
Technical stack
- Backend building blocks
- Infrastructure
- PostgreSQL
- docker and docker-compose