diff --git a/src/main.rs b/src/main.rs index e3823ea..0f3a1a7 100644 --- a/src/main.rs +++ b/src/main.rs @@ -358,6 +358,16 @@ fn emission(dashboard: &State>>) -> 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. // Whitelisted methods: get_connected_peers, get_peers, get_status. #[post("/v2/owner", data="")] @@ -938,7 +948,7 @@ async fn main() { soft_supply, production_cost, reward_ratio, breakeven_cost, last_block_age, block_list_by_height, block_list_index, search, kernel, output, api_owner, api_foreign, stats, unspent_outputs, kernels, - emission]) + emission, api_overview]) .mount("/static", FileServer::from("static")) .attach(Template::custom(|engines| {engines.tera.register_filter("separate_with_commas", separate_with_commas)})) .launch() diff --git a/templates/api_overview.html.tera b/templates/api_overview.html.tera new file mode 100644 index 0000000..eda6709 --- /dev/null +++ b/templates/api_overview.html.tera @@ -0,0 +1,61 @@ +{% extends "base" %} + +{% block content %} + + + +
+
+

API Overview

+ {% if public_api != "enabled" %} + + {% endif %} +
The API provides access to Grin node's Foreign and Owner endpoints.
+
+
Foreign API
+
get_block
+
get_blocks
+
get_kernel
+
get_outputs
+
get_pmmr_indices
+
get_pool_size
+
get_stempool_size
+
get_tip
+
get_unconfirmed_transactions
+
get_unspent_outputs
+
get_version
+
push_transaction
+
+
+
+ Example:
curl -X POST --data '{"jsonrpc":"2.0","method":"get_tip","params":[],"id":1}' https://grincoin.org/v2/foreign +
+
+
+
Owner API
+
get_connected_peers
+
get_peers
+
get_status
+
+
+
+ Example:
curl -X POST --data '{"jsonrpc":"2.0","method":"get_status","params":[],"id":1}' https://grincoin.org/v2/owner +
+
+
+
GET API
+
There are also several GET APIs provided by the explorer.
+
+ https://grincoin.org/rpc/block/latest
+ https://grincoin.org/rpc/market/supply
+ https://grincoin.org/rpc/network/hashrate
+ https://grincoin.org/rpc/network/difficulty

+
+
+ +
+ +{% endblock %} + diff --git a/templates/base.html.tera b/templates/base.html.tera index aa8f418..08d00f8 100644 --- a/templates/base.html.tera +++ b/templates/base.html.tera @@ -296,9 +296,12 @@ v.0.1.8 - + Search + + API +