mirror of
https://git.wownero.com/wownero/wownero-funding-system.git
synced 2024-08-15 00:53:45 +00:00
Total supply API
This commit is contained in:
parent
921cdb324b
commit
c288d58ca2
2 changed files with 40 additions and 0 deletions
|
@ -1,3 +1,4 @@
|
|||
import requests
|
||||
from flask import jsonify, send_from_directory, Response, request
|
||||
from flask_yoloapi import endpoint, parameter
|
||||
|
||||
|
@ -85,3 +86,26 @@ def api_wowlight_version_check(version):
|
|||
return False
|
||||
|
||||
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
|
||||
</a>
|
||||
</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>
|
||||
|
||||
{% include 'sidebar.html' %}
|
||||
|
|
Loading…
Reference in a new issue