Commit f3b4f480 authored by Jeremy Bokobza's avatar Jeremy Bokobza Committed by GitHub

Update ApiSpecification.md

1. Removed the "success = true" and "success = false" in response messages as the client will rely on HTTP code to be informed of success/failure.
2. Changed the error object to be an array of errors.
3. Reformatted the errors in the spec to be just a status code followed by a message instead of showing their JSON representation.

Apart from that I think there is some value in having possible errors after each endpoints, rather than having them grouped together at the top. This way, the client implementer doesn't have to look at all the errors in sequence to decide whether the relevant endpoint does or doesn't include which errors.

@nopara73 @dangershony @dev0tion any thoughts?
parent 79f14616
...@@ -2,12 +2,7 @@ ...@@ -2,12 +2,7 @@
## Request/Response ## Request/Response
RESPONSE: responsecode (`200` if success, `400`/`500` if error, see later) RESPONSE: response code (`200` for all successful requests, `4xx`/`5xx` if error, see later)
```
{
"success": "true"
}
```
HEADERS HEADERS
`Content-Type:application/json` `Content-Type:application/json`
...@@ -15,16 +10,20 @@ HEADERS ...@@ -15,16 +10,20 @@ HEADERS
## Errors ## Errors
### General errors ### General errors
`400` series status codes for client issues & `500` series status codes for server issues.
API should standardize that all `400` series errors come with consumable JSON error representation.
BODY BODY
The error response is an array of error objects.
Depending on the circumstance the API will either return an error at the first encounter or will continue until multiple errors are gathered.
``` ```
{ {
"success": "false", "errors": [
"message": "something bad happened", // ex.Message maybe? {
"description": ex.ToString() "status": 400,
"message": "No wallet file found at Wallets\\myFirstWallet.json",
"description": "System.ArgumentException: No wallet file found at..."
}
]
} }
``` ```
...@@ -36,11 +35,7 @@ This error message comes at all request if the wallet is not created yet, except ...@@ -36,11 +35,7 @@ This error message comes at all request if the wallet is not created yet, except
- `POST /wallet/send-transaction` - `POST /wallet/send-transaction`
``` ```
{ 404 (Not Found) - "wallet is not created"
"success": "false",
"message": "wallet is not created",
"description": ""
}
``` ```
### wallet is not decrypted ### wallet is not decrypted
...@@ -53,11 +48,7 @@ This error message comes at all request if the wallet is not loaded yet, except ...@@ -53,11 +48,7 @@ This error message comes at all request if the wallet is not loaded yet, except
- `DELETE /wallet` - `DELETE /wallet`
``` ```
{ 400 (Bad Request) - "wallet is not decrypted"
"success": "false",
"message": "wallet is not decrypted",
"description": ""
}
``` ```
## Key Management ## Key Management
...@@ -99,7 +90,6 @@ POST /wallet/send-transaction - Attempts to send a transaction ...@@ -99,7 +90,6 @@ POST /wallet/send-transaction - Attempts to send a transaction
### Responses ### Responses
``` ```
{ {
"success": "true",
"walletFilePath": "path to the wallet file", "walletFilePath": "path to the wallet file",
"encryptedSeed": "6PYKWP34en1wELfcJDgXaFRPugjgkDdEk2p2Pzytm1158dxgNyLAUXwpKL", "encryptedSeed": "6PYKWP34en1wELfcJDgXaFRPugjgkDdEk2p2Pzytm1158dxgNyLAUXwpKL",
"chainCode": "q/Fn7+RSIVM0p0Nj6rIuNkybF+0WKeSZPMQS2QCbDzY=", "chainCode": "q/Fn7+RSIVM0p0Nj6rIuNkybF+0WKeSZPMQS2QCbDzY=",
...@@ -119,7 +109,6 @@ POST /wallet/send-transaction - Attempts to send a transaction ...@@ -119,7 +109,6 @@ POST /wallet/send-transaction - Attempts to send a transaction
### Responses ### Responses
``` ```
{ {
"success": "true",
"extkey": "sadwqdpqoijedqcdoijsadoijsadisa", "extkey": "sadwqdpqoijedqcdoijsadoijsadisa",
"extpubkey": "dalkdsaklkjdlkjdsaljlkjdsalkjdsalk", "extpubkey": "dalkdsaklkjdlkjdsaljlkjdsalkjdsalk",
} }
...@@ -128,7 +117,6 @@ POST /wallet/send-transaction - Attempts to send a transaction ...@@ -128,7 +117,6 @@ POST /wallet/send-transaction - Attempts to send a transaction
### Responses ### Responses
``` ```
{ {
"success": "true",
"connectedNodeCount": "7", "connectedNodeCount": "7",
"maxConnextedNodeCount": "8", "maxConnextedNodeCount": "8",
"headerChainHeight": "1048", "headerChainHeight": "1048",
...@@ -151,7 +139,6 @@ POST /wallet/send-transaction - Attempts to send a transaction ...@@ -151,7 +139,6 @@ POST /wallet/send-transaction - Attempts to send a transaction
### Responses ### Responses
``` ```
{ {
"success": "true",
"mnemonic": "foo bar buz", "mnemonic": "foo bar buz",
} }
``` ```
...@@ -185,7 +172,6 @@ Works as expected. ...@@ -185,7 +172,6 @@ Works as expected.
### Responses ### Responses
``` ```
{ {
"success": "true",
"addresses": // 7 unused receive address (7 is the best number: https://www.psychologytoday.com/blog/fulfillment-any-age/201109/7-reasons-we-7-reasons) "addresses": // 7 unused receive address (7 is the best number: https://www.psychologytoday.com/blog/fulfillment-any-age/201109/7-reasons-we-7-reasons)
[ [
"mzz63n3n89KVeHQXRqJEVsQX8MZj5zeqCw", "mzz63n3n89KVeHQXRqJEVsQX8MZj5zeqCw",
...@@ -203,7 +189,6 @@ Works as expected. ...@@ -203,7 +189,6 @@ Works as expected.
### Responses ### Responses
``` ```
{ {
"success": "true",
"history": "history":
[ [
{ {
...@@ -226,7 +211,6 @@ Works as expected. ...@@ -226,7 +211,6 @@ Works as expected.
### Responses ### Responses
``` ```
{ {
"success": "true",
"synced": "true", "synced": "true",
"confirmed": "0.144", "confirmed": "0.144",
"unconfirmed": "-6.23" "unconfirmed": "-6.23"
...@@ -252,7 +236,6 @@ Unconfirmed balance is the difference of unconfirmed incoming and outgoing trans ...@@ -252,7 +236,6 @@ Unconfirmed balance is the difference of unconfirmed incoming and outgoing trans
#### Successful #### Successful
``` ```
{ {
"success": "true",
"spendsUnconfirmed": "false", // If spends unconfirmed you can ask the user if it's sure about spending unconfirmed transaction (if inputs are malleated or inputs never confirm then this transaction will never confirm either" "spendsUnconfirmed": "false", // If spends unconfirmed you can ask the user if it's sure about spending unconfirmed transaction (if inputs are malleated or inputs never confirm then this transaction will never confirm either"
"fee": "0.0001", "fee": "0.0001",
"feePercentOfSent": "0.1" // Percentage of the total spent amount, there must be a safety limit implemented here "feePercentOfSent": "0.1" // Percentage of the total spent amount, there must be a safety limit implemented here
...@@ -303,11 +286,7 @@ Unconfirmed balance is the difference of unconfirmed incoming and outgoing trans ...@@ -303,11 +286,7 @@ Unconfirmed balance is the difference of unconfirmed incoming and outgoing trans
#### Errors #### Errors
``` ```
{ 400 - "wallet is not synced"
"success": "false",
"message": "wallet is not synced",
"description": ""
}
``` ```
## POST /wallet/send-transaction - Attempts to send a transaction ## POST /wallet/send-transaction - Attempts to send a transaction
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment