github.com/muhammedhassanm/blockchain@v0.0.0-20200120143007-697261defd4d/sawtooth-core-master/rest_api/openapi.yaml (about) 1 # Copyright 2017 Intel Corporation 2 # 3 # Licensed under the Apache License, Version 2.0 (the "License"); 4 # you may not use this file except in compliance with the License. 5 # You may obtain a copy of the License at 6 # 7 # http://www.apache.org/licenses/LICENSE-2.0 8 # 9 # Unless required by applicable law or agreed to in writing, software 10 # distributed under the License is distributed on an "AS IS" BASIS, 11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 # See the License for the specific language governing permissions and 13 # limitations under the License. 14 # ------------------------------------------------------------------------------ 15 16 swagger: '2.0' 17 18 info: 19 version: "0.8.0" 20 title: Sawtooth REST API 21 description: | 22 _This HTTP pragmatic REST API is built on top of Sawtooth's 23 existing ZMQ/Protobuf infrastructure, simplifying client 24 interaction with the blockchain by exposing endpoints that 25 use common HTTP/JSON standards._ 26 27 paths: 28 /batches: 29 post: 30 summary: Sends a BatchList to the validator 31 description: | 32 Accepts a protobuf formatted `BatchList` as an octet-stream binary 33 file and submits it to the validator to be committed. 34 35 The API will return immediately with a status of `202`. There will be 36 no `data` object, only a `link` to a `/batch_statuses` endpoint to be 37 polled to check the status of submitted batches. 38 consumes: 39 - application/octet-stream 40 parameters: 41 - name: BatchList 42 in: body 43 description: A binary encoded protobuf BatchList 44 schema: 45 $ref: "#/definitions/BatchList" 46 required: true 47 responses: 48 202: 49 description: Batches submitted for validation, but not yet committed 50 schema: 51 properties: 52 link: 53 $ref: "#/definitions/Link" 54 400: 55 $ref: "#/responses/400BadRequest" 56 429: 57 $ref: "#/responses/429TooManyRequests" 58 500: 59 $ref: "#/responses/500ServerError" 60 503: 61 $ref: "#/responses/503ServiceUnavailable" 62 get: 63 summary: Fetches a list of batches 64 description: > 65 Fetches a paginated list of batches from the validator. 66 parameters: 67 - $ref: "#/parameters/head" 68 - $ref: "#/parameters/start" 69 - $ref: "#/parameters/limit" 70 - $ref: "#/parameters/reverse" 71 responses: 72 200: 73 description: Successfully retrieved batches 74 schema: 75 properties: 76 data: 77 type: array 78 items: 79 $ref: "#/definitions/Batch" 80 head: 81 $ref: "#/definitions/Head" 82 link: 83 $ref: "#/definitions/Link" 84 paging: 85 $ref: "#/definitions/Paging" 86 400: 87 $ref: "#/responses/400BadRequest" 88 500: 89 $ref: "#/responses/500ServerError" 90 503: 91 $ref: "#/responses/503ServiceUnavailable" 92 93 /batches/{batch_id}: 94 parameters: 95 - $ref: "#/parameters/batch_id" 96 get: 97 summary: Fetches a particular batch 98 responses: 99 200: 100 description: Successfully retrieved batch 101 schema: 102 properties: 103 data: 104 $ref: "#/definitions/Batch" 105 head: 106 $ref: "#/definitions/Head" 107 link: 108 $ref: "#/definitions/Link" 109 400: 110 $ref: "#/responses/400BadRequest" 111 404: 112 $ref: "#/responses/404NotFound" 113 500: 114 $ref: "#/responses/500ServerError" 115 503: 116 $ref: "#/responses/503ServiceUnavailable" 117 118 /batch_statuses: 119 get: 120 summary: Fetches the committed statuses for a set of batches 121 description: | 122 Fetches an array of objects with a status and id for each batch 123 requested. There are four possible statuses with string values 124 `'COMMITTED'`, `'INVALID'`, `'PENDING'`, and `'UNKNOWN'`. 125 126 The batch(es) you want to check can be specified using the `id` filter 127 parameter. If a `wait` time is specified in the URL, the API will wait 128 to respond until all batches are committed, or the time in seconds has 129 elapsed. If the value of `wait` is not set (i.e., `?wait&id=...`), or 130 it is set to any non-integer value other than `false`, the wait time 131 will be just under the API's specified timeout (usually 300). 132 133 Note that because this route does not return full resources, the 134 response will not be paginated, and there will be no `head` or 135 `paging` properties. 136 parameters: 137 - name: id 138 in: query 139 description: A comma-separated list of batch ids 140 type: string 141 required: true 142 - $ref: "#/parameters/wait" 143 responses: 144 200: 145 description: Successfully retrieved statuses 146 schema: 147 properties: 148 data: 149 $ref: "#/definitions/BatchStatuses" 150 link: 151 $ref: "#/definitions/Link" 152 400: 153 $ref: "#/responses/400BadRequest" 154 500: 155 $ref: "#/responses/500ServerError" 156 503: 157 $ref: "#/responses/503ServiceUnavailable" 158 159 post: 160 summary: Fetches the committed statuses for a set of batches 161 description: | 162 Identical to `GET /batch_statuses`, but takes ids of batches as a JSON 163 formatted POST body rather than a query parameter. This allows for many 164 more batches to be checked and should be used for more than 15 ids. 165 166 Note that because query information is not encoded in the URL, no `link` 167 will be returned with this query. 168 consumes: 169 - application/json 170 parameters: 171 - name: Batch Ids 172 in: body 173 description: A JSON array of batch id strings 174 required: true 175 schema: 176 type: array 177 items: 178 type: string 179 example: 89807bfc9089e37e00d87d97357de14cfbc455cd608438d426a625a30a0da9a31c406983803c4aa27e1f32a3ff61709e8ec4b56abbc553d7d330635b5d27029c 180 - $ref: "#/parameters/wait" 181 responses: 182 200: 183 description: Successfully retrieved statuses 184 schema: 185 properties: 186 data: 187 $ref: "#/definitions/BatchStatuses" 188 400: 189 $ref: "#/responses/400BadRequest" 190 500: 191 $ref: "#/responses/500ServerError" 192 503: 193 $ref: "#/responses/503ServiceUnavailable" 194 195 /state: 196 get: 197 summary: Fetches the data for the current state 198 description: > 199 Fetches a paginated list of entries for the current state, or relative 200 to a particular head block. Using the `address` filter parameter will 201 narrow the list to any entries that have an address beginning with the 202 characters specified. 203 parameters: 204 - $ref: "#/parameters/head" 205 - name: address 206 in: query 207 type: string 208 description: A partial address to filter leaves by 209 - $ref: "#/parameters/start" 210 - $ref: "#/parameters/limit" 211 - $ref: "#/parameters/reverse" 212 responses: 213 200: 214 description: Successfully retrieved state data 215 schema: 216 properties: 217 data: 218 type: array 219 items: 220 $ref: "#/definitions/Entry" 221 head: 222 $ref: "#/definitions/Head" 223 link: 224 $ref: "#/definitions/Link" 225 paging: 226 $ref: "#/definitions/Paging" 227 400: 228 $ref: "#/responses/400BadRequest" 229 500: 230 $ref: "#/responses/500ServerError" 231 503: 232 $ref: "#/responses/503ServiceUnavailable" 233 234 /state/{address}: 235 parameters: 236 - $ref: "#/parameters/address" 237 get: 238 summary: Fetches a particular leaf from the current state 239 parameters: 240 - $ref: "#/parameters/head" 241 responses: 242 200: 243 description: Successfully fetched leaves 244 schema: 245 properties: 246 data: 247 type: string 248 format: byte 249 example: Zm9vOmJhcg== 250 head: 251 $ref: "#/definitions/Head" 252 link: 253 $ref: "#/definitions/Link" 254 400: 255 $ref: "#/responses/400BadRequest" 256 404: 257 $ref: "#/responses/404NotFound" 258 500: 259 $ref: "#/responses/500ServerError" 260 503: 261 $ref: "#/responses/503ServiceUnavailable" 262 263 /blocks: 264 get: 265 summary: Fetches a list of blocks 266 description: > 267 Fetches a paginated list of blocks from the validator. 268 parameters: 269 - $ref: "#/parameters/head" 270 - $ref: "#/parameters/start" 271 - $ref: "#/parameters/limit" 272 - $ref: "#/parameters/reverse" 273 responses: 274 200: 275 description: Successfully retrieved blocks 276 schema: 277 properties: 278 data: 279 type: array 280 items: 281 - $ref: "#/definitions/Block" 282 head: 283 $ref: "#/definitions/Head" 284 link: 285 $ref: "#/definitions/Link" 286 paging: 287 $ref: "#/definitions/Paging" 288 400: 289 $ref: "#/responses/400BadRequest" 290 500: 291 $ref: "#/responses/500ServerError" 292 503: 293 $ref: "#/responses/503ServiceUnavailable" 294 295 /blocks/{block_id}: 296 parameters: 297 - $ref: "#/parameters/block_id" 298 get: 299 summary: Fetches a particular block 300 responses: 301 200: 302 description: Successfully retrieved block 303 schema: 304 properties: 305 data: 306 $ref: "#/definitions/Block" 307 head: 308 $ref: "#/definitions/Head" 309 link: 310 $ref: "#/definitions/Link" 311 312 400: 313 $ref: "#/responses/400BadRequest" 314 404: 315 $ref: "#/responses/404NotFound" 316 500: 317 $ref: "#/responses/500ServerError" 318 503: 319 $ref: "#/responses/503ServiceUnavailable" 320 321 /transactions: 322 get: 323 summary: Fetches a list of transactions 324 description: > 325 Fetches a paginated list of transactions from the validator. 326 parameters: 327 - $ref: "#/parameters/head" 328 - $ref: "#/parameters/start" 329 - $ref: "#/parameters/limit" 330 - $ref: "#/parameters/reverse" 331 responses: 332 200: 333 description: Successfully retrieved transactions 334 schema: 335 properties: 336 data: 337 type: array 338 items: 339 - $ref: "#/definitions/Transaction" 340 head: 341 $ref: "#/definitions/Head" 342 link: 343 $ref: "#/definitions/Link" 344 paging: 345 $ref: "#/definitions/Paging" 346 400: 347 $ref: "#/responses/400BadRequest" 348 500: 349 $ref: "#/responses/500ServerError" 350 503: 351 $ref: "#/responses/503ServiceUnavailable" 352 353 /transactions/{transaction_id}: 354 parameters: 355 - $ref: "#/parameters/transaction_id" 356 get: 357 summary: Fetches a particular transaction 358 responses: 359 200: 360 description: Successfully retrieved transaction 361 schema: 362 properties: 363 data: 364 $ref: "#/definitions/Block" 365 head: 366 $ref: "#/definitions/Head" 367 link: 368 $ref: "#/definitions/Link" 369 370 400: 371 $ref: "#/responses/400BadRequest" 372 404: 373 $ref: "#/responses/404NotFound" 374 500: 375 $ref: "#/responses/500ServerError" 376 503: 377 $ref: "#/responses/503ServiceUnavailable" 378 379 /receipts: 380 get: 381 summary: Fetches the receipts for a set of transactions 382 description: | 383 Fetches an array of objects for each receipt requested. 384 385 The receipt(s) you want to retrieve can be specified using the `id` 386 filter parameter, where `id` refers to the transaction id of the 387 transaction the receipt is associated with. 388 parameters: 389 - name: id 390 in: query 391 description: A comma-separated list of transaction ids 392 type: string 393 required: true 394 responses: 395 200: 396 description: Successfully retrieved transaction receipts 397 schema: 398 properties: 399 data: 400 $ref: "#/definitions/TransactionReceipts" 401 link: 402 $ref: "#/definitions/Link" 403 400: 404 $ref: "#/responses/400BadRequest" 405 500: 406 $ref: "#/responses/500ServerError" 407 503: 408 $ref: "#/responses/503ServiceUnavailable" 409 410 post: 411 summary: Fetches the receipts for a set of transactions 412 description: | 413 Identical to `GET /receipts`, but takes ids of transactions as a JSON 414 formatted POST body rather than a query parameter. This allows for many 415 more receipts to be fetched and should be used with more than 15 ids. 416 417 Note that because query information is not encoded in the URL, no `link` 418 will be returned with this request. 419 consumes: 420 - application/json 421 parameters: 422 - name: Transaction Ids 423 in: body 424 description: A JSON array of transaction id strings 425 required: true 426 schema: 427 type: array 428 items: 429 type: string 430 example: 89807bfc9089e37e00d87d97357de14cfbc455cd608438d426a625a30a0da9a31c406983803c4aa27e1f32a3ff61709e8ec4b56abbc553d7d330635b5d27029c 431 - $ref: "#/parameters/wait" 432 responses: 433 200: 434 description: Successfully retrieved transaction receipts 435 schema: 436 properties: 437 data: 438 $ref: "#/definitions/TransactionReceipts" 439 link: 440 $ref: "#/definitions/Link" 441 400: 442 $ref: "#/responses/400BadRequest" 443 500: 444 $ref: "#/responses/500ServerError" 445 503: 446 $ref: "#/responses/503ServiceUnavailable" 447 448 /peers: 449 get: 450 summary: Fetches the endpoints of the authorized peers of the validator 451 responses: 452 200: 453 description: Successfully retrieved peers 454 schema: 455 properties: 456 data: 457 type: array 458 items: 459 type: string 460 example: tcp://12.345.67.890:8800 461 link: 462 $ref: "#/definitions/Link" 463 400: 464 $ref: "#/responses/400BadRequest" 465 500: 466 $ref: "#/responses/500ServerError" 467 503: 468 $ref: "#/responses/503ServiceUnavailable" 469 470 /status: 471 get: 472 summary: Fetches information pertaining to the status of the validator 473 responses: 474 200: 475 description: Successfully retrieved status 476 schema: 477 properties: 478 data: 479 type: object 480 properties: 481 endpoint: 482 type: string 483 example: tcp://12.345.67.890:8800 484 peers: 485 type: array 486 items: 487 type: object 488 properties: 489 endpoint: 490 type: string 491 example: tcp://12.345.67.890:8800 492 link: 493 $ref: "#/definitions/Link" 494 400: 495 $ref: "#/responses/400BadRequest" 496 500: 497 $ref: "#/responses/500ServerError" 498 503: 499 $ref: "#/responses/503ServiceUnavailable" 500 501 responses: 502 400BadRequest: 503 description: Request was malformed 504 schema: 505 $ref: "#/definitions/Error" 506 404NotFound: 507 description: Address or id did not match any resource 508 schema: 509 $ref: "#/definitions/Error" 510 429TooManyRequests: 511 description: Too many requests have been made to process batches 512 schema: 513 $ref: "#/definitions/Error" 514 500ServerError: 515 description: Something went wrong within the validator 516 schema: 517 $ref: "#/definitions/Error" 518 503ServiceUnavailable: 519 description: API is unable to reach the validator 520 schema: 521 $ref: "#/definitions/Error" 522 523 parameters: 524 address: 525 name: address 526 in: path 527 type: string 528 required: true 529 description: Radix address of a leaf 530 block_id: 531 name: block_id 532 in: path 533 type: string 534 required: true 535 description: Block id 536 batch_id: 537 name: batch_id 538 in: path 539 type: string 540 required: true 541 description: Batch id 542 transaction_id: 543 name: transaction_id 544 in: path 545 type: string 546 required: true 547 description: Transaction id 548 head: 549 name: head 550 in: query 551 type: string 552 default: latest 553 description: Index or id of head block 554 wait: 555 name: wait 556 in: query 557 type: integer 558 description: A time in seconds to wait for commit 559 limit: 560 name: limit 561 in: query 562 type: integer 563 default: 1000 564 description: Number of items to return 565 start: 566 name: start 567 in: query 568 type: string 569 description: Id to start paging (inclusive) 570 reverse: 571 name: reverse 572 in: query 573 type: string 574 description: If the list should be reversed 575 576 definitions: 577 Head: 578 type: string 579 example: 65cd3a3ce088b265b626f704b7f3db97b6f12e848dccb35d7806f3d0324c71b709ed360d602b8b658b94695374717e3bdb4b76f77886953777d5d008558247dd 580 Link: 581 type: string 582 example: https://api.sawtooth.com/state?head=65cd3a3ce088b265b626f704b7f3db97b6f12e848dccb35d7806f3d0324c71b709ed360d602b8b658b94695374717e3bdb4b76f77886953777d5d008558247dd 583 Paging: 584 properties: 585 start: 586 type: string 587 example: "65cd3a3ce088b265b626f704b7f3db97b6f12e848dccb35d7806f3d0324c71b709ed360d602b8b658b94695374717e3bdb4b76f77886953777d5d008558247dd" 588 limit: 589 type: integer 590 example: 54321 591 next_position: 592 type: string 593 example: "65cd3a3ce088b265b626f704b7f3db97b6f12e848dccb35d7806f3d0324c71b709ed360d602b8b658b94695374717e3bdb4b76f77886953777d5d008558247dd" 594 next: 595 type: string 596 example: https://api.sawtooth.com/state?head=65cd3a3ce088b265b626f704b7f3db97b6f12e848dccb35d7806f3d0324c71b709ed360d602b8b658b94695374717e3bdb4b76f77886953777d5d008558247dd&start=2000&limit=1000 597 598 Error: 599 properties: 600 code: 601 type: integer 602 example: 34 603 title: 604 type: string 605 example: No Batches Submitted 606 message: 607 type: string 608 example: > 609 The protobuf BatchList you submitted was empty and contained no 610 Batches. You must submit at least one Batch. 611 612 BatchStatuses: 613 type: array 614 items: 615 properties: 616 id: 617 type: string 618 example: 89807bfc9089e37e00d87d97357de14cfbc455cd608438d426a625a30a0da9a31c406983803c4aa27e1f32a3ff61709e8ec4b56abbc553d7d330635b5d27029c 619 status: 620 type: string 621 example: INVALID 622 enum: 623 - COMMITTED 624 - INVALID 625 - PENDING 626 - UNKNOWN 627 invalid_transactions: 628 type: array 629 items: 630 properties: 631 id: 632 type: string 633 example: 540a6803971d1880ec73a96cb97815a95d374cbad5d865925e5aa0432fcf1931539afe10310c122c5eaae15df61236079abbf4f258889359c4d175516934484a 634 message: 635 type: string 636 example: Verb is \"inc\" but name \"foo\" not in state 637 extended_data: 638 type: string 639 format: byte 640 example: ZXJyb3IgZGF0YQ== 641 642 Entry: 643 properties: 644 address: 645 type: string 646 example: 1cf12650d858e0985ecc7f60418aaf0cc5ab587f42c2570a884095a9e8ccacd0f6545c 647 data: 648 type: string 649 format: byte 650 example: Zm9vOmJhcg== 651 652 TransactionHeader: 653 properties: 654 batcher_public_key: 655 type: string 656 example: 02d260a46457a064733153e09840c322bee1dff34445d7d49e19e60abd18fd0758 657 dependencies: 658 type: array 659 items: 660 type: string 661 example: 1baee350bdb60bcee60e3d325d43283cf830b4c23b2cb17d3bb43935bd7af3761c2bee79847c72a9e396a9ae58f48add4e43f94eb83f84442c6085c1dd5d4dbe 662 family_name: 663 type: string 664 example: intkey 665 family_version: 666 type: string 667 example: "1.0" 668 inputs: 669 type: array 670 items: 671 type: string 672 example: 1cf12650d858e0985ecc7f60418aaf0cc5ab587f42c2570a884095a9e8ccacd0f6545c 673 nonce: 674 type: string 675 example: QAApS4L 676 outputs: 677 type: array 678 items: 679 type: string 680 example: 1cf12650d858e0985ecc7f60418aaf0cc5ab587f42c2570a884095a9e8ccacd0f6545c 681 payload_sha512: 682 type: string 683 example: fb6135ef73f4fe77367f9384b3bbbb158f4b8603c9d612157108e5c271868fce2242ee4abd7a29397ba63780c3ccab13783dfd4d9f0167beda03cdb0e37b87f4 684 signer_public_key: 685 type: string 686 example: 038bba5708acc262464c9fe30d3de9e905a9a5fa30cedd151dd9cd09ea26d46d00 687 Transaction: 688 properties: 689 header: 690 $ref: "#/definitions/TransactionHeader" 691 header_signature: 692 type: string 693 example: 540a6803971d1880ec73a96cb97815a95d374cbad5d865925e5aa0432fcf1931539afe10310c122c5eaae15df61236079abbf4f258889359c4d175516934484a 694 payload: 695 type: string 696 format: binary 697 698 TransactionReceipt: 699 properties: 700 transaction_id: 701 type: string 702 example: 540a6803971d1880ec73a96cb97815a95d374cbad5d865925e5aa0432fcf1931539afe10310c122c5eaae15df61236079abbf4f258889359c4d175516934484a 703 state_changes: 704 type: array 705 items: 706 properties: 707 type: 708 type: string 709 example: SET 710 address: 711 type: string 712 example: 1cf12650d858e0985ecc7f60418aaf0cc5ab587f42c2570a884095a9e8ccacd0f6545c 713 value: 714 type: string 715 format: binary 716 events: 717 type: array 718 items: 719 properties: 720 event_type: 721 type: string 722 example: sawtooth/block-commit 723 attributes: 724 type: array 725 items: 726 properties: 727 key: 728 type: string 729 value: 730 type: string 731 data: 732 type: string 733 format: binary 734 data: 735 type: array 736 items: 737 type: string 738 format: binary 739 TransactionReceipts: 740 type: array 741 items: 742 - $ref: "#/definitions/TransactionReceipt" 743 744 BatchHeader: 745 properties: 746 signer_public_key: 747 type: string 748 example: 038bba5708acc262464c9fe30d3de9e905a9a5fa30cedd151dd9cd09ea26d46d00 749 transaction_ids: 750 type: array 751 items: 752 type: string 753 example: 540a6803971d1880ec73a96cb97815a95d374cbad5d865925e5aa0432fcf1931539afe10310c122c5eaae15df61236079abbf4f258889359c4d175516934484a 754 Batch: 755 properties: 756 header: 757 $ref: "#/definitions/BatchHeader" 758 header_signature: 759 type: string 760 example: 89807bfc9089e37e00d87d97357de14cfbc455cd608438d426a625a30a0da9a31c406983803c4aa27e1f32a3ff61709e8ec4b56abbc553d7d330635b5d27029c 761 transactions: 762 type: array 763 items: 764 $ref: "#/definitions/Transaction" 765 BatchList: 766 properties: 767 batches: 768 type: array 769 items: 770 $ref: "#/definitions/Batch" 771 772 BlockHeader: 773 properties: 774 block_num: 775 type: integer 776 example: 12345 777 previous_block_id: 778 type: string 779 example: 65cd3a3ce088b265b626f704b7f3db97b6f12e848dccb35d7806f3d0324c71b709ed360d602b8b658b94695374717e3bdb4b76f77886953777d5d008558247dd 780 signer_public_key: 781 type: string 782 example: 02d260a46457a064733153e09840c322bee1dff34445d7d49e19e60abd18fd0758 783 batch_ids: 784 type: array 785 items: 786 type: string 787 example: 89807bfc9089e37e00d87d97357de14cfbc455cd608438d426a625a30a0da9a31c406983803c4aa27e1f32a3ff61709e8ec4b56abbc553d7d330635b5d27029c 788 consensus: 789 type: string 790 format: binary 791 state_root_hash: 792 type: string 793 example: 708ca7fbb701799bb387f2e50deaca402e8502abe229f705693d2d4f350e1ad6 794 Block: 795 properties: 796 header: 797 $ref: "#/definitions/BlockHeader" 798 header_signature: 799 type: string 800 example: 65cd3a3ce088b265b626f704b7f3db97b6f12e848dccb35d7806f3d0324c71b709ed360d602b8b658b94695374717e3bdb4b76f77886953777d5d008558247dd 801 batches: 802 type: array 803 items: 804 $ref: "#/definitions/Batch"