gitlab.com/SiaPrime/SiaPrime@v1.4.1/doc/API.md (about) 1 Siad API 2 ======== 3 4 SiaPrime uses semantic versioning and is backwards compatible to version v1.0.0. 5 6 API calls return either JSON or no content. Success is indicated by 2xx HTTP 7 status codes, while errors are indicated by 4xx and 5xx HTTP status codes. If 8 an endpoint does not specify its expected status code refer to 9 [#standard-responses](#standard-responses). 10 11 There may be functional API calls which are not documented. These are not 12 guaranteed to be supported beyond the current release, and should not be used 13 in production. 14 15 Notes: 16 - Requests must set their User-Agent string to contain the substring "SiaPrime-Agent". 17 - By default, siad listens on "localhost:4280". This can be changed using the 18 `--api-addr` flag when running siad. 19 - **Do not bind or expose the API to a non-loopback address unless you are 20 aware of the possible dangers.** 21 22 Example GET curl call: 23 ``` 24 curl -A "SiaPrime-Agent" "localhost:4280/wallet/transactions?startheight=1&endheight=250" 25 ``` 26 27 Example POST curl call: 28 ``` 29 curl -A "SiaPrime-Agent" --data "amount=123&destination=abcd" "localhost:4280/wallet/siacoins" 30 ``` 31 32 Standard responses 33 ------------------ 34 35 #### Success 36 37 The standard response indicating the request was successfully processed is HTTP 38 status code `204 No Content`. If the request was successfully processed and the 39 server responded with JSON the HTTP status code is `200 OK`. Specific endpoints 40 may specify other 2xx status codes on success. 41 42 #### Error 43 44 The standard error response indicating the request failed for any reason, is a 45 4xx or 5xx HTTP status code with an error JSON object describing the error. 46 ```javascript 47 { 48 "message": String 49 50 // There may be additional fields depending on the specific error. 51 } 52 ``` 53 54 Authentication 55 -------------- 56 57 API authentication can be enabled with the `--authenticate-api` siad flag. 58 Authentication is HTTP Basic Authentication as described in 59 [RFC 2617](https://tools.ietf.org/html/rfc2617), however, the username is the 60 empty string. The flag does not enforce authentication on all API endpoints. 61 Only endpoints that expose sensitive information or modify state require 62 authentication. 63 64 For example, if the API password is "foobar" the request header should include 65 ``` 66 Authorization: Basic OmZvb2Jhcg== 67 ``` 68 69 Units 70 ----- 71 72 Unless otherwise specified, all parameters should be specified in their 73 smallest possible unit. For example, size should always be specified in bytes 74 and Siacoins should be specified in hastings. JSON values returned by the API 75 will also use the smallest possible unit, unless otherwise specified. 76 77 If a numbers is returned as a string in JSON, it should be treated as an 78 arbitrary-precision number (bignum), and it should be parsed with your 79 language's corresponding bignum library. Currency values are the most common 80 example where this is necessary. 81 82 Table of contents 83 ----------------- 84 85 - [Daemon](#daemon) 86 - [Consensus](#consensus) 87 - [Gateway](#gateway) 88 - [Host](#host) 89 - [Host DB](#host-db) 90 - [Miner](#miner) 91 - [Renter](#renter) 92 - [Transaction Pool](#transaction-pool) 93 - [Wallet](#wallet) 94 95 Daemon 96 ------ 97 98 | Route | HTTP verb | 99 | ----------------------------------------- | --------- | 100 | [/daemon/constants](#daemonconstants-get) | GET | 101 | [/daemon/stop](#daemonstop-get) | GET | 102 | [/daemon/version](#daemonversion-get) | GET | 103 104 For examples and detailed descriptions of request and response parameters, 105 refer to [Daemon.md](/doc/api/Daemon.md). 106 107 #### /daemon/constants [GET] 108 109 returns the set of constants in use. 110 111 ###### JSON Response [(with comments)](/doc/api/Daemon.md#json-response) 112 ```javascript 113 { 114 "blockfrequency": 600, // seconds per block 115 "blocksizelimit": 2000000, // bytes 116 "extremefuturethreshold": 10800, // seconds 117 "futurethreshold": 10800, // seconds 118 "genesistimestamp": 1257894000, // Unix time 119 "maturitydelay": 144, // blocks 120 "mediantimestampwindow": 11, // blocks 121 "siafundcount": "10000", 122 "siafundportion": "39/1000", 123 "targetwindow": 1000, // blocks 124 125 "initialcoinbase": 300000, // Siacoins (see note in Daemon.md) 126 "minimumcoinbase": 30000, // Siacoins (see note in Daemon.md) 127 128 "roottarget": [0,0,0,0,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], 129 "rootdepth": [255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255], 130 131 "maxtargetadjustmentup": "5/2", 132 "maxtargetadjustmentdown": "2/5", 133 134 "siacoinprecision": "1000000000000000000000000" // hastings per siacoin 135 } 136 ``` 137 138 #### /daemon/stop [GET] 139 140 cleanly shuts down the daemon. May take a few seconds. 141 142 ###### Response 143 standard success or error response. See 144 [#standard-responses](#standard-responses). 145 146 #### /daemon/version [GET] 147 148 returns the version of the SiaPrime daemon currently running. 149 150 ###### JSON Response [(with comments)](/doc/api/Daemon.md#json-response-1) 151 ```javascript 152 { 153 "version": "1.0.0" 154 } 155 ``` 156 157 Consensus 158 --------- 159 160 | Route | HTTP verb | 161 | --------------------------------------------------------------------------- | --------- | 162 | [/consensus](#consensus-get) | GET | 163 | [/consensus/blocks](#consensusblocks-get) | GET | 164 | [/consensus/validate/transactionset](#consensusvalidatetransactionset-post) | POST | 165 166 For examples and detailed descriptions of request and response parameters, 167 refer to [Consensus.md](/doc/api/Consensus.md). 168 169 #### /consensus [GET] 170 171 returns information about the consensus set, such as the current block height. 172 173 ###### JSON Response [(with comments)](/doc/api/Consensus.md#json-response) 174 ```javascript 175 { 176 "synced": true, 177 "height": 62248, 178 "currentblock": "00000000000008a84884ba827bdc868a17ba9c14011de33ff763bd95779a9cf1", 179 "target": [0,0,0,0,0,0,11,48,125,79,116,89,136,74,42,27,5,14,10,31,23,53,226,238,202,219,5,204,38,32,59,165], 180 "difficulty": "1234" 181 } 182 ``` 183 184 #### /consensus/blocks [GET] 185 186 Returns the block for a given id or height. 187 188 ###### Query String Parameters 189 One of the following parameters can be specified. 190 ``` 191 // BlockID of the requested block. 192 id 193 194 // BlockHeight of the requested block. 195 height 196 197 ``` 198 199 ###### Response 200 The JSON formatted block or a standard error response. 201 ``` 202 { 203 "height": 20032, 204 "id": "00000000000033b9eb57fa63a51adeea857e70f6415ebbfe5df2a01f0d0477f4", 205 "minerpayouts": [ 206 { 207 "unlockhash": "c199cd180e19ef7597bcf4beecdd4f211e121d085e24432959c42bdf9030e32b9583e1c2727c", 208 "value": "279978000000000000000000000000" 209 } 210 ], 211 "nonce": [4,12,219,7,0,0,0,0], 212 "parentid": "0000000000009615e8db750eb1226aa5e629bfa7badbfe0b79607ec8b918a44c", 213 "timestamp": 1444516982, 214 "transactions": [ 215 { 216 // ... 217 }, 218 { 219 "arbitrarydata": [], 220 "filecontractrevisions": [], 221 "filecontracts": [], 222 "id": "3c98ec79b990461f353c22bb06bcfb10e702f529ad7d27a43c4448273553d90a", 223 "minerfees": [], 224 "siacoininputs": [ 225 { 226 "parentid": "24cbeb9df7eb2d81d0025168fc94bd179909d834f49576e65b51feceaf957a64", 227 "unlockconditions": { 228 "publickeys": [ 229 { 230 "algorithm": "ed25519", 231 "key": "QET8w7WRbGfcnnpKd1nuQfE3DuNUUq9plyoxwQYDK4U=" 232 } 233 ], 234 "signaturesrequired": 1, 235 "timelock": 0 236 } 237 } 238 ], 239 "siacoinoutputs": [ 240 { 241 "id": "1f9da81e23522f79590ac67ac0b668828c52b341cbf04df4959bb7040c072f29", 242 "unlockhash": "d54f500f6c1774d518538dbe87114fe6f7e6c76b5bc8373a890b12ce4b8909a336106a4cd6db", 243 "value": "1010000000000000000000000000" 244 }, 245 { 246 "id": "14978a4c54f5ebd910ea41537de014f8423574c13d132e8713fab5af09ec08ca", 247 "unlockhash": "48a56b19bd0be4f24190640acbd0bed9669ea9c18823da2645ec1ad9652f10b06c5d4210f971", 248 "value": "5780000000000000000000000000" 249 } 250 ], 251 "siafundinputs": [], 252 "siafundoutputs": [], 253 "storageproofs": [], 254 "transactionsignatures": [ 255 { 256 "coveredfields": { 257 "arbitrarydata": [], 258 "filecontractrevisions": [], 259 "filecontracts": [], 260 "minerfees": [], 261 "siacoininputs": [], 262 "siacoinoutputs": [], 263 "siafundinputs": [], 264 "siafundoutputs": [], 265 "storageproofs": [], 266 "transactionsignatures": [], 267 "wholetransaction": true 268 }, 269 "parentid": "24cbeb9df7eb2d81d0025168fc94bd179909d834f49576e65b51feceaf957a64", 270 "publickeyindex": 0, 271 "signature": "pByLGMlvezIZWVZmHQs/ynGETETNbxcOY/kr6uivYgqZqCcKTJ0JkWhcFaKJU+3DEA7JAloLRNZe3PTklD3tCQ==", 272 "timelock": 0 273 } 274 ] 275 }, 276 { 277 // ... 278 } 279 ] 280 } 281 ``` 282 283 #### /consensus/validate/transactionset [POST] 284 285 validates a set of transactions using the current utxo set. 286 287 ###### Request Body Bytes 288 289 Since transactions may be large, the transaction set is supplied in the POST 290 body, encoded in JSON format. 291 292 ###### Response 293 standard success or error response. See 294 [#standard-responses](#standard-responses). 295 296 Gateway 297 ------- 298 299 | Route | HTTP verb | 300 | ---------------------------------------------------------------------------------- | --------- | 301 | [/gateway](#gateway-get-example) | GET | 302 | [/gateway/connect/:___netaddress___](#gatewayconnectnetaddress-post-example) | POST | 303 | [/gateway/disconnect/:___netaddress___](#gatewaydisconnectnetaddress-post-example) | POST | 304 305 For examples and detailed descriptions of request and response parameters, 306 refer to [Gateway.md](/doc/api/Gateway.md). 307 308 #### /gateway [GET] [(example)](/doc/api/Gateway.md#gateway-info) 309 310 returns information about the gateway, including the list of connected peers. 311 312 ###### JSON Response [(with comments)](/doc/api/Gateway.md#json-response) 313 ```javascript 314 { 315 "netaddress": String, 316 "peers": []{ 317 "netaddress": String, 318 "version": String, 319 "inbound": Boolean 320 } 321 } 322 ``` 323 324 #### /gateway/connect/:___netaddress___ [POST] [(example)](/doc/api/Gateway.md#connecting-to-a-peer) 325 326 connects the gateway to a peer. The peer is added to the node list if it is not 327 already present. The node list is the list of all nodes the gateway knows 328 about, but is not necessarily connected to. 329 330 ###### Path Parameters [(with comments)](/doc/api/Gateway.md#path-parameters) 331 ``` 332 :netaddress 333 ``` 334 335 ###### Response 336 standard success or error response. See 337 [#standard-responses](#standard-responses). 338 339 #### /gateway/disconnect/:___netaddress___ [POST] [(example)](/doc/api/Gateway.md#disconnecting-from-a-peer) 340 341 disconnects the gateway from a peer. The peer remains in the node list. 342 343 ###### Path Parameters [(with comments)](/doc/api/Gateway.md#path-parameters-1) 344 ``` 345 :netaddress 346 ``` 347 348 ###### Response 349 standard success or error response. See 350 [#standard-responses](#standard-responses). 351 352 Host 353 ---- 354 355 | Route | HTTP verb | 356 | ------------------------------------------------------------------------------------------ | --------- | 357 | [/host](#host-get) | GET | 358 | [/host](#host-post) | POST | 359 | [/host/announce](#hostannounce-post) | POST | 360 | [/host/contracts](#hostcontracts-get) | GET | 361 | [/host/estimatescore](#hostestimatescore-get) | GET | 362 | [/host/storage](#hoststorage-get) | GET | 363 | [/host/storage/folders/add](#hoststoragefoldersadd-post) | POST | 364 | [/host/storage/folders/remove](#hoststoragefoldersremove-post) | POST | 365 | [/host/storage/folders/resize](#hoststoragefoldersresize-post) | POST | 366 | [/host/storage/sectors/delete/:___merkleroot___](#hoststoragesectorsdeletemerkleroot-post) | POST | 367 368 For examples and detailed descriptions of request and response parameters, 369 refer to [Host.md](/doc/api/Host.md). 370 371 #### /host [GET] 372 373 fetches status information about the host. 374 375 ###### JSON Response [(with comments)](/doc/api/Host.md#json-response) 376 ```javascript 377 { 378 "externalsettings": { 379 "acceptingcontracts": true, 380 "maxdownloadbatchsize": 17825792, // bytes 381 "maxduration": 25920, // blocks 382 "maxrevisebatchsize": 17825792, // bytes 383 "netaddress": "123.456.789.0:4282", 384 "remainingstorage": 35000000000, // bytes 385 "sectorsize": 4194304, // bytes 386 "totalstorage": 35000000000, // bytes 387 "unlockhash": "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789ab", 388 "windowsize": 144, // blocks 389 390 "collateral": "57870370370", // hastings / byte / block 391 "maxcollateral": "100000000000000000000000000000", // hastings 392 393 "contractprice": "30000000000000000000000000", // hastings 394 "downloadbandwidthprice": "250000000000000", // hastings / byte 395 "storageprice": "231481481481", // hastings / byte / block 396 "uploadbandwidthprice": "100000000000000", // hastings / byte 397 398 "revisionnumber": 0, 399 "version": "1.0.0" 400 }, 401 402 "financialmetrics": { 403 "contractcount": 2, 404 "contractcompensation": "123", // hastings 405 "potentialcontractcompensation": "123", // hastings 406 407 "lockedstoragecollateral": "123", // hastings 408 "lostrevenue": "123", // hastings 409 "loststoragecollateral": "123", // hastings 410 "potentialstoragerevenue": "123", // hastings 411 "riskedstoragecollateral": "123", // hastings 412 "storagerevenue": "123", // hastings 413 "transactionfeeexpenses": "123", // hastings 414 415 "downloadbandwidthrevenue": "123", // hastings 416 "potentialdownloadbandwidthrevenue": "123", // hastings 417 "potentialuploadbandwidthrevenue": "123", // hastings 418 "uploadbandwidthrevenue": "123" // hastings 419 }, 420 421 "internalsettings": { 422 "acceptingcontracts": true, 423 "maxdownloadbatchsize": 17825792, // bytes 424 "maxduration": 25920, // blocks 425 "maxrevisebatchsize": 17825792, // bytes 426 "netaddress": "123.456.789.0:4282", 427 "windowsize": 144, // blocks 428 429 "collateral": "57870370370", // hastings / byte / block 430 "collateralbudget": "2000000000000000000000000000000", // hastings 431 "maxcollateral": "100000000000000000000000000000", // hastings 432 433 "mincontractprice": "30000000000000000000000000", // hastings 434 "mindownloadbandwidthprice": "250000000000000", // hastings / byte 435 "minstorageprice": "231481481481", // hastings / byte / block 436 "minuploadbandwidthprice": "100000000000000" // hastings / byte 437 }, 438 439 "networkmetrics": { 440 "downloadcalls": 0, 441 "errorcalls": 1, 442 "formcontractcalls": 2, 443 "renewcalls": 3, 444 "revisecalls": 4, 445 "settingscalls": 5, 446 "unrecognizedcalls": 6 447 }, 448 449 "connectabilitystatus": "checking", 450 "workingstatus": "checking" 451 } 452 ``` 453 454 #### /host [POST] 455 456 configures hosting parameters. All parameters are optional; unspecified 457 parameters will be left unchanged. 458 459 ###### Query String Parameters [(with comments)](/doc/api/Host.md#query-string-parameters) 460 ``` 461 acceptingcontracts // Optional, true / false 462 maxdownloadbatchsize // Optional, bytes 463 maxduration // Optional, blocks 464 maxrevisebatchsize // Optional, bytes 465 netaddress // Optional 466 windowsize // Optional, blocks 467 468 collateral // Optional, hastings / byte / block 469 collateralbudget // Optional, hastings 470 maxcollateral // Optional, hastings 471 472 mincontractprice // Optional, hastings 473 mindownloadbandwidthprice // Optional, hastings / byte 474 minstorageprice // Optional, hastings / byte / block 475 minuploadbandwidthprice // Optional, hastings / byte 476 ``` 477 478 ###### Response 479 standard success or error response. See 480 [#standard-responses](#standard-responses). 481 482 #### /host/announce [POST] 483 484 Announces the host to the network as a source of storage. Generally only needs 485 to be called once. 486 487 ###### Query String Parameters [(with comments)](/doc/api/Host.md#query-string-parameters-1) 488 ``` 489 netaddress string // Optional 490 ``` 491 492 ###### Response 493 standard success or error response. See 494 [#standard-responses](#standard-responses). 495 496 #### /host/contracts [GET] 497 498 gets a list of all contracts from the host database 499 500 ###### JSON Response [(with comments)](/doc/api/Host.md#json-response-1) 501 ```javascript 502 { 503 "contracts": [ 504 { 505 "contractcost": "1234", // hastings 506 "datasize": 500000, // bytes 507 "lockedcollateral": "1234", // hastings 508 "obligationid": "fff48010dcbbd6ba7ffd41bc4b25a3634ee58bbf688d2f06b7d5a0c837304e13", 509 "potentialdownloadrevenue": "1234", // hastings 510 "potentialstoragerevenue": "1234", // hastings 511 "potentialuploadrevenue": "1234", // hastings 512 "riskedcollateral": "1234", // hastings 513 "sectorrootscount": 2, 514 "transactionfeesadded": "1234", // hastings 515 516 "expirationheight": 123456, // blocks 517 "negotiationheight": 123456, // blocks 518 "proofdeadline": 123456, // blocks 519 520 "obligationstatus": "obligationFailed", 521 "originconfirmed": true, 522 "proofconfirmed": true, 523 "proofconstructed": true 524 "revisionconfirmed": false, 525 "revisionconstructed": false, 526 } 527 ] 528 } 529 ``` 530 531 #### /host/storage [GET] 532 533 gets a list of folders tracked by the host's storage manager. 534 535 ###### JSON Response [(with comments)](/doc/api/Host.md#json-response-2) 536 ```javascript 537 { 538 "folders": [ 539 { 540 "path": "/home/foo/bar", 541 "capacity": 50000000000, // bytes 542 "capacityremaining": 100000, // bytes 543 544 "failedreads": 0, 545 "failedwrites": 1, 546 "successfulreads": 2, 547 "successfulwrites": 3 548 } 549 ] 550 } 551 ``` 552 553 #### /host/storage/folders/add [POST] 554 555 adds a storage folder to the manager. The manager may not check that there is 556 enough space available on-disk to support as much storage as requested 557 558 ###### Query String Parameters [(with comments)](/doc/api/Host.md#query-string-parameters-2) 559 ``` 560 path // Required 561 size // bytes, Required 562 ``` 563 564 ###### Response 565 standard success or error response. See 566 [#standard-responses](#standard-responses). 567 568 #### /host/storage/folders/remove [POST] 569 570 remove a storage folder from the manager. All storage on the folder will be 571 moved to other storage folders, meaning that no data will be lost. If the 572 manager is unable to save data, an error will be returned and the operation 573 will be stopped. 574 575 ###### Query String Parameters [(with comments)](/doc/api/Host.md#query-string-parameters-3) 576 ``` 577 path // Required 578 force // bool, Optional, default is false 579 ``` 580 581 ###### Response 582 standard success or error response. See 583 [#standard-responses](#standard-responses). 584 585 #### /host/storage/folders/resize [POST] 586 587 grows or shrink a storage folder in the manager. The manager may not check that 588 there is enough space on-disk to support growing the storage folder, but should 589 gracefully handle running out of space unexpectedly. When shrinking a storage 590 folder, any data in the folder that needs to be moved will be placed into other 591 storage folders, meaning that no data will be lost. If the manager is unable to 592 migrate the data, an error will be returned and the operation will be stopped. 593 594 ###### Query String Parameters [(with comments)](/doc/api/Host.md#query-string-parameters-4) 595 ``` 596 path // Required 597 newsize // bytes, Required 598 ``` 599 600 ###### Response 601 standard success or error response. See 602 [#standard-responses](#standard-responses). 603 604 #### /host/storage/sectors/delete/:___merkleroot___ [POST] 605 606 deletes a sector, meaning that the manager will be unable to upload that sector 607 and be unable to provide a storage proof on that sector. This endpoint is for 608 removing the data entirely, and will remove instances of the sector appearing 609 at all heights. The primary purpose is to comply with legal requests to remove 610 data. 611 612 ###### Path Parameters [(with comments)](/doc/api/Host.md#path-parameters) 613 ``` 614 :merkleroot 615 ``` 616 617 ###### Response 618 standard success or error response. See 619 [#standard-responses](#standard-responses). 620 621 #### /host/estimatescore [GET] 622 623 returns the estimated HostDB score of the host using its current settings, 624 combined with the provided settings. 625 626 ###### JSON Response [(with comments)](/doc/api/Host.md#json-response-3) 627 ```javascript 628 { 629 "estimatedscore": "123456786786786786786786786742133", 630 "conversionrate": 95 631 } 632 ``` 633 634 ###### Query String Parameters [(with comments)](/doc/api/Host.md#query-string-parameters-5) 635 ``` 636 acceptingcontracts // Optional, true / false 637 maxdownloadbatchsize // Optional, bytes 638 maxduration // Optional, blocks 639 maxrevisebatchsize // Optional, bytes 640 netaddress // Optional 641 windowsize // Optional, blocks 642 643 collateral // Optional, hastings / byte / block 644 collateralbudget // Optional, hastings 645 maxcollateral // Optional, hastings 646 647 mincontractprice // Optional, hastings 648 mindownloadbandwidthprice // Optional, hastings / byte 649 minstorageprice // Optional, hastings / byte / block 650 minuploadbandwidthprice // Optional, hastings / byte 651 ``` 652 653 654 Host DB 655 ------- 656 657 | Route | HTTP verb | 658 | ------------------------------------------------------- | --------- | 659 | [/hostdb](#hostdb-get-example) | GET | 660 | [/hostdb/active](#hostdbactive-get-example) | GET | 661 | [/hostdb/all](#hostdball-get-example) | GET | 662 | [/hostdb/hosts/:___pubkey___](#hostdbhostspubkey-get-example) | GET | 663 664 For examples and detailed descriptions of request and response parameters, 665 refer to [HostDB.md](/doc/api/HostDB.md). 666 667 #### /hostdb [GET] [(example)](/doc/api/HostDB.md#hostdb-get) 668 669 shows some general information about the state of the hostdb. 670 671 ###### JSON Response [(with comments)](/doc/api/HostDB.md#json-response) 672 673 Either the following JSON struct or an error response. See [#standard-responses](#standard-responses). 674 675 ```javascript 676 { 677 "initialscancomplete": false 678 } 679 ``` 680 681 #### /hostdb/active [GET] [(example)](/doc/api/HostDB.md#active-hosts) 682 683 lists all of the active hosts known to the renter, sorted by preference. 684 685 ###### Query String Parameters [(with comments)](/doc/api/HostDB.md#query-string-parameters) 686 ``` 687 numhosts // Optional 688 ``` 689 690 ###### JSON Response [(with comments)](/doc/api/HostDB.md#json-response-1) 691 ```javascript 692 { 693 "hosts": [ 694 { 695 "acceptingcontracts": true, 696 "maxdownloadbatchsize": 17825792, // bytes 697 "maxduration": 25920, // blocks 698 "maxrevisebatchsize": 17825792, // bytes 699 "netaddress": "123.456.789.2:4282", 700 "remainingstorage": 35000000000, // bytes 701 "sectorsize": 4194304, // bytes 702 "totalstorage": 35000000000, // bytes 703 "unlockhash": "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789ab", 704 "windowsize": 144, // blocks 705 "publickey": { 706 "algorithm": "ed25519", 707 "key": "RW50cm9weSBpc24ndCB3aGF0IGl0IHVzZWQgdG8gYmU=" 708 } 709 "publickeystring": "ed25519:1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef", 710 } 711 ] 712 } 713 ``` 714 715 #### /hostdb/all [GET] [(example)](/doc/api/HostDB.md#all-hosts) 716 717 lists all of the hosts known to the renter. Hosts are not guaranteed to be in 718 any particular order, and the order may change in subsequent calls. 719 720 ###### JSON Response [(with comments)](/doc/api/HostDB.md#json-response-2) 721 ```javascript 722 { 723 "hosts": [ 724 { 725 "acceptingcontracts": true, 726 "maxdownloadbatchsize": 17825792, // bytes 727 "maxduration": 25920, // blocks 728 "maxrevisebatchsize": 17825792, // bytes 729 "netaddress": "123.456.789.0:4282", 730 "remainingstorage": 35000000000, // bytes 731 "sectorsize": 4194304, // bytes 732 "totalstorage": 35000000000, // bytes 733 "unlockhash": "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789ab", 734 "windowsize": 144, // blocks 735 "publickey": { 736 "algorithm": "ed25519", 737 "key": "RW50cm9weSBpc24ndCB3aGF0IGl0IHVzZWQgdG8gYmU=" 738 } 739 "publickeystring": "ed25519:1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef", 740 } 741 ] 742 } 743 ``` 744 745 #### /hostdb/hosts/:___pubkey___ [GET] [(example)](/doc/api/HostDB.md#host-details) 746 747 fetches detailed information about a particular host, including metrics 748 regarding the score of the host within the database. It should be noted that 749 each renter uses different metrics for selecting hosts, and that a good score on 750 in one hostdb does not mean that the host will be successful on the network 751 overall. 752 753 ###### Path Parameters [(with comments)](/doc/api/HostDB.md#path-parameters) 754 ``` 755 :pubkey 756 ``` 757 758 ###### JSON Response [(with comments)](/doc/api/HostDB.md#json-response-3) 759 ```javascript 760 { 761 "entry": { 762 "acceptingcontracts": true, 763 "maxdownloadbatchsize": 17825792, // bytes 764 "maxduration": 25920, // blocks 765 "maxrevisebatchsize": 17825792, // bytes 766 "netaddress": "123.456.789.0:4282", 767 "remainingstorage": 35000000000, // bytes 768 "sectorsize": 4194304, // bytes 769 "totalstorage": 35000000000, // bytes 770 "unlockhash": "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789ab", 771 "windowsize": 144, // blocks 772 "publickey": { 773 "algorithm": "ed25519", 774 "key": "RW50cm9weSBpc24ndCB3aGF0IGl0IHVzZWQgdG8gYmU=" 775 } 776 "publickeystring": "ed25519:1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef", 777 }, 778 "scorebreakdown": { 779 "score": 1, 780 781 "ageadjustment": 0.1234, 782 "burnadjustment": 0.1234, 783 "collateraladjustment": 23.456, 784 "interactionadjustment": 0.1234, 785 "priceadjustment": 0.1234, 786 "storageremainingadjustment": 0.1234, 787 "uptimeadjustment": 0.1234, 788 "versionadjustment": 0.1234, 789 } 790 } 791 ``` 792 793 794 Miner 795 ----- 796 797 | Route | HTTP verb | 798 | ---------------------------------- | --------- | 799 | [/miner](#miner-get) | GET | 800 | [/miner/start](#minerstart-get) | GET | 801 | [/miner/stop](#minerstop-get) | GET | 802 | [/miner/header](#minerheader-get) | GET | 803 | [/miner/header](#minerheader-post) | POST | 804 805 For examples and detailed descriptions of request and response parameters, 806 refer to [Miner.md](/doc/api/Miner.md). 807 808 #### /miner [GET] 809 810 returns the status of the miner. 811 812 ###### JSON Response [(with comments)](/doc/api/Miner.md#json-response) 813 ```javascript 814 { 815 "blocksmined": 9001, 816 "cpuhashrate": 1337, 817 "cpumining": false, 818 "staleblocksmined": 0, 819 } 820 ``` 821 822 #### /miner/start [GET] 823 824 starts a single threaded cpu miner. Does nothing if the cpu miner is already 825 running. 826 827 ###### Response 828 standard success or error response. See 829 [#standard-responses](#standard-responses). 830 831 #### /miner/stop [GET] 832 833 stops the cpu miner. Does nothing if the cpu miner is not running. 834 835 ###### Response 836 standard success or error response. See 837 [#standard-responses](#standard-responses). 838 839 #### /miner/header [GET] 840 841 provides a block header that is ready to be grinded on for work. 842 843 ###### Byte Response 844 845 For efficiency the header for work is returned as a raw byte encoding of the 846 header, rather than encoded to JSON. Refer to 847 [Miner.md#byte-response](/doc/api/Miner.md#byte-response) for a detailed 848 description of the byte encoding. 849 850 #### /miner/header [POST] 851 852 submits a header that has passed the POW. 853 854 ###### Request Body Bytes 855 856 For efficiency headers are submitted as raw byte encodings of the header in the 857 body of the request, rather than as a query string parameter or path parameter. 858 The request body should contain only the 80 bytes of the encoded header. The 859 encoding is the same encoding used in `/miner/header [GET]` endpoint. Refer to 860 [Miner.md#byte-response](/doc/api/Miner.md#byte-response) for a detailed 861 description of the byte encoding. 862 863 Renter 864 ------ 865 866 | Route | HTTP verb | 867 | --------------------------------------------------------------------------| --------- | 868 | [/renter](#renter-get) | GET | 869 | [/renter](#renter-post) | POST | 870 | [/renter/contract/cancel](#rentercontractcancel-post) | POST | 871 | [/renter/contracts](#rentercontracts-get) | GET | 872 | [/renter/downloads](#renterdownloads-get) | GET | 873 | [/renter/downloads/clear](#renterdownloadsclear-post) | POST | 874 | [/renter/prices](#renterprices-get) | GET | 875 | [/renter/files](#renterfiles-get) | GET | 876 | [/renter/file/*___siapath___](#renterfile___siapath___-get) | GET | 877 | [/renter/file/*___siapath___](#renterfile___siapath___-post) | POST | 878 | [/renter/delete/*___siapath___](#renterdeletesiapath-post) | POST | 879 | [/renter/download/*___siapath___](#renterdownloadsiapath-get) | GET | 880 | [/renter/downloadasync/*___siapath___](#renterdownloadasyncsiapath-get) | GET | 881 | [/renter/stream/*___siapath___](#renterstreamsiapath-get) | GET | 882 | [/renter/upload/*___siapath___](#renteruploadsiapath-post) | POST | 883 884 For examples and detailed descriptions of request and response parameters, 885 refer to [Renter.md](/doc/api/Renter.md). 886 887 #### /renter [GET] 888 889 returns the current settings along with metrics on the renter's spending. 890 891 ###### JSON Response [(with comments)](/doc/api/Renter.md#json-response) 892 ```javascript 893 { 894 "settings": { 895 "allowance": { 896 "funds": "1234", // hastings 897 "hosts": 24, 898 "period": 6048, // blocks 899 "renewwindow": 3024 // blocks 900 }, 901 "maxuploadspeed": 1234, // BPS 902 "maxdownloadspeed": 1234, // BPS 903 "streamcachesize": 4 904 }, 905 "financialmetrics": { 906 "contractfees": "1234", // hastings 907 "contractspending": "1234", // hastings (deprecated, now totalallocated) 908 "downloadspending": "5678", // hastings 909 "storagespending": "1234", // hastings 910 "totalallocated": "1234", // hastings 911 "uploadspending": "5678", // hastings 912 "unspent": "1234" // hastings 913 }, 914 "currentperiod": 200 915 } 916 ``` 917 918 #### /renter [POST] 919 920 modify settings that control the renter's behavior. 921 922 ###### Query String Parameters [(with comments)](/doc/api/Renter.md#query-string-parameters) 923 ``` 924 funds // hastings 925 hosts 926 period // block height 927 renewwindow // block height 928 maxdownloadspeed // bytes per second 929 maxuploadspeed // bytes per second 930 streamcachesize // number of data chunks cached when streaming 931 ``` 932 933 ###### Response 934 standard success or error response. See 935 [#standard-responses](#standard-responses). 936 937 #### /renter/contract/cancel [POST] 938 939 cancels a specific contract of the Renter. 940 941 ###### Query String Parameters [(with comments)](/doc/api/Renter.md#query-string-parameter) 942 ``` 943 // ID of the file contract 944 id 945 ``` 946 947 ###### Response 948 standard success or error response. See 949 [API.md#standard-responses](/doc/API.md#standard-responses). 950 951 #### /renter/contracts [GET] 952 953 returns the renter's contracts. Active contracts are contracts that the Renter 954 is currently using to store, upload, and download data, and are returned by 955 default. Inactive contracts are contracts that are in the current period but are 956 marked as not good for renew, these contracts have the potential to become 957 active again but currently are not storing data. Expired contracts are 958 contracts not in the current period, where not more data is being stored and 959 excess funds have been released to the renter. 960 961 ###### Contract Parameters [(with comments)](/doc/api/Renter.md#contract-parameters) 962 ``` 963 inactive // true or false - Optional 964 expired // true or false - Optional 965 ``` 966 967 ###### JSON Response [(with comments)](/doc/api/Renter.md#json-response-1) 968 ```javascript 969 { 970 "activecontracts": [ 971 { 972 "downloadspending": "1234", // hastings 973 "endheight": 50000, // block height 974 "fees": "1234", // hastings 975 "hostpublickey": { 976 "algorithm": "ed25519", 977 "key": "RW50cm9weSBpc24ndCB3aGF0IGl0IHVzZWQgdG8gYmU=" 978 }, 979 "id": "1234567890abcdef0123456789abcdef0123456789abcdef0123456789abcdef", 980 "lasttransaction": {}, 981 "netaddress": "12.34.56.78:9", 982 "renterfunds": "1234", // hastings 983 "size": 8192, // bytes 984 "startheight": 50000, // block height 985 "StorageSpending": "1234", 986 "storagespending": "1234", // hastings 987 "totalcost": "1234", // hastings 988 "uploadspending": "1234" // hastings 989 "goodforupload": true, 990 "goodforrenew": false, 991 } 992 ], 993 "inactivecontracts": [], 994 "expiredcontracts": [], 995 } 996 ``` 997 998 #### /renter/downloads [GET] 999 1000 lists all files in the download queue. 1001 1002 ###### JSON Response [(with comments)](/doc/api/Renter.md#json-response-2) 1003 ```javascript 1004 { 1005 "downloads": [ 1006 { 1007 "destination": "/home/users/alice/bar.txt", 1008 "destinationtype": "file", 1009 "length": 8192, 1010 "offset": 2000, 1011 "siapath": "foo/bar.txt", 1012 1013 "completed": true, 1014 "endtime": "2009-11-10T23:10:00Z", // RFC 3339 time 1015 "error": "", 1016 "received": 8192, 1017 "starttime": "2009-11-10T23:00:00Z", // RFC 3339 time 1018 "totaldatatransfered": 10031 1019 } 1020 ] 1021 } 1022 ``` 1023 1024 #### /renter/downloads/clear [POST] 1025 1026 Clears the download history of the renter for a range of unix time stamps. Both 1027 parameters are optional, if no parameters are provided, the entire download 1028 history will be cleared. To clear a single download, provide the timestamp for 1029 the download as both parameters. Providing only the before parameter will clear 1030 all downloads older than the timestamp. Conversely, providing only the after 1031 parameter will clear all downloads newer than the timestamp. 1032 1033 ###### Timestamp Parameters [(with comments)](/doc/api/Renter.md#timestamp-parameters) 1034 ``` 1035 before // Optional 1036 after // Optional 1037 ``` 1038 1039 ###### Response 1040 standard success or error response. See 1041 [#standard-responses](#standard-responses). 1042 1043 #### /renter/files [GET] 1044 1045 lists the status of all files. 1046 1047 ###### JSON Response [(with comments)](/doc/api/Renter.md#json-response-3) 1048 ```javascript 1049 { 1050 "files": [ 1051 { 1052 "siapath": "foo/bar.txt", 1053 "localpath": "/home/foo/bar.txt", 1054 "filesize": 8192, // bytes 1055 "available": true, 1056 "renewing": true, 1057 "redundancy": 5, 1058 "bytesuploaded": 209715200, // total bytes uploaded 1059 "uploadprogress": 100, // percent 1060 "expiration": 60000 1061 } 1062 ] 1063 } 1064 ``` 1065 1066 #### /renter/file/*__siapath__ [GET] 1067 1068 lists the status of specified file. 1069 1070 ###### JSON Response [(with comments)](/doc/api/Renter.md#json-response-4) 1071 ```javascript 1072 { 1073 "file": { 1074 "siapath": "foo/bar.txt", 1075 "localpath": "/home/foo/bar.txt", 1076 "filesize": 8192, // bytes 1077 "available": true, 1078 "renewing": true, 1079 "redundancy": 5, 1080 "bytesuploaded": 209715200, // total bytes uploaded 1081 "uploadprogress": 100, // percent 1082 "expiration": 60000 1083 } 1084 } 1085 ``` 1086 1087 #### /renter/prices [GET] 1088 1089 lists the estimated prices of performing various storage and data operations. An 1090 allowance can be submitted to provide a more personalized estimate. If no 1091 allowance is submitted then the current set allowance will be used, if there is 1092 no allowance set then sane defaults will be used. Submitting an allowance is 1093 optional, but when submitting an allowance all the components of the allowance 1094 are required. The allowance used to create the estimate is returned with the 1095 estimate. 1096 1097 ###### Query String Parameters [(with comments)](/doc/api/Renter.md#query-string-parameters-5) 1098 ``` 1099 all optional or all required 1100 1101 funds // hastings 1102 hosts 1103 period // block height 1104 renewwindow // block height 1105 ``` 1106 1107 ###### JSON Response [(with comments)](/doc/api/Renter.md#json-response-5) 1108 ```javascript 1109 { 1110 "downloadterabyte": "1234", // hastings 1111 "formcontracts": "1234", // hastings 1112 "storageterabytemonth": "1234", // hastings 1113 "uploadterabyte": "1234", // hastings 1114 "funds": "1234", // hastings 1115 "hosts": 24, 1116 "period": 6048, // blocks 1117 "renewwindow": 3024 // blocks 1118 } 1119 ``` 1120 1121 #### /renter/file/*___siapath___ [POST] 1122 1123 endpoint for changing file metadata. 1124 1125 ###### Path Parameters [(with comments)](/doc/api/Renter.md#path-parameters-3) 1126 ``` 1127 // SiaPath of the file on the network. The path must be non-empty, may not 1128 // include any path traversal strings ("./", "../"), and may not begin with a 1129 // forward-slash character. 1130 *siapath 1131 ``` 1132 1133 ###### Query String Parameters [(with comments)](/doc/api/Renter.md#query-string-parameters-3) 1134 ``` 1135 // If provided, this parameter changes the tracking path of a file to the 1136 // specified path. Useful if moving the file to a different location on disk. 1137 trackingpath 1138 ``` 1139 1140 ###### Response 1141 standard success or error response. See 1142 [#standard-responses](#standard-responses). 1143 1144 #### /renter/delete/*___siapath___ [POST] 1145 1146 deletes a renter file entry. Does not delete any downloads or original files, 1147 only the entry in the renter. 1148 1149 ###### Path Parameters [(with comments)](/doc/api/Renter.md#path-parameters) 1150 ``` 1151 *siapath 1152 ``` 1153 1154 ###### Response 1155 standard success or error response. See 1156 [#standard-responses](#standard-responses). 1157 1158 #### /renter/download/*___siapath___ [GET] 1159 1160 downloads a file to the local filesystem. The call will block until the file 1161 has been downloaded. 1162 1163 ###### Path Parameters [(with comments)](/doc/api/Renter.md#path-parameters-1) 1164 ``` 1165 *siapath 1166 ``` 1167 1168 ###### Query String Parameters [(with comments)](/doc/api/Renter.md#query-string-parameters-1) 1169 ``` 1170 async 1171 destination 1172 httpresp 1173 length 1174 offset 1175 ``` 1176 1177 ###### Response 1178 standard success or error response. See 1179 [#standard-responses](#standard-responses). 1180 1181 #### /renter/downloadasync/*___siapath___ [GET] 1182 1183 downloads a file to the local filesystem. The call will return immediately. 1184 1185 ###### Path Parameters [(with comments)](/doc/api/Renter.md#path-parameters-2) 1186 ``` 1187 *siapath 1188 ``` 1189 1190 ###### Query String Parameters [(with comments)](/doc/api/Renter.md#query-string-parameters-2) 1191 ``` 1192 destination 1193 ``` 1194 1195 ###### Response 1196 standard success or error response. See 1197 [#standard-responses](#standard-responses). 1198 1199 #### /renter/rename/*___siapath___ [POST] 1200 1201 renames a file. Does not rename any downloads or source files, only renames the 1202 entry in the renter. An error is returned if `siapath` does not exist or 1203 `newsiapath` already exists. 1204 1205 ###### Path Parameters [(with comments)](/doc/api/Renter.md#path-parameters-3) 1206 ``` 1207 *siapath 1208 ``` 1209 1210 ###### Query String Parameters [(with comments)](/doc/api/Renter.md#query-string-parameters-3) 1211 ``` 1212 newsiapath 1213 ``` 1214 1215 ###### Response 1216 standard success or error response. See 1217 [#standard-responses](#standard-responses). 1218 1219 #### /renter/stream/*___siapath___ [GET] 1220 1221 downloads a file using http streaming. This call blocks until the data is 1222 received. 1223 The streaming endpoint also uses caching internally to prevent siad from 1224 re-downloading the same chunk multiple times when only parts of a file are 1225 requested at once. This might lead to a substantial increase in ram usage and 1226 therefore it is not recommended to stream multiple files in parallel at the 1227 moment. This restriction will be removed together with the caching once partial 1228 downloads are supported in the future. If you want to stream multiple files you 1229 should increase the size of the Renter's `streamcachesize` to at least 2x the 1230 number of files you are steaming. 1231 1232 ###### Path Parameters [(with comments)](/doc/api/Renter.md#path-parameters-1) 1233 ``` 1234 *siapath 1235 ``` 1236 1237 ###### Response 1238 standard success with the requested data in the body or error response. See 1239 [#standard-responses](#standard-responses). 1240 1241 #### /renter/upload/*___siapath___ [POST] 1242 1243 uploads a file to the network from the local filesystem. 1244 1245 ###### Path Parameters [(with comments)](/doc/api/Renter.md#path-parameters-4) 1246 ``` 1247 *siapath 1248 ``` 1249 1250 ###### Query String Parameters [(with comments)](/doc/api/Renter.md#query-string-parameters-4) 1251 ``` 1252 datapieces // int 1253 paritypieces // int 1254 source // string - a filepath 1255 ``` 1256 1257 ###### Response 1258 standard success or error response. See 1259 [#standard-responses](#standard-responses). 1260 1261 1262 Transaction Pool 1263 ------ 1264 1265 | Route | HTTP verb | 1266 | ------------------------------------------- | --------- | 1267 | [/tpool/confirmed/:id](#tpoolconfirmed-get) | GET | 1268 | [/tpool/fee](#tpoolfee-get) | GET | 1269 | [/tpool/raw/:id](#tpoolraw-get) | GET | 1270 | [/tpool/raw](#tpoolraw-post) | POST | 1271 1272 #### /tpool/confirmed/:id [GET] 1273 1274 returns whether the requested transaction has been seen on the blockchain. 1275 Note, however, that the block containing the transaction may later be 1276 invalidated by a reorg. 1277 1278 ###### JSON Response 1279 ```javascript 1280 { 1281 "confirmed": true 1282 } 1283 ``` 1284 1285 #### /tpool/fee [GET] 1286 1287 returns the minimum and maximum estimated fees expected by the transaction pool. 1288 1289 ###### JSON Response [(with comments)](/doc/api/Transactionpool.md#json-response-1) 1290 ```javascript 1291 { 1292 "minimum": "1234", // hastings / byte 1293 "maximum": "5678" // hastings / byte 1294 } 1295 ``` 1296 1297 #### /tpool/raw/:id [GET] 1298 1299 returns the ID for the requested transaction and its raw encoded parents and transaction data. 1300 1301 ###### JSON Response [(with comments)](/doc/api/Transactionpool.md#json-response-2) 1302 ```javascript 1303 { 1304 // id of the transaction 1305 "id": "124302d30a219d52f368ecd94bae1bfb922a3e45b6c32dd7fb5891b863808788", 1306 1307 // raw, base64 encoded transaction data 1308 "transaction": "AQAAAAAAAADBM1ca/FyURfizmSukoUQ2S0GwXMit1iNSeYgrnhXOPAAAAAAAAAAAAQAAAAAAAABlZDI1NTE5AAAAAAAAAAAAIAAAAAAAAACdfzoaJ1MBY7L0fwm7O+BoQlFkkbcab5YtULa6B9aecgEAAAAAAAAAAQAAAAAAAAAMAAAAAAAAAAM7Ljyf0IA86AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAACgAAAAAAAACe0ZTbGbI4wAAAAAAAAAAAAAABAAAAAAAAAMEzVxr8XJRF+LOZK6ShRDZLQbBcyK3WI1J5iCueFc48AAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAA+z4P1wc98IqKxykTSJxiVT+BVbWezIBnIBO1gRRlLq2x/A+jIc6G7/BA5YNJRbdnqPHrzsZvkCv4TKYd/XzwBA==", 1309 "parents": "AQAAAAAAAAABAAAAAAAAAJYYmFUdXXfLQ2p6EpF+tcqM9M4Pw5SLSFHdYwjMDFCjAAAAAAAAAAABAAAAAAAAAGVkMjU1MTkAAAAAAAAAAAAgAAAAAAAAAAHONvdzzjHfHBx6psAN8Z1rEVgqKPZ+K6Bsqp3FbrfjAQAAAAAAAAACAAAAAAAAAAwAAAAAAAAAAzvNDjSrme8gwAAA4w8ODnW8DxbOV/JribivvTtjJ4iHVOug0SXJc31BdSINAAAAAAAAAAPGHY4699vggx5AAAC2qBhm5vwPaBsmwAVPho/1Pd8ecce/+BGv4UimnEPzPQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAACWGJhVHV13y0NqehKRfrXKjPTOD8OUi0hR3WMIzAxQowAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAABnt64wN1qxym/CfiMgOx5fg/imVIEhY+4IiiM7gwvSx8qtqKniOx50ekrGv8B+gTKDXpmm2iJibWTI9QLZHWAY=", 1310 } 1311 ``` 1312 1313 #### /tpool/raw [POST] 1314 1315 submits a raw transaction to the transaction pool, broadcasting it to the transaction pool's peers. 1316 1317 ###### Query String Parameters [(with comments)](/doc/api/Transactionpool.md#query-string-parameters) 1318 1319 ``` 1320 parents string // JSON- or base64-encoded transaction parents 1321 transaction string // JSON- or base64-encoded transaction 1322 ``` 1323 1324 ###### Response 1325 standard success or error response. See 1326 [#standard-responses](#standard-responses). 1327 1328 1329 Wallet 1330 ------ 1331 1332 | Route | HTTP verb | 1333 | ----------------------------------------------------------------------- | --------- | 1334 | [/wallet](#wallet-get) | GET | 1335 | [/wallet/033x](#wallet033x-post) | POST | 1336 | [/wallet/address](#walletaddress-get) | GET | 1337 | [/wallet/addresses](#walletaddresses-get) | GET | 1338 | [/wallet/backup](#walletbackup-get) | GET | 1339 | [/wallet/changepassword](#walletchangepassword-post) | POST | 1340 | [/wallet/init](#walletinit-post) | POST | 1341 | [/wallet/init/seed](#walletinitseed-post) | POST | 1342 | [/wallet/lock](#walletlock-post) | POST | 1343 | [/wallet/seed](#walletseed-post) | POST | 1344 | [/wallet/seeds](#walletseeds-get) | GET | 1345 | [/wallet/siacoins](#walletsiacoins-post) | POST | 1346 | [/wallet/siafunds](#walletsiafunds-post) | POST | 1347 | [/wallet/siagkey](#walletsiagkey-post) | POST | 1348 | [/wallet/sign](#walletsign-post) | POST | 1349 | [/wallet/sweep/seed](#walletsweepseed-post) | POST | 1350 | [/wallet/transaction/:___id___](#wallettransactionid-get) | GET | 1351 | [/wallet/transactions](#wallettransactions-get) | GET | 1352 | [/wallet/transactions/:___addr___](#wallettransactionsaddr-get) | GET | 1353 | [/wallet/unlock](#walletunlock-post) | POST | 1354 | [/wallet/unlockconditions](#walletunlockconditions-post) | POST | 1355 | [/wallet/unlockconditions/:___addr___](#walletunlockconditionsaddr-get) | GET | 1356 | [/wallet/unspent](#walletunspent-get) | GET | 1357 | [/wallet/verify/address/:___addr___](#walletverifyaddressaddr-get) | GET | 1358 | [/wallet/watch](#walletwatch-get) | GET | 1359 | [/wallet/watch](#walletwatch-post) | POST | 1360 1361 For examples and detailed descriptions of request and response parameters, 1362 refer to [Wallet.md](/doc/api/Wallet.md). 1363 1364 #### /wallet [GET] 1365 1366 returns basic information about the wallet, such as whether the wallet is 1367 locked or unlocked. 1368 1369 ###### JSON Response [(with comments)](/doc/api/Wallet.md#json-response) 1370 ```javascript 1371 { 1372 "encrypted": true, 1373 "unlocked": true, 1374 "rescanning": false, 1375 1376 "confirmedsiacoinbalance": "123456", // hastings, big int 1377 "unconfirmedoutgoingsiacoins": "0", // hastings, big int 1378 "unconfirmedincomingsiacoins": "789", // hastings, big int 1379 1380 "siafundbalance": "1", // siafunds, big int 1381 "siacoinclaimbalance": "9001", // hastings, big int 1382 1383 "dustthreshold": "1234", // hastings / byte, big int 1384 } 1385 ``` 1386 1387 #### /wallet/033x [POST] 1388 1389 loads a v0.3.3.x wallet into the current wallet, harvesting all of the secret 1390 keys. All spendable addresses in the loaded wallet will become spendable from 1391 the current wallet. 1392 1393 ###### Query String Parameters [(with comments)](/doc/api/Wallet.md#query-string-parameters) 1394 ``` 1395 source 1396 encryptionpassword 1397 ``` 1398 1399 ###### Response 1400 standard success or error response. See 1401 [#standard-responses](#standard-responses). 1402 1403 #### /wallet/address [GET] 1404 1405 gets a new address from the wallet generated by the primary seed. An error will 1406 be returned if the wallet is locked. 1407 1408 ###### JSON Response [(with comments)](/doc/api/Wallet.md#json-response-1) 1409 ```javascript 1410 { 1411 "address": "1234567890abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789ab" 1412 } 1413 ``` 1414 1415 #### /wallet/addresses [GET] 1416 1417 fetches the list of addresses from the wallet. If the wallet has not been 1418 created or unlocked, no addresses will be returned. After the wallet is 1419 unlocked, this call will continue to return its addresses even after the 1420 wallet is locked again. 1421 1422 ###### JSON Response [(with comments)](/doc/api/Wallet.md#json-response-2) 1423 ```javascript 1424 { 1425 "addresses": [ 1426 "1234567890abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789ab", 1427 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", 1428 "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb" 1429 ] 1430 } 1431 ``` 1432 1433 #### /wallet/backup [GET] 1434 1435 creates a backup of the wallet settings file. Though this can easily be done 1436 manually, the settings file is often in an unknown or difficult to find 1437 location. The /wallet/backup call can spare users the trouble of needing to 1438 find their wallet file. 1439 1440 ###### Parameters [(with comments)](/doc/api/Wallet.md#query-string-parameters-1) 1441 ``` 1442 destination 1443 ``` 1444 1445 ###### Response 1446 standard success or error response. See 1447 [#standard-responses](#standard-responses). 1448 1449 #### /wallet/changepassword [POST] 1450 1451 changes the wallet's encryption key. 1452 1453 ###### Query String Parameters [(with comments)](/doc/api/Wallet.md#query-string-parameters-12) 1454 ``` 1455 encryptionpassword 1456 newpassword 1457 ``` 1458 1459 ###### Response 1460 standard success or error response. See 1461 [#standard-responses](#standard-responses). 1462 1463 #### /wallet/init [POST] 1464 1465 initializes the wallet. After the wallet has been initialized once, it does 1466 not need to be initialized again, and future calls to /wallet/init will return 1467 an error. The encryption password is provided by the api call. If the password 1468 is blank, then the password will be set to the same as the seed. 1469 1470 ###### Query String Parameters [(with comments)](/doc/api/Wallet.md#query-string-parameters-2) 1471 ``` 1472 encryptionpassword 1473 dictionary // Optional, default is english. 1474 force // Optional, when set to true it will destroy an existing wallet and reinitialize a new one. 1475 ``` 1476 1477 ###### JSON Response [(with comments)](/doc/api/Wallet.md#json-response-3) 1478 ```javascript 1479 { 1480 "primaryseed": "hello world hello world hello world hello world hello world hello world hello world hello world hello world hello world hello world hello world hello world hello world hello" 1481 } 1482 ``` 1483 1484 #### /wallet/init/seed [POST] 1485 1486 initializes the wallet using a preexisting seed. After the wallet has been 1487 initialized once, it does not need to be initialized again, and future calls 1488 to /wallet/init/seed will return an error. The encryption password is provided 1489 by the api call. If the password is blank, then the password will be set to 1490 the same as the seed. Note that loading a preexisting seed requires scanning 1491 the blockchain to determine how many keys have been generated from the seed. 1492 For this reason, /wallet/init/seed can only be called if the blockchain is 1493 synced. 1494 1495 ###### Query String Parameters [(with comments)](/doc/api/Wallet.md#query-string-parameters-3) 1496 ``` 1497 encryptionpassword 1498 dictionary // Optional, default is english. 1499 seed 1500 force // Optional, when set to true it will destroy an existing wallet and reinitialize a new one. 1501 ``` 1502 1503 ###### Response 1504 standard success or error response. See 1505 [#standard-responses](#standard-responses). 1506 1507 #### /wallet/seed [POST] 1508 1509 gives the wallet a seed to track when looking for incoming transactions. The 1510 wallet will be able to spend outputs related to addresses created by the seed. 1511 The seed is added as an auxiliary seed, and does not replace the primary seed. 1512 Only the primary seed will be used for generating new addresses. 1513 1514 ###### Query String Parameters [(with comments)](/doc/api/Wallet.md#query-string-parameters-4) 1515 ``` 1516 encryptionpassword 1517 dictionary 1518 seed 1519 ``` 1520 1521 ###### Response 1522 standard success or error response. See 1523 [#standard-responses](#standard-responses). 1524 1525 #### /wallet/seeds [GET] 1526 1527 returns the list of seeds in use by the wallet. The primary seed is the only 1528 seed that gets used to generate new addresses. This call is unavailable when 1529 the wallet is locked. 1530 1531 ###### Query String Parameters [(with comments)](/doc/api/Wallet.md#query-string-parameters-5) 1532 ``` 1533 dictionary 1534 ``` 1535 1536 ###### JSON Response [(with comments)](/doc/api/Wallet.md#json-response-4) 1537 ```javascript 1538 { 1539 "primaryseed": "hello world hello world hello world hello world hello world hello world hello world hello world hello world hello world hello world hello world hello world hello world hello", 1540 "addressesremaining": 2500, 1541 "allseeds": [ 1542 "hello world hello world hello world hello world hello world hello world hello world hello world hello world hello world hello world hello world hello world hello world hello", 1543 "foo bar foo bar foo bar foo bar foo bar foo bar foo bar foo bar foo bar foo bar foo bar foo bar foo bar foo bar foo", 1544 ] 1545 } 1546 ``` 1547 1548 #### /wallet/siacoins [POST] 1549 1550 sends siacoins to an address or set of addresses. The outputs are arbitrarily 1551 selected from addresses in the wallet. If 'outputs' is supplied, 'amount' and 1552 'destination' must be empty. 1553 1554 ###### Query String Parameters [(with comments)](/doc/api/Wallet.md#query-string-parameters-6) 1555 ``` 1556 amount // hastings 1557 destination // address 1558 outputs // JSON array of {unlockhash, value} pairs 1559 ``` 1560 1561 ###### JSON Response [(with comments)](/doc/api/Wallet.md#json-response-5) 1562 ```javascript 1563 { 1564 "transactionids": [ 1565 "1234567890abcdef0123456789abcdef0123456789abcdef0123456789abcdef", 1566 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", 1567 "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb" 1568 ] 1569 } 1570 ``` 1571 1572 #### /wallet/siafunds [POST] 1573 1574 sends siafunds to an address. The outputs are arbitrarily selected from 1575 addresses in the wallet. Any siacoins available in the siafunds being sent (as 1576 well as the siacoins available in any siafunds that end up in a refund address) 1577 will become available to the wallet as siacoins after 144 confirmations. To 1578 access all of the siacoins in the siacoin claim balance, send all of the 1579 siafunds to an address in your control (this will give you all the siacoins, 1580 while still letting you control the siafunds). 1581 1582 ###### Query String Parameters [(with comments)](/doc/api/Wallet.md#query-string-parameters-7) 1583 ``` 1584 amount // siafunds 1585 destination // address 1586 ``` 1587 1588 ###### JSON Response [(with comments)](/doc/api/Wallet.md#json-response-6) 1589 ```javascript 1590 { 1591 "transactionids": [ 1592 "1234567890abcdef0123456789abcdef0123456789abcdef0123456789abcdef", 1593 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", 1594 "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb" 1595 ] 1596 } 1597 ``` 1598 1599 #### /wallet/siagkey [POST] 1600 1601 loads a key into the wallet that was generated by siag. Most siafunds are 1602 currently in addresses created by siag. 1603 1604 ###### Query String Parameters [(with comments)](/doc/api/Wallet.md#query-string-parameters-8) 1605 ``` 1606 encryptionpassword 1607 keyfiles 1608 ``` 1609 1610 ###### Response 1611 standard success or error response. See 1612 [#standard-responses](#standard-responses). 1613 1614 #### /wallet/sign [POST] 1615 1616 Function: Sign a transaction. The wallet will attempt to sign each input 1617 specified. 1618 1619 ###### Request Body 1620 ``` 1621 { 1622 "transaction": { }, // types.Transaction; see Wallet.md for all fields 1623 "tosign": [ 1624 "1234567890abcdef0123456789abcdef0123456789abcdef0123456789abcdef", 1625 "abcdef0123456789abcdef0123456789abcd1234567890ef0123456789abcdef" 1626 ] 1627 } 1628 ``` 1629 1630 ###### Response 1631 ```javascript 1632 { 1633 "transaction": { } // types.Transaction; see Wallet.md for all fields 1634 } 1635 ``` 1636 1637 #### /wallet/sweep/seed [POST] 1638 1639 Function: Scan the blockchain for outputs belonging to a seed and send them to 1640 an address owned by the wallet. 1641 1642 ###### Query String Parameters [(with comments)](/doc/api/Wallet.md#query-string-parameters-9) 1643 ``` 1644 dictionary // Optional, default is english. 1645 seed 1646 ``` 1647 1648 ###### JSON Response [(with comments)](/doc/api/Wallet.md#json-response-7) 1649 ```javascript 1650 { 1651 "coins": "123456", // hastings, big int 1652 "funds": "1", // siafunds, big int 1653 } 1654 ``` 1655 1656 #### /wallet/lock [POST] 1657 1658 locks the wallet, wiping all secret keys. After being locked, the keys are 1659 encrypted. Queries for the seed, to send siafunds, and related queries become 1660 unavailable. Queries concerning transaction history and balance are still 1661 available. 1662 1663 ###### Response 1664 standard success or error response. See 1665 [#standard-responses](#standard-responses). 1666 1667 #### /wallet/transaction/:___id___ [GET] 1668 1669 gets the transaction associated with a specific transaction id. 1670 1671 ###### Path Parameters [(with comments)](/doc/api/Wallet.md#path-parameters) 1672 ``` 1673 :id 1674 ``` 1675 1676 ###### JSON Response [(with comments)](/doc/api/Wallet.md#json-response-8) 1677 ```javascript 1678 { 1679 "transaction": { 1680 "transaction": { 1681 // See types.Transaction in https://gitlab.com/SiaPrime/SiaPrime/blob/master/types/transactions.go 1682 }, 1683 "transactionid": "1234567890abcdef0123456789abcdef0123456789abcdef0123456789abcdef", 1684 "confirmationheight": 50000, 1685 "confirmationtimestamp": 1257894000, 1686 "inputs": [ 1687 { 1688 "parentid": "1234567890abcdef0123456789abcdef0123456789abcdef0123456789abcdef", 1689 "fundtype": "siacoin input", 1690 "walletaddress": false, 1691 "relatedaddress": "1234567890abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789ab", 1692 "value": "1234", // hastings or siafunds, depending on fundtype, big int 1693 } 1694 ], 1695 "outputs": [ 1696 { 1697 "id": "1234567890abcdef0123456789abcdef0123456789abcdef0123456789abcdef", 1698 "fundtype": "siacoin output", 1699 "maturityheight": 50000, 1700 "walletaddress": false, 1701 "relatedaddress": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", 1702 "value": "1234", // hastings or siafunds, depending on fundtype, big int 1703 } 1704 ] 1705 } 1706 } 1707 ``` 1708 1709 #### /wallet/transactions [GET] 1710 1711 returns a list of transactions related to the wallet in chronological order. 1712 1713 ###### Query String Parameters [(with comments)](/doc/api/Wallet.md#query-string-parameters-10) 1714 ``` 1715 startheight // block height 1716 endheight // block height 1717 ``` 1718 1719 ###### JSON Response [(with comments)](/doc/api/Wallet.md#json-response-9) 1720 ```javascript 1721 { 1722 "confirmedtransactions": [ 1723 { 1724 // See the documentation for '/wallet/transaction/:id' for more information. 1725 } 1726 ], 1727 "unconfirmedtransactions": [ 1728 { 1729 // See the documentation for '/wallet/transaction/:id' for more information. 1730 } 1731 ] 1732 } 1733 ``` 1734 1735 #### /wallet/transactions/:___addr___ [GET] 1736 1737 returns all of the transactions related to a specific address. 1738 1739 ###### Path Parameters [(with comments)](/doc/api/Wallet.md#path-parameters-1) 1740 ``` 1741 :addr 1742 ``` 1743 1744 ###### JSON Response [(with comments)](/doc/api/Wallet.md#json-response-10) 1745 ```javascript 1746 { 1747 "transactions": [ 1748 { 1749 // See the documentation for '/wallet/transaction/:id' for more information. 1750 } 1751 ] 1752 } 1753 ``` 1754 1755 #### /wallet/unlock [POST] 1756 1757 unlocks the wallet. The wallet is capable of knowing whether the correct 1758 password was provided. 1759 1760 ###### Query String Parameters [(with comments)](/doc/api/Wallet.md#query-string-parameters-11) 1761 ``` 1762 encryptionpassword 1763 ``` 1764 1765 ###### Response 1766 standard success or error response. See 1767 [#standard-responses](#standard-responses). 1768 1769 #### /wallet/unlockconditions/___:addr___ [GET] 1770 1771 returns the unlock conditions of :addr, if they are known to the wallet. 1772 1773 ###### JSON Response [(with comments)](/doc/api/Wallet.md#json-response-11) 1774 ```javascript 1775 { 1776 "unlockconditions": { 1777 "timelock": 0, 1778 "publickeys": [{ 1779 "algorithm": "ed25519", 1780 "key": "/XUGj8PxMDkqdae6Js6ubcERxfxnXN7XPjZyANBZH1I=" 1781 }], 1782 "signaturesrequired": 1 1783 } 1784 } 1785 ``` 1786 1787 #### /wallet/unspent [GET] 1788 1789 returns a list of outputs that the wallet can spend. 1790 1791 ###### JSON Response [(with comments)](/doc/api/Wallet.md#json-response-11) 1792 ```javascript 1793 { 1794 "outputs": [ 1795 { 1796 "id": "1234567890abcdef0123456789abcdef0123456789abcdef0123456789abcdef", 1797 "fundtype": "siacoin output", 1798 "confirmationheight": 50000, 1799 "unlockhash": "1234567890abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789ab", 1800 "value": "1234", // big int 1801 "iswatchonly": false 1802 } 1803 ] 1804 } 1805 ``` 1806 1807 #### /wallet/verify/address/:addr [GET] 1808 1809 takes the address specified by :addr and returns a JSON response indicating if the address is valid. 1810 1811 ###### JSON Response [(with comments)](/doc/api/Wallet.md#json-response-11) 1812 ```javascript 1813 { 1814 "valid": true 1815 } 1816 ``` 1817 1818 #### /wallet/watch [GET] 1819 1820 returns the set of addresses that the wallet is watching. 1821 1822 ###### JSON Response [(with comments)](/doc/api/Wallet.md#json-response-12) 1823 ```javascript 1824 { 1825 "addresses": [ 1826 "1234567890abcdef0123456789abcdef0123456789abcdef0123456789abcdef", 1827 "abcdef0123456789abcdef0123456789abcd1234567890ef0123456789abcdef" 1828 ] 1829 } 1830 ``` 1831 1832 #### /wallet/watch [POST] 1833 1834 updates the set of addresses watched by the wallet. Outputs owned by the 1835 addresses will be reported in /wallet/unspent. 1836 1837 ###### Request Body 1838 ``` 1839 { 1840 "addresses": [ 1841 "1234567890abcdef0123456789abcdef0123456789abcdef0123456789abcdef", 1842 "abcdef0123456789abcdef0123456789abcd1234567890ef0123456789abcdef" 1843 ], 1844 "remove": false, 1845 "unused": true, 1846 } 1847 1848 ``` 1849 1850 ###### Response 1851 standard success or error response. See 1852 [#standard-responses](#standard-responses).