adding api overview page

This commit is contained in:
aglkm
2025-03-03 18:27:32 +03:00
parent 37f4b45248
commit 84a56aebdf
3 changed files with 76 additions and 2 deletions

View File

@@ -358,6 +358,16 @@ fn emission(dashboard: &State<Arc<Mutex<Dashboard>>>) -> Template {
} }
// Rendering API Overview page.
#[get("/api_overview")]
fn api_overview() -> Template {
Template::render("api_overview", context! {
route: "api_overview",
public_api: CONFIG.public_api.clone(),
})
}
// Owner API. // Owner API.
// Whitelisted methods: get_connected_peers, get_peers, get_status. // Whitelisted methods: get_connected_peers, get_peers, get_status.
#[post("/v2/owner", data="<data>")] #[post("/v2/owner", data="<data>")]
@@ -938,7 +948,7 @@ async fn main() {
soft_supply, production_cost, reward_ratio, breakeven_cost, soft_supply, production_cost, reward_ratio, breakeven_cost,
last_block_age, block_list_by_height, block_list_index, search, kernel, last_block_age, block_list_by_height, block_list_index, search, kernel,
output, api_owner, api_foreign, stats, unspent_outputs, kernels, output, api_owner, api_foreign, stats, unspent_outputs, kernels,
emission]) emission, api_overview])
.mount("/static", FileServer::from("static")) .mount("/static", FileServer::from("static"))
.attach(Template::custom(|engines| {engines.tera.register_filter("separate_with_commas", separate_with_commas)})) .attach(Template::custom(|engines| {engines.tera.register_filter("separate_with_commas", separate_with_commas)}))
.launch() .launch()

View File

@@ -0,0 +1,61 @@
{% extends "base" %}
{% block content %}
<code>
<div class="card border-start-0 border-end-0 rounded-0">
<div class="card-body">
<h4><i class="bi bi-robot me-3"></i>API Overview</h4>
{% if public_api != "enabled" %}
<div class="alert alert-danger" role="alert">
API is disabled. Set 'public_api = enabled' in Explorer.toml to enable.
</div>
{% endif %}
<div>The API provides access to Grin node's Foreign and Owner endpoints.</div>
<br>
<h5>Foreign API</h5>
<div>get_block</div>
<div>get_blocks</div>
<div>get_kernel</div>
<div>get_outputs</div>
<div>get_pmmr_indices</div>
<div>get_pool_size</div>
<div>get_stempool_size</div>
<div>get_tip</div>
<div>get_unconfirmed_transactions</div>
<div>get_unspent_outputs</div>
<div>get_version</div>
<div>push_transaction</div>
<br>
<div class="card">
<div class="card-body">
<b>Example:</b><br> curl -X POST --data '{"jsonrpc":"2.0","method":"get_tip","params":[],"id":1}' https://grincoin.org/v2/foreign
</div>
</div>
<br>
<h5>Owner API</h5>
<div>get_connected_peers</div>
<div>get_peers</div>
<div>get_status</div>
<br>
<div class="card">
<div class="card-body">
<b>Example:</b><br> curl -X POST --data '{"jsonrpc":"2.0","method":"get_status","params":[],"id":1}' https://grincoin.org/v2/owner
</div>
</div>
<br>
<h5>GET API</h5>
<div>There are also several GET APIs provided by the explorer.</div>
<br>
<a href="https://grincoin.org/rpc/block/latest">https://grincoin.org/rpc/block/latest</a><br>
<a href="https://grincoin.org/rpc/market/supply">https://grincoin.org/rpc/market/supply</a><br>
<a href="https://grincoin.org/rpc/network/hashrate">https://grincoin.org/rpc/network/hashrate</a><br>
<a href="https://grincoin.org/rpc/network/difficulty">https://grincoin.org/rpc/network/difficulty</a><br><br>
</div>
</div>
</code>
{% endblock %}

View File

@@ -296,9 +296,12 @@
<a class="text-decoration-none me-2" href="https://github.com/aglkm/grin-explorer"> <a class="text-decoration-none me-2" href="https://github.com/aglkm/grin-explorer">
<span style="color:grey"><i class="bi bi-github me-1"></i>v.0.1.8</span> <span style="color:grey"><i class="bi bi-github me-1"></i>v.0.1.8</span>
</a> </a>
<a class="text-decoration-none" href="/search"> <a class="text-decoration-none me-2" href="/search">
<span style="color:grey"><i class="bi bi-search me-1"></i>Search</span> <span style="color:grey"><i class="bi bi-search me-1"></i>Search</span>
</a> </a>
<a class="text-decoration-none" href="/api_overview">
<span style="color:grey"><i class="bi bi-robot me-1"></i>API</span>
</a>
</div> </div>
</div> </div>
</div> </div>