Skip to content

Commit 80a30e9

Browse files
authored
New endpoints for dcrweb statistics. (#184)
"price" endpoint serves USD prices for bitcoin and decred as reported by dcrdata. "webinfo" collects data from dcrdata and caches it, serves to JavaScript running on the homepage of decred.org. Both endpoints have a "last updated" field so clients can make their own decisions on handling stale data.
1 parent 871ff80 commit 80a30e9

File tree

6 files changed

+1119
-14
lines changed

6 files changed

+1119
-14
lines changed

LICENSE

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
ISC License
22

3-
Copyright (c) 2017-2023 The Decred developers
3+
Copyright (c) 2017-2024 The Decred developers
44

55
Permission to use, copy, modify, and distribute this software for any
66
purpose with or without fee is hereby granted, provided that the above

docs/api.md

+34
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,37 @@ Example: <https://api.decred.org/?c=vsp>
3232
},
3333
}
3434
```
35+
36+
## Web Info
37+
38+
Collects data from dcrdata and caches it, serves to JavaScript running on the
39+
homepage of <https://decred.org>.
40+
41+
Example: <https://api.decred.org/?c=webinfo>
42+
43+
```json
44+
{
45+
"circulatingsupply": 15804577.17784509,
46+
"ultimatesupply": 20999999.9839432,
47+
"stakedsupply": 9855286.05084056,
48+
"blockreward": 8.061013,
49+
"treasury": 822237.44313611,
50+
"ticketprice": 268.19271648,
51+
"height": 837324,
52+
"lastupdated": 1706092430
53+
}
54+
```
55+
56+
## Price Info
57+
58+
Returns the current USD price of Bitcoin and Decred as reported by dcrdata.
59+
60+
Example: <https://api.decred.org/?c=price>
61+
62+
```json
63+
{
64+
"bitcoin_usd": 40119.53495,
65+
"decred_usd": 14.1665886541639,
66+
"lastupdated": 1706092430
67+
}
68+
```

go.mod

+56-2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,60 @@ module github.com/decred/dcrwebapi
22

33
go 1.18
44

5-
require github.com/gorilla/handlers v1.5.1
5+
require (
6+
github.com/decred/dcrd/dcrutil/v4 v4.0.0
7+
github.com/decred/dcrdata/exchanges/v3 v3.1.0
8+
github.com/decred/dcrdata/v6 v6.0.0
9+
github.com/gorilla/handlers v1.5.1
10+
)
611

7-
require github.com/felixge/httpsnoop v1.0.3 // indirect
12+
require (
13+
decred.org/dcrdex v0.4.3 // indirect
14+
decred.org/dcrwallet v1.7.0 // indirect
15+
github.com/agl/ed25519 v0.0.0-20170116200512-5312a6153412 // indirect
16+
github.com/carterjones/go-cloudflare-scraper v0.1.2 // indirect
17+
github.com/carterjones/signalr v0.3.5 // indirect
18+
github.com/dchest/siphash v1.2.2 // indirect
19+
github.com/decred/base58 v1.0.3 // indirect
20+
github.com/decred/dcrd/blockchain/stake/v3 v3.0.0 // indirect
21+
github.com/decred/dcrd/blockchain/standalone/v2 v2.1.0 // indirect
22+
github.com/decred/dcrd/certgen v1.1.1 // indirect
23+
github.com/decred/dcrd/chaincfg/chainhash v1.0.3 // indirect
24+
github.com/decred/dcrd/chaincfg/v3 v3.1.1 // indirect
25+
github.com/decred/dcrd/crypto/blake256 v1.0.1-0.20200921185235-6d75c7ec1199 // indirect
26+
github.com/decred/dcrd/crypto/ripemd160 v1.0.1 // indirect
27+
github.com/decred/dcrd/database/v2 v2.0.2 // indirect
28+
github.com/decred/dcrd/dcrec v1.0.1-0.20200921185235-6d75c7ec1199 // indirect
29+
github.com/decred/dcrd/dcrec/edwards/v2 v2.0.2 // indirect
30+
github.com/decred/dcrd/dcrec/secp256k1/v3 v3.0.0 // indirect
31+
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 // indirect
32+
github.com/decred/dcrd/dcrjson/v3 v3.1.0 // indirect
33+
github.com/decred/dcrd/dcrutil/v3 v3.0.0 // indirect
34+
github.com/decred/dcrd/hdkeychain/v3 v3.1.0 // indirect
35+
github.com/decred/dcrd/rpc/jsonrpc/types/v2 v2.3.0 // indirect
36+
github.com/decred/dcrd/txscript/v3 v3.0.0 // indirect
37+
github.com/decred/dcrd/txscript/v4 v4.0.0 // indirect
38+
github.com/decred/dcrd/wire v1.5.0 // indirect
39+
github.com/decred/go-socks v1.1.0 // indirect
40+
github.com/decred/slog v1.2.0 // indirect
41+
github.com/felixge/httpsnoop v1.0.3 // indirect
42+
github.com/go-chi/chi/v5 v5.0.4 // indirect
43+
github.com/golang/protobuf v1.4.3 // indirect
44+
github.com/golang/snappy v0.0.4 // indirect
45+
github.com/gorilla/websocket v1.4.2 // indirect
46+
github.com/lib/pq v1.10.3 // indirect
47+
github.com/pkg/errors v0.9.1 // indirect
48+
github.com/robertkrimen/otto v0.0.0-20180617131154-15f95af6e78d // indirect
49+
github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 // indirect
50+
go.etcd.io/bbolt v1.3.7-0.20220130032806-d5db64bdbfde // indirect
51+
golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97 // indirect
52+
golang.org/x/net v0.0.0-20210903162142-ad29c8ab022f // indirect
53+
golang.org/x/sys v0.0.0-20210902050250-f475640dd07b // indirect
54+
golang.org/x/text v0.3.6 // indirect
55+
golang.org/x/time v0.0.0-20210220033141-f8bda1e9f3ba // indirect
56+
google.golang.org/genproto v0.0.0-20201022181438-0ff5f38871d5 // indirect
57+
google.golang.org/grpc v1.36.1 // indirect
58+
google.golang.org/protobuf v1.25.0 // indirect
59+
gopkg.in/ini.v1 v1.55.0 // indirect
60+
gopkg.in/sourcemap.v1 v1.0.5 // indirect
61+
)

0 commit comments

Comments
 (0)