From d666fd319c87a96e9d5be6d626ec79d4f9b44889 Mon Sep 17 00:00:00 2001 From: raphjaph Date: Sat, 30 Sep 2023 19:24:52 +0200 Subject: [PATCH 1/8] Document JSON-API --- docs/src/guides/explorer.md | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/docs/src/guides/explorer.md b/docs/src/guides/explorer.md index 02ad36b299..acaa14126e 100644 --- a/docs/src/guides/explorer.md +++ b/docs/src/guides/explorer.md @@ -71,3 +71,33 @@ Or by percentile, the percentage of bitcoin's supply that has been or will have been issued when they are mined: [100%](https://ordinals.com/search/100%) + +### JSON-API + +You can run ord with the `--enable-json-api` flag to access endpoints that +return JSON instead of HTML if you set the HTTP `Accept: application/json` +header. The structure of theses objects closely follows +what is shown in the HTML, in order to make it easier to explore. The following +endpoints are implemented at the moment: + +- `/inscription/` +- `/inscriptions` +- `/inscriptions/block/` +- `/inscriptions/block//` +- `/inscriptions/` +- `/inscriptions//` +- `/output/` +- `/output/` +- `/sat/` + +To get a list of the latest 100 inscriptions you would do: + +``` +curl -s -H "Accept: application/json" 'http://0.0.0.0:80/inscriptions' +``` + +To see information about an UTXO, which includes inscriptions inside it, do: + +``` +curl -s -H "Accept: application/json" 'http://0.0.0.0:80/output/bc4c30829a9564c0d58e6287195622b53ced54a25711d1b86be7cd3a70ef61ed:0' +``` From 9c0da035f6fcb742e7edd44c2c3a2076d37f5ea8 Mon Sep 17 00:00:00 2001 From: raphjaph Date: Sat, 30 Sep 2023 23:25:18 +0200 Subject: [PATCH 2/8] add link to section --- docs/src/guides/explorer.md | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/docs/src/guides/explorer.md b/docs/src/guides/explorer.md index acaa14126e..aaf4e3e953 100644 --- a/docs/src/guides/explorer.md +++ b/docs/src/guides/explorer.md @@ -14,7 +14,8 @@ To specify a port add the `--http-port` flag: `ord server --http-port 8080` -To enable the JSON-API endpoints add the `--enable-json-api` or `-e` flag: +To enable the JSON-API endpoints add the `--enable-json-api` or `-e` flag (see +[here](#JSON-API) for more info): `ord --enable-json-api server` @@ -101,3 +102,18 @@ To see information about an UTXO, which includes inscriptions inside it, do: ``` curl -s -H "Accept: application/json" 'http://0.0.0.0:80/output/bc4c30829a9564c0d58e6287195622b53ced54a25711d1b86be7cd3a70ef61ed:0' ``` + +Which returns: + +``` +{ + "value": 10000, + "script_pubkey": "OP_PUSHNUM_1 OP_PUSHBYTES_32 156cc4878306157720607cdcb4b32afa4cc6853868458d7258b907112e5a434b", + "address": "bc1pz4kvfpurqc2hwgrq0nwtfve2lfxvdpfcdpzc6ujchyr3ztj6gd9sfr6ayf", + "transaction": "bc4c30829a9564c0d58e6287195622b53ced54a25711d1b86be7cd3a70ef61ed", + "sat_ranges": null, + "inscriptions": [ + "6fb976ab49dcec017f1e201e84395983204ae1a7c2abf7ced0a85d692e442799i0" + ] +} +``` From b35a7c0f38dbb4afb2dd647afc9ef9b471d00dc2 Mon Sep 17 00:00:00 2001 From: raphjaph Date: Sat, 30 Sep 2023 23:28:02 +0200 Subject: [PATCH 3/8] make lowercase --- docs/src/guides/explorer.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/src/guides/explorer.md b/docs/src/guides/explorer.md index aaf4e3e953..c407e2abe9 100644 --- a/docs/src/guides/explorer.md +++ b/docs/src/guides/explorer.md @@ -15,7 +15,7 @@ To specify a port add the `--http-port` flag: `ord server --http-port 8080` To enable the JSON-API endpoints add the `--enable-json-api` or `-e` flag (see -[here](#JSON-API) for more info): +[here](#json-api) for more info): `ord --enable-json-api server` From b710cb64b7bc87a60354437cc04608e269a74245 Mon Sep 17 00:00:00 2001 From: raph Date: Mon, 2 Oct 2023 21:25:06 +0200 Subject: [PATCH 4/8] Update docs/src/guides/explorer.md Co-authored-by: Casey Rodarmor --- docs/src/guides/explorer.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/src/guides/explorer.md b/docs/src/guides/explorer.md index c407e2abe9..cf8304dc5a 100644 --- a/docs/src/guides/explorer.md +++ b/docs/src/guides/explorer.md @@ -73,7 +73,8 @@ been issued when they are mined: [100%](https://ordinals.com/search/100%) -### JSON-API +JSON-API +-------- You can run ord with the `--enable-json-api` flag to access endpoints that return JSON instead of HTML if you set the HTTP `Accept: application/json` From 13f3587dd61f356bc100d13cab111c0fc5f76d1e Mon Sep 17 00:00:00 2001 From: raph Date: Mon, 2 Oct 2023 21:25:16 +0200 Subject: [PATCH 5/8] Update docs/src/guides/explorer.md Co-authored-by: Casey Rodarmor --- docs/src/guides/explorer.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/src/guides/explorer.md b/docs/src/guides/explorer.md index cf8304dc5a..b068abdeef 100644 --- a/docs/src/guides/explorer.md +++ b/docs/src/guides/explorer.md @@ -76,7 +76,7 @@ been issued when they are mined: JSON-API -------- -You can run ord with the `--enable-json-api` flag to access endpoints that +You can run `ord` with the `--enable-json-api` flag to access endpoints that return JSON instead of HTML if you set the HTTP `Accept: application/json` header. The structure of theses objects closely follows what is shown in the HTML, in order to make it easier to explore. The following From 1173dc7f563c6cf8b12fd06df498239802e91efb Mon Sep 17 00:00:00 2001 From: raph Date: Mon, 2 Oct 2023 21:25:23 +0200 Subject: [PATCH 6/8] Update docs/src/guides/explorer.md Co-authored-by: Casey Rodarmor --- docs/src/guides/explorer.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/src/guides/explorer.md b/docs/src/guides/explorer.md index b068abdeef..067b217b35 100644 --- a/docs/src/guides/explorer.md +++ b/docs/src/guides/explorer.md @@ -79,7 +79,7 @@ JSON-API You can run `ord` with the `--enable-json-api` flag to access endpoints that return JSON instead of HTML if you set the HTTP `Accept: application/json` header. The structure of theses objects closely follows -what is shown in the HTML, in order to make it easier to explore. The following +what is shown in the HTML. The following endpoints are implemented at the moment: - `/inscription/` From c7d0b93c02ae0bec3e410e51e77feb5b119a1a7a Mon Sep 17 00:00:00 2001 From: raph Date: Mon, 2 Oct 2023 21:25:36 +0200 Subject: [PATCH 7/8] Update docs/src/guides/explorer.md Co-authored-by: Casey Rodarmor --- docs/src/guides/explorer.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/src/guides/explorer.md b/docs/src/guides/explorer.md index 067b217b35..daad75701a 100644 --- a/docs/src/guides/explorer.md +++ b/docs/src/guides/explorer.md @@ -98,7 +98,7 @@ To get a list of the latest 100 inscriptions you would do: curl -s -H "Accept: application/json" 'http://0.0.0.0:80/inscriptions' ``` -To see information about an UTXO, which includes inscriptions inside it, do: +To see information about a UTXO, which includes inscriptions inside it, do: ``` curl -s -H "Accept: application/json" 'http://0.0.0.0:80/output/bc4c30829a9564c0d58e6287195622b53ced54a25711d1b86be7cd3a70ef61ed:0' From 867a92099f52c29815318fb70f05d8562feb0c4a Mon Sep 17 00:00:00 2001 From: raphjaph Date: Mon, 2 Oct 2023 21:29:24 +0200 Subject: [PATCH 8/8] change short flag --- docs/src/guides/explorer.md | 5 ++--- src/options.rs | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/docs/src/guides/explorer.md b/docs/src/guides/explorer.md index daad75701a..f6253ff355 100644 --- a/docs/src/guides/explorer.md +++ b/docs/src/guides/explorer.md @@ -14,7 +14,7 @@ To specify a port add the `--http-port` flag: `ord server --http-port 8080` -To enable the JSON-API endpoints add the `--enable-json-api` or `-e` flag (see +To enable the JSON-API endpoints add the `--enable-json-api` or `-j` flag (see [here](#json-api) for more info): `ord --enable-json-api server` @@ -79,8 +79,7 @@ JSON-API You can run `ord` with the `--enable-json-api` flag to access endpoints that return JSON instead of HTML if you set the HTTP `Accept: application/json` header. The structure of theses objects closely follows -what is shown in the HTML. The following -endpoints are implemented at the moment: +what is shown in the HTML. These endpoints are: - `/inscription/` - `/inscriptions` diff --git a/src/options.rs b/src/options.rs index 4b3b318a3e..8af18cc60d 100644 --- a/src/options.rs +++ b/src/options.rs @@ -54,7 +54,7 @@ pub(crate) struct Options { pub(crate) testnet: bool, #[arg(long, default_value = "ord", help = "Use wallet named .")] pub(crate) wallet: String, - #[arg(long, short, help = "Enable JSON API.")] + #[arg(long, short = 'j', help = "Enable JSON API.")] pub(crate) enable_json_api: bool, }