API documentation page

This commit is contained in:
Sander Ferdinand 2018-07-12 18:11:17 +02:00
parent 68d6690c22
commit 94dc07e128
6 changed files with 129 additions and 5 deletions

View file

@ -122,13 +122,14 @@ class Proposal(base):
'date_posted_epoch': self.date_added.strftime('%s'),
'date_posted': self.date_added.strftime('%b %d %Y %H:%M:%S'),
'headline': self.headline,
'content': self.content,
'content_markdown': self.content,
'category': self.category,
'funds_target': self.funds_target,
'funded_pct': self.funds_progress,
'addr_donation': self.addr_donation,
'status': self.status,
'user': self.user.username
'user': self.user.username,
'id': self.id
}
@classmethod

View file

@ -18,6 +18,11 @@ def about():
return make_response(render_template('about.html'))
@app.route('/api')
def api():
return make_response(render_template('api.html'))
@app.route('/proposal/add/disclaimer')
def proposal_add_disclaimer():
return make_response(render_template(('proposal/disclaimer.html')))

View file

@ -208,7 +208,9 @@ a {
}
.card-header {
padding: .75rem 1.25rem;
padding: 0.5rem;
padding-left: 1.0rem;
font-size: 16px;
margin-bottom: 0;
background-color: rgba(0,0,0,.03);
background: linear-gradient(90deg, #d253c829, #ffa93e69);
@ -428,4 +430,40 @@ ul.b {
.media-body #comment{
word-break: break-all;
}
.api_documentation code{
background-color: #f3f3f3;
padding: 4px;
padding-top:2px;
padding-bottom:2px;
}
.api_documentation pre{
margin-top:0;
background-color: #f3f3f3;
padding: 4px;
font-size: 12px;
padding-left:8px;
white-space: pre-wrap; /* Since CSS 2.1 */
white-space: -moz-pre-wrap; /* Mozilla, since 1999 */
white-space: -pre-wrap; /* Opera 4-6 */
white-space: -o-pre-wrap; /* Opera 7 */
word-wrap: break-word; /* Internet Explorer 5.5+ */
}
.api_documentation .api_container hr{
margin-bottom: 14px;
margin-top: 12px;
}
.api_documentation .api_container{
margin-bottom: 60px;
}
.sidebar .card-body{
padding: 1.0rem;
padding-left: 1.25rem;
padding-right: 1.25rem;
}

View file

@ -0,0 +1,77 @@
{% extends "base.html" %}
{% block content %}
<div class="container api_documentation">
<div class="row" style="margin-bottom:4px;">
<div class="col-lg-8">
<h3>API documentation</h3>
<p>
Requests are made using standard HTTP and responses are returned in JSON format.
</p>
<p>
<ul>
<li><a href="#api_convert_wow_usd">/api/1/convert/wow-usd</a></li>
<li><a href="#api_proposals">/api/1/proposals</a></li>
</ul>
</p>
<br>
<div class="api_container" id="api_convert_wow_usd">
<h5><small>GET</small> <code>/api/1/convert/wow-usd</code></h5>
<hr>
<p>
WOW to USD conversion. Data from TradeOgre and CoinMarketCap.
</p>
<b>Example:</b>
<pre>curl -vvX GET 'https://funding.wownero.com/api/1/convert/wow-usd?wow=1000'</pre>
<b>Response:</b>
<pre>{"usd": 6.7}</pre>
</div>
<div class="api_container" id="api_proposals">
<h5><small>GET</small> <code>/api/1/proposals</code></h5>
<hr>
<p>
Proposal listing.
</p>
<b>Parameters:</b>
<ul>
<li><code>status</code>: the proposal status, from 0 to 5. Default is 1.</li>
<li><code>limit</code>: limit results. Default is 20.</li>
<li><code>offset</code>: offset results. Default is 0.</li>
</ul>
<b>Example:</b>
<pre>curl -vvX GET 'https://funding.wownero.com/api/1/proposals?offset=1&limit=1&status=0'</pre>
<b>Response:</b>
<pre>{
"data": [
{
"id": 15,
"user": "dsc",
"headline": "[Bounty] Memes",
"content": "### markdown Content",
"category": "marketing",
"addr_donation": "WW3LcKRi3vJGSn11256Q819gExLtfsR3DZeGneu7K55QeeS4YcKMaDAHZ16hRM2gmJT7pVRiTGesjCsJUNAJPTn42rnh7wZEa",
"date_posted": "Jul 09 2018 21:59:26",
"date_posted_epoch": "1531173566",
"funded_pct": 33.3333333333333,
"funds_target": 15000.0,
"status": 2
}
]
}</pre>
</div>
</div>
{% include 'sidebar.html' %}
</div>
</div>
<!-- /.container -->
{% endblock %}

View file

@ -22,6 +22,9 @@
<li class="nav-item">
<a class="nav-link" href="/about">About</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/api">API</a>
</li>
{% if logged_in %}
<li class="nav-item">
<a class="nav-link" href="/logout">Logout</a>

View file

@ -3,7 +3,7 @@
{% endif %}
<!-- Sidebar Widgets Column -->
<div class="col-md-4">
<div class="col-md-4 sidebar">
<!-- Search Widget -->
<div class="card my-4" style="margin-top: 0 !important;">
@ -22,7 +22,7 @@
<!-- Categories Widget -->
<div class="card my-4">
<h5 style="transform: rotate(0.6deg);" class="card-header">Categories</h5>
<h5 class="card-header">Categories</h5>
<div class="card-body">
<div class="row">
<div class="col-lg-6">