Total supply API
This commit is contained in:
parent
921cdb324b
commit
c288d58ca2
|
@ -1,3 +1,4 @@
|
||||||
|
import requests
|
||||||
from flask import jsonify, send_from_directory, Response, request
|
from flask import jsonify, send_from_directory, Response, request
|
||||||
from flask_yoloapi import endpoint, parameter
|
from flask_yoloapi import endpoint, parameter
|
||||||
|
|
||||||
|
@ -85,3 +86,26 @@ def api_wowlight_version_check(version):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
return versions[version]
|
return versions[version]
|
||||||
|
|
||||||
|
|
||||||
|
@app.route('/api/1/wow/supply')
|
||||||
|
@endpoint.api()
|
||||||
|
def api_wow_supply():
|
||||||
|
from funding.factory import cache
|
||||||
|
cache_key = 'wow_supply'
|
||||||
|
hit = cache.get(cache_key)
|
||||||
|
if hit:
|
||||||
|
return float(hit.get('data', -1))
|
||||||
|
|
||||||
|
try:
|
||||||
|
resp = requests.get('http://explorer.wowne.ro/api/emission', headers={'User-Agent': 'WFS'})
|
||||||
|
resp.raise_for_status()
|
||||||
|
blob = resp.json()
|
||||||
|
assert 'data' in blob
|
||||||
|
assert 'coinbase' in blob['data']
|
||||||
|
except:
|
||||||
|
return Exception('error fetching circulating supply')
|
||||||
|
|
||||||
|
supply = blob['data'].get('coinbase') / 100000000000
|
||||||
|
cache.set(cache_key, {'data': supply}, 120)
|
||||||
|
return supply
|
||||||
|
|
|
@ -81,6 +81,22 @@
|
||||||
link
|
link
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="api_container" id="api_wow_supply">
|
||||||
|
<h5><small>GET</small> <code>/api/1/wow/supply</code></h5>
|
||||||
|
<hr>
|
||||||
|
<p>
|
||||||
|
The current total supply of WOW.
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<b>Example:</b>
|
||||||
|
<pre>curl -vvX GET 'https://funding.wownero.com/api/1/wow/supply'</pre>
|
||||||
|
|
||||||
|
<b>Response:</b>
|
||||||
|
<pre>{
|
||||||
|
"data": 10456897.573388882
|
||||||
|
}</pre>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{% include 'sidebar.html' %}
|
{% include 'sidebar.html' %}
|
||||||
|
|
Loading…
Reference in New Issue