Skip to content

Commit af305c0

Browse files
update API
1 parent 2200cab commit af305c0

1 file changed

Lines changed: 259 additions & 18 deletions

File tree

developers/api/rest.md

Lines changed: 259 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ title: REST
33
---
44
# REST API
55

6-
API for Warthog node version v0.10.3 "dd054a2"
6+
API for Warthog node version v0.10.3 "3ead1f0"
77

88
## Configuration
99

@@ -54,16 +54,16 @@ Below we assume the RPC socket is accessible at `localhost:3000`. On startup the
5454
| `GET` | [`/chain/signed_snapshot`](#get-chainsigned_snapshot) | Show chain snapshot |
5555
| `GET` | [`/chain/hashrate/chart/block/:from/:to/:window`](#get-chainhashratechartblockfromtowindow) | Show hashrate chart by block range |
5656
| `GET` | [`/chain/hashrate/chart/time/:from/:to/:interval`](#get-chainhashratecharttimefromtointerval) | Show hashrate chart by time range |
57-
| `GET` | [`/chart/candles/:asset/:interval?from=...&to=...&n=...`](#get-chartcandlesassetinterval) | Show OHLCV candle data for a timeframe (5m, 1h, 1d) |
58-
| `GET` | [`/chart/trades/:asset?from=...&to=...&n=...`](#get-charttradesasset) | Show trade data |
5957
| `POST` | [`/chain/append`](#post-chainappend) | Append mined block |
60-
| `GET` | [`/token/complete`](#get-tokencomplete) | Search tokens by name and/or hash prefix |
58+
| `GET` | [`/asset/complete?namePrefix=...&hashPrefix=...`](#get-assetcomplete) | Search assets by name and/or hash prefix |
59+
| `GET` | [`/asset/lookup/:asset`](#get-assetlookupasset) | Asset lookup (by ID or hash) |
6160
| `GET` | [`/market/:market`](#get-marketmarket) | Show market orders and liquidity pool |
61+
| `GET` | [`/market/:market/order/:historyId`](#get-marketmarketorderhistoryid) | Order history |
6262
| `GET` | [`/account/:account/mempool`](#get-accountaccountmempool) | Show mempool transactions for account |
6363
| `GET` | [`/account/:account/open_orders`](#get-accountaccountopen_orders) | Show all open orders for account |
6464
| `GET` | [`/account/:account/open_orders/:asset`](#get-accountaccountopen_ordersasset) | Show open orders for account and specific asset |
6565
| `GET` | [`/account/:account/balance/:token`](#get-accountaccountbalancetoken) | Show balance of specific account for a token |
66-
| `GET` | [`/account/:account/balance_wart`](#get-accountaccountbalance_wart) | Show WART balance of specific account |
66+
| `GET` | [`/account/:account/wart_balance`](#get-accountaccountwart_balance) | Show WART balance of specific account |
6767
| `GET` | [`/account/:account/history/:beforeTxIndex`](#get-accountaccounthistorybeforetxindex) | Show transaction history of specific account |
6868
| `GET` | [`/account/richlist/:token`](#get-accountrichlisttoken) | Show richlist for a specific token |
6969
| `GET` | [`/peers/ip_count`](#get-peersip_count) | Show peer IP counts |
@@ -77,9 +77,11 @@ Below we assume the RPC socket is accessible at `localhost:3000`. On startup the
7777
| `GET` | [`/peers/throttled`](#get-peersthrottled) | Show throttled peers |
7878
| `GET` | [`/peers/transmission_hours`](#get-peerstransmission_hours) | Show transmission data by hours |
7979
| `GET` | [`/peers/transmission_minutes`](#get-peerstransmission_minutes) | Show transmission data by minutes |
80+
| `GET` | [`/chart/candles/:asset/:interval?from=...&to=...&n=...`](#get-chartcandlesassetinterval) | Show OHLCV candle data for a timeframe (5m, 1h, 1d) |
81+
| `GET` | [`/chart/trades/:asset?from=...&to=...&n=...`](#get-charttradesasset) | Show trade data |
8082
| `GET` | [`/tools/encode16bit/from_e8/:feeE8`](#get-toolsencode16bitfrom_e8feee8) | Round raw 64 integer to closest 16 bit representation |
8183
| `GET` | [`/tools/encode16bit/from_string/:string`](#get-toolsencode16bitfrom_stringstring) | Round coin amount string to closest 16 bit representation |
82-
| `GET` | [`/tools/parse_price/:price/:precision`](#get-toolsparse_pricepriceprecision) | Parse price adjusted for asset precision |
84+
| `GET` | [`/tools/parse_price/:price/:decimals`](#get-toolsparse_pricedecimals) | Parse price adjusted for asset precision |
8385
| `GET` | [`/tools/info`](#get-toolsinfo) | Print information about this node |
8486
| `GET` | [`/tools/wallet/new`](#get-toolswalletnew) | Create a new wallet |
8587
| `GET` | [`/tools/wallet/from_privkey/:privkey`](#get-toolswalletfrom_privkeyprivkey) | Restore wallet from a private key |
@@ -316,7 +318,163 @@ For detailed JSON strucutre of block actions, see
316318
317319
Show binary data of specific block with structure annotations.
318320
319-
**TODO: Add JSON output example**
321+
Example output of `/chain/block/20/binary`:
322+
323+
```json
324+
{
325+
"code": 0,
326+
"data": {
327+
"bytes": "00000000000000000000000000000000000000040000000011e1a30100000000000000010000000000000007000000040000000000000000000009000000630000000000000000000000000f4240fa004902fc0829a8a7fa7b7016935f3bf5e8db4c5aed491dd6c0609180133ce5cff48c3134d287f28f0a07b266f68f04ddec146a93f9237a8f779dee0d2f7fc90b2d56010000",
328+
"structure": [
329+
{
330+
"children": [],
331+
"offsetBegin": 0,
332+
"offsetEnd": 10,
333+
"tag": "extraNonce"
334+
},
335+
{
336+
"children": [
337+
{
338+
"children": [],
339+
"offsetBegin": 10,
340+
"offsetEnd": 12,
341+
"tag": "length"
342+
}
343+
],
344+
"offsetBegin": 10,
345+
"offsetEnd": 12,
346+
"tag": "newAddresses"
347+
},
348+
{
349+
"children": [
350+
{
351+
"children": [],
352+
"offsetBegin": 12,
353+
"offsetEnd": 20,
354+
"tag": "toAccountId"
355+
},
356+
{
357+
"children": [],
358+
"offsetBegin": 20,
359+
"offsetEnd": 28,
360+
"tag": "wart"
361+
}
362+
],
363+
"offsetBegin": 12,
364+
"offsetEnd": 28,
365+
"tag": "reward"
366+
},
367+
{
368+
"children": [
369+
{
370+
"children": [],
371+
"offsetBegin": 28,
372+
"offsetEnd": 32,
373+
"tag": "length"
374+
}
375+
],
376+
"offsetBegin": 28,
377+
"offsetEnd": 32,
378+
"tag": "wartTransfers"
379+
},
380+
{
381+
"children": [
382+
{
383+
"children": [],
384+
"offsetBegin": 32,
385+
"offsetEnd": 34,
386+
"tag": "length"
387+
}
388+
],
389+
"offsetBegin": 32,
390+
"offsetEnd": 34,
391+
"tag": "cancelations"
392+
},
393+
{
394+
"children": [
395+
{
396+
"children": [],
397+
"offsetBegin": 34,
398+
"offsetEnd": 36,
399+
"tag": "length"
400+
},
401+
{
402+
"children": [],
403+
"offsetBegin": 36,
404+
"offsetEnd": 44,
405+
"tag": "assetId"
406+
},
407+
{
408+
"children": [],
409+
"offsetBegin": 44,
410+
"offsetEnd": 51,
411+
"tag": "tenBitsLengths"
412+
},
413+
{
414+
"children": [
415+
{
416+
"children": [],
417+
"offsetBegin": 51,
418+
"offsetEnd": 59,
419+
"tag": "originAccountId"
420+
},
421+
{
422+
"children": [],
423+
"offsetBegin": 59,
424+
"offsetEnd": 67,
425+
"tag": "pinNonce"
426+
},
427+
{
428+
"children": [],
429+
"offsetBegin": 67,
430+
"offsetEnd": 69,
431+
"tag": "compactFee"
432+
},
433+
{
434+
"children": [],
435+
"offsetBegin": 70,
436+
"offsetEnd": 78,
437+
"tag": "amount"
438+
},
439+
{
440+
"children": [],
441+
"offsetBegin": 78,
442+
"offsetEnd": 81,
443+
"tag": "limitPrice"
444+
},
445+
{
446+
"children": [],
447+
"offsetBegin": 81,
448+
"offsetEnd": 146,
449+
"tag": "signature"
450+
}
451+
],
452+
"offsetBegin": 51,
453+
"offsetEnd": 146,
454+
"tag": "limitSwap"
455+
}
456+
],
457+
"offsetBegin": 34,
458+
"offsetEnd": 146,
459+
"tag": "tokenSections"
460+
},
461+
{
462+
"children": [
463+
{
464+
"children": [],
465+
"offsetBegin": 146,
466+
"offsetEnd": 148,
467+
"tag": "length"
468+
}
469+
],
470+
"offsetBegin": 146,
471+
"offsetEnd": 148,
472+
"tag": "assetCreations"
473+
}
474+
]
475+
}
476+
}
477+
```
320478
321479
### `GET /chain/block/:id`
322480
@@ -437,26 +595,84 @@ Example output of `/chain/hashrate/100`
437595
}
438596
```
439597
440-
### `GET /chain/hashrate/chart/block/:from/:to/:window`
598+
### `GET /chart/hashrate/block/:from/:to/:window`
441599
442600
Show hashrate chart data for a block range.
443601
444602
**TODO: Add JSON output example**
445603
446-
### `GET /chain/hashrate/chart/time/:from/:to/:interval`
604+
### `GET /chart/hashrate/time/:from/:to/:interval`
447605
448606
Show hashrate chart data for a time range.
449607
450608
**TODO: Add JSON output example**
451609
452610
### `POST /chain/append`
453611
454-
Append mined block. Miners must POST mined block they received from `GET /chain/mine/:address`.
455-
TODO: Detailed description
612+
Append mined block. Miners must POST mined block they received from `GET /chain/mine/:address` with mined nonce (in header) and extranonce (first 10 bytes in block).
613+
Output on success: `{"code": 0, data: null}`, example on error: `{"code": <error code>, error: "<error message>"}`.
456614
457-
### `GET /token/complete`
615+
### `GET /asset/complete?namePrefix=...&hashPrefix=...`
458616
459-
Search tokens by name prefix and/or hash prefix. Query parameters: `namePrefix` and `hashPrefix`.
617+
Search assets by query parameters `namePrefix` (asset name prefix) and `hashPrefix` (hash prefix) especially suitable for auto-complete.
618+
Example output of "/asset/complete?namePrefix=TOK"
619+
```json
620+
{
621+
"code": 0,
622+
"data": {
623+
"hashPrefix": "",
624+
"matches": [
625+
{
626+
"decimals": 4,
627+
"hash": "0e4825efffa294610d2ac376713e3bcc9b53d378e823834b64e5df01f75d3b0c",
628+
"height": 7,
629+
"name": "TOK2"
630+
},
631+
{
632+
"decimals": 4,
633+
"hash": "58a74b758516d13e7f882922b483fca1627758c85b491e2cb9303e92e270ba88",
634+
"height": 4,
635+
"name": "TOK2"
636+
},
637+
{
638+
"decimals": 4,
639+
"hash": "d645efa5c0a64b409e44725d1d9b84ed7d800fca8ca5b3d71301d361652eddbc",
640+
"height": 22,
641+
"name": "TOK2"
642+
},
643+
{
644+
"decimals": 4,
645+
"hash": "f45b113119c7f7c000234f1090d5d181ab60b8b24526f1edd2f563aa1ca329f2",
646+
"height": 3,
647+
"name": "TOK2"
648+
}
649+
],
650+
"namePrefix": "TOK"
651+
}
652+
}
653+
```
654+
655+
### `GET /asset/lookup/:asset`
656+
657+
Look up asset information by asset ID or asset hash.
658+
659+
Example output of `/asset/lookup/7`:
660+
661+
```json
662+
{
663+
"code": 0,
664+
"data": {
665+
"decimals": 4,
666+
"hash": "0e4825efffa294610d2ac376713e3bcc9b53d378e823834b64e5df01f75d3b0c",
667+
"height": 7,
668+
"name": "TOK2"
669+
}
670+
}
671+
```
672+
673+
### `GET /market/:market/order/:historyId`
674+
675+
Show order for a specific market and order.
460676
461677
**TODO: Add JSON output example**
462678
@@ -484,7 +700,7 @@ Show open orders for a specific account and asset.
484700
485701
**TODO: Add JSON output example**
486702
487-
### `GET /account/:account/balance/:token`
703+
### `GET /account/:account/balance/:tokenspec`
488704
489705
Show balance of an account for a specific asset. The `:account` parameter is the account address, and `:token` is the token spec (e.g., `asset:0e4825efffa294610d2ac376713e3bcc9b53d378e823834b64e5df01f75d3b0c`).
490706
@@ -541,11 +757,36 @@ Show open orders for a specific account and asset.
541757
}
542758
```
543759
544-
### `GET /account/:account/balance_wart`
760+
### `GET /account/:account/wart_balance`
545761
546-
Show WART balance of a specific account.
762+
Show WART balance (locked, mempool and total) of a specific account. Amount in `mempool` cannot exceed `total - locked`.
547763
548-
**TODO: Add JSON output example**
764+
Example output of `account/2de77d5e23dc63e4c4149d394c979361e9e8e966336c8cd4/wart_balance`:
765+
```json
766+
{
767+
"code": 0,
768+
"data": {
769+
"account": {
770+
"accountId": 9,
771+
"address": "2de77d5e23dc63e4c4149d394c979361e9e8e966336c8cd4"
772+
},
773+
"balance": {
774+
"locked": {
775+
"E8": 0,
776+
"str": "0"
777+
},
778+
"mempool": {
779+
"E8": 0,
780+
"str": "0"
781+
},
782+
"total": {
783+
"E8": 400097559,
784+
"str": "4.00097559"
785+
}
786+
}
787+
}
788+
}
789+
```
549790
550791
### `GET /account/:account/history/:beforeTxIndex`
551792
@@ -709,7 +950,7 @@ Show transmission statistics aggregated by minutes.
709950
}
710951
```
711952
712-
### `GET /tools/parse_price/:price/:precision`
953+
### `GET /tools/parse_price/:price/:decimals`
713954
714955
Parse price adjusted for asset precision.
715956

0 commit comments

Comments
 (0)