rest_api.json 28.6 KB
Newer Older
1
2
3
4
5
6
7
{
    "swagger": "2.0",
    "info": {
        "title": "Hyperledger Fabric API",
        "description": "Interact with the enterprise blockchain through Hyperledger Fabric API",
        "version": "1.0.0"
    },
8
    "host": "127.0.0.1:7050",
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
    "schemes": [
        "http"
    ],
    "produces": [
        "application/json"
    ],
    "paths": {
        "/chain": {
            "get": {
                "summary": "Blockchain information",
                "description": "The Chain endpoint returns information about the current state of the blockchain such as the height, the current block hash, and the previous block hash.",
                "tags": [
                    "Blockchain"
                ],
                "operationId": "getChain",
                "responses": {
                    "200": {
                        "description": "Blockchain information",
                        "schema": {
                           "$ref": "#/definitions/BlockchainInfo"
                        }
                    },
                    "default": {
                        "description": "Unexpected error",
                        "schema": {
                            "$ref": "#/definitions/Error"
                        }
                    }
                }
            }
        },
        "/chain/blocks/{Block}": {
            "get": {
                "summary": "Individual block information",
                "description": "The {Block} endpoint returns information about a specific block within the Blockchain. Note that the genesis block is block zero.",
                "tags": [
                    "Block"
                ],
                "operationId": "getBlock",
                "parameters": [{
                    "name": "Block",
                    "in": "path",
                    "description": "Block number to retrieve",
                    "type": "integer",
                    "format": "uint64",
                    "required": true
                }],
                "responses": {
                    "200": {
                        "description": "Individual Block contents",
                        "schema": {
                           "$ref": "#/definitions/Block"
                        }
                    },
                    "default": {
                        "description": "Unexpected error",
                        "schema": {
                            "$ref": "#/definitions/Error"
                        }
                    }
                }
            }
        },
Gabor Hosszu's avatar
Gabor Hosszu committed
72
        "/transactions/{ID}": {
73
74
            "get": {
                "summary": "Individual transaction contents",
Gabor Hosszu's avatar
Gabor Hosszu committed
75
                "description": "The /transactions/{ID} endpoint returns the transaction matching the specified TXID.",
76
77
78
79
80
                "tags": [
                    "Transactions"
                ],
                "operationId": "getTransaction",
                "parameters": [{
Gabor Hosszu's avatar
Gabor Hosszu committed
81
                    "name": "ID",
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
                    "in": "path",
                    "description": "Transaction to retrieve from the blockchain.",
                    "type": "string",
                    "required": true
                }],
                "responses": {
                    "200": {
                        "description": "Individual Transaction contents",
                        "schema": {
                           "$ref": "#/definitions/Transaction"
                        }
                    },
                    "default": {
                        "description": "Unexpected error",
                        "schema": {
                            "$ref": "#/definitions/Error"
                        }
                    }
                }
            }
        },
        "/chaincode": {
           "post": {
              "summary": "Service endpoint for Chaincode operations",
              "description": "The /chaincode endpoint receives requests to deploy, invoke, and query a target Chaincode. This service endpoint implements the JSON RPC 2.0 specification with the payload identifying the desired Chaincode operation within the 'method' field.",
              "tags": [
                  "Chaincode"
              ],
              "operationId": "chaincodeOp",
              "parameters": [{
                 "name": "ChaincodeOpPayload",
                 "in": "body",
                 "description": "Chaincode JSON RPC 2.0 payload",
                 "required": true,
                 "schema": {
                    "$ref": "#/definitions/ChaincodeOpPayload"
                 }
              }],
              "responses": {
                  "200": {
                      "description": "Chaincode operation successful",
                      "schema": {
                         "$ref": "#/definitions/ChaincodeOpSuccess"
                      }
                  },
                  "default": {
                      "description": "Chaincode operation failed",
                      "schema": {
                          "$ref": "#/definitions/ChaincodeOpFailure"
                      }
                  }
              }
           }
        },
        "/registrar": {
           "post": {
              "summary": "Register a user with the certificate authority",
              "description": "The /registrar endpoint receives requests to register a user with the certificate authority. The request must supply the registration id and password within the payload. If the registration is successful, the required transaction certificates are received and stored locally. Otherwise, an error is displayed alongside with a reason for the failure.",
              "tags": [
                  "Registrar"
              ],
              "operationId": "registerUser",
              "parameters": [{
                 "name": "Secret",
                 "in": "body",
                 "description": "User enrollment credentials",
                 "required": true,
                 "schema": {
                    "$ref": "#/definitions/Secret"
                 }
              }],
              "responses": {
                  "200": {
                      "description": "Successfully registered user with the certificate authority",
                      "schema": {
                         "$ref": "#/definitions/OK"
                      }
                  },
                  "default": {
                      "description": "Unexpected error",
                      "schema": {
                          "$ref": "#/definitions/Error"
                      }
                  }
              }
           }
        },
        "/registrar/{enrollmentID}": {
            "get": {
                "summary": "Confirm the user has registered with the certificate authority",
                "description": "The /registrar/{enrollmentID} endpoint confirms whether the specified user has registered with the certificate authority. If the user has registered, a confirmation message will be returned. Otherwise, an authorization failure will result.",
                "tags": [
                    "Registrar"
                ],
                "operationId": "getUserRegistration",
                "parameters": [{
                    "name": "enrollmentID",
                    "in": "path",
                    "description": "Username for which registration is to be confirmed",
                    "type": "string",
                    "required": true
                }],
                "responses": {
                    "200": {
                        "description": "Confirm registration for target user",
                        "schema": {
                           "$ref": "#/definitions/OK"
                        }
                    },
                    "default": {
                        "description": "Unexpected error",
                        "schema": {
                            "$ref": "#/definitions/Error"
                        }
                    }
                }
            },
            "delete": {
              "summary": "Delete user login tokens from local storage",
              "description": "The /registrar/{enrollmentID} endpoint deletes any existing client login tokens from local storage. After the completion of this request, the target user will no longer be able to execute transactions.",
              "tags": [
                  "Registrar"
              ],
                "operationId": "deleteUserRegistration",
                "parameters": [{
                    "name": "enrollmentID",
                    "in": "path",
                    "description": "Username for which login tokens are to be deleted",
                    "type": "string",
                    "required": true
                }],
                "responses": {
                    "200": {
                        "description": "Confirm deletion of user login tokens",
                        "schema": {
                           "$ref": "#/definitions/OK"
                        }
                    },
                    "default": {
                        "description": "Unexpected error",
                        "schema": {
                            "$ref": "#/definitions/Error"
                        }
                    }
                }
            }
        },
        "/registrar/{enrollmentID}/ecert": {
            "get": {
                "summary": "Retrieve user enrollment certificate",
                "description": "The /registrar/{enrollmentID}/ecert endpoint retrieves the enrollment certificate for a given user that has registered with the certificate authority. If the user has registered, a confirmation message will be returned containing the URL-encoded enrollment certificate. Otherwise, an error will result.",
                "tags": [
                    "Registrar"
                ],
                "operationId": "getUserEnrollmentCertificate",
                "parameters": [{
                    "name": "enrollmentID",
                    "in": "path",
                    "description": "EnrollmentID for which the certificate is requested",
                    "type": "string",
                    "required": true
                }],
                "responses": {
                    "200": {
                        "description": "Confirm registration for target user and return the URL-encoded enrollment certificate",
                        "schema": {
                           "$ref": "#/definitions/OK"
                        }
                    },
                    "default": {
                        "description": "Unexpected error",
                        "schema": {
                            "$ref": "#/definitions/Error"
                        }
                    }
                }
            }
        },
        "/registrar/{enrollmentID}/tcert": {
            "get": {
                "summary": "Retrieve user transaction certificates",
                "description": "The /registrar/{enrollmentID}/tcert endpoint retrieves the transaction certificates for a given user that has registered with the certificate authority. If the user has registered, a confirmation message will be returned containing an array of URL-encoded transaction certificates. Otherwise, an error will result. The desired number of transaction certificates is specified with the optional 'count' query parameter. The default number of returned transaction certificates is 1 and 500 is the maximum number of certificates that can be retrieved with a single request.",
                "tags": [
                    "Registrar"
                ],
                "operationId": "getUserTransactionCertificate",
                "parameters": [{
                    "name": "enrollmentID",
                    "in": "path",
                    "description": "EnrollmentID for which the certificate is requested",
                    "type": "string",
                    "required": true
                },
                {
                    "name": "count",
                    "in": "query",
                    "description": "The desired number of transaction certificates. The default number of returned transaction certificates is 1 and 500 is the maximum number of certificates that can be retrieved with a single request",
                    "type": "string"
                }],
                "responses": {
                    "200": {
                        "description": "Confirm registration for target user and return the desired number of URL-encoded transaction certificates",
                        "schema": {
                           "$ref": "#/definitions/OK"
                        }
                    },
                    "default": {
                        "description": "Unexpected error",
                        "schema": {
                            "$ref": "#/definitions/Error"
                        }
                    }
                }
            }
        },
        "/network/peers": {
            "get": {
                "summary": "List of network peers",
                "description": "The /network/peers endpoint returns a list of all existing network connections for the target peer node. The list includes both validating and non-validating peers.",
                "tags": [
                    "Network"
                ],
                "operationId": "getPeers",
                "responses": {
                    "200": {
                        "description": "List of network peers",
                        "schema": {
                           "$ref": "#/definitions/PeersMessage"
                        }
                    },
                    "default": {
                        "description": "Unexpected error",
                        "schema": {
                            "$ref": "#/definitions/Error"
                        }
                    }
                }
            }
        }
    },
    "definitions": {
        "BlockchainInfo": {
            "type": "object",
            "properties": {
                "height": {
                    "type": "integer",
                    "format": "uint64",
                    "description": "Current height of the blockchain."
                },
                "currentBlockHash": {
                    "type": "string",
                    "format": "bytes",
                    "description": "Hash of the last block in the blockchain."
                },
                "previousBlockHash": {
                    "type": "string",
                    "format": "bytes",
                    "description": "Hash of the previous block in the blockchain."
                }
            }
        },
        "Block": {
            "type": "object",
            "properties": {
                "proposerID": {
                    "type": "string",
                    "description": "Creator/originator of the block."
                },
                "timestamp": {
                  "$ref": "#/definitions/Timestamp",
                  "description": "Time of block creation."
                },
                "transactions": {
                    "type": "array",
                    "items": {
                        "$ref": "#/definitions/Transaction"
                    }
                },
                "stateHash": {
                    "type": "string",
                    "format": "bytes",
                    "description": "Global state hash after executing all transactions in the block."
                },
                "previousBlockHash": {
                    "type": "string",
                    "format": "bytes",
                    "description": "Hash of the previous block in the blockchain."
                },
                "consensusMetadata": {
                  "type": "string",
                  "format": "bytes",
                  "description": "Metadata required for consensus."
                },
                "nonHashData": {
                  "type": "string",
                  "format": "bytes",
                  "description": "Data stored in the block, but excluded from the computation of block hash."
                }
            }
        },
        "Transaction": {
            "type": "object",
            "properties": {
                "type": {
                    "type": "string",
                    "default": "UNDEFINED",
                    "example": "UNDEFINED",
                    "enum":[
                        "UNDEFINED",
                        "CHAINCODE_DEPLOY",
                        "CHAINCODE_INVOKE",
                        "CHAINCODE_QUERY",
                        "CHAINCODE_TERMINATE"
                    ],
                    "description": "Transaction type."
                },
                "chaincodeID": {
                  "type": "string",
                  "format": "bytes",
                  "description": "Chaincode identifier as bytes."
                },
                "payload": {
                    "type": "string",
                    "format": "bytes",
                    "description": "Payload supplied for Chaincode function execution."
                },
Gabor Hosszu's avatar
Gabor Hosszu committed
408
                "id": {
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
                   "type": "string",
                   "description": "Unique transaction identifier."
                },
                "timestamp": {
                  "$ref": "#/definitions/Timestamp",
                  "description": "Time at which the chanincode becomes executable."
                },
                "confidentialityLevel": {
                    "$ref": "#/definitions/ConfidentialityLevel",
                    "description": "Confidentiality level of the Chaincode."
                },
                "nonce": {
                    "type": "string",
                    "format": "bytes",
                    "description": "Nonce value generated for this transaction."
                },
                "cert": {
                    "type": "string",
                    "format": "bytes",
                    "description": "Certificate of client sending the transaction."
                },
                "signature": {
                    "type": "string",
                    "format": "bytes",
                    "description": "Signature of client sending the transaction."
                }
            }
        },
        "ChaincodeID": {
            "type": "object",
            "properties": {
                "path": {
                    "type": "string",
                    "description": "Chaincode location in the file system. This value is required by the deploy transaction."
                },
                "name": {
                    "type": "string",
                    "description": "Chaincode name identifier. This value is required by the invoke and query transactions."
                }
            }
        },
        "ChaincodeSpec": {
            "type": "object",
            "properties": {
                "type": {
Christopher Ferris's avatar
Christopher Ferris committed
454
455
456
                    "type": "integer",
                    "default": 1,
                    "example": 1,
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
                    "description": "Chaincode specification language."
                },
                "chaincodeID": {
                    "$ref": "#/definitions/ChaincodeID",
                    "description": "Unique Chaincode identifier."
                },
                "ctorMsg": {
                    "$ref": "#/definitions/ChaincodeInput",
                    "description": "Specific function to execute within the Chaincode."
                },
                "secureContext": {
                    "type": "string",
                    "description": "Username when security is enabled."
                },
                "confidentialityLevel": {
                    "$ref": "#/definitions/ConfidentialityLevel",
                    "description": "Confidentiality level of the Chaincode."
                }
            }
        },
        "ChaincodeInvocationSpec": {
            "type": "object",
            "properties": {
                "chaincodeSpec": {
                    "$ref": "#/definitions/ChaincodeSpec",
                    "description": "Chaincode specification message."
                }
            }
        },
        "ChaincodeOpPayload": {
           "type": "object",
           "properties": {
              "jsonrpc": {
                 "type": "string",
                 "default": "2.0",
                 "description": "A string specifying the version of the JSON-RPC protocol. Must be exactly '2.0'."
              },
              "method": {
                 "type": "string",
                 "description": "A string containing the name of the method to be invoked. Must be 'deploy', 'invoke', or 'query'."
              },
              "params": {
                  "$ref": "#/definitions/ChaincodeSpec",
                  "description": "A required Chaincode specification message identifying the target chaincode."
              },
              "id": {
                 "type": "integer",
                 "format": "int64",
                 "description": "An integer number used to correlate the request and response objects. If it is not included, the request is assumed to be a notification and the server will not generate a response."
              }
           },
           "required": [
              "jsonrpc",
              "method",
              "params",
              "id"
           ]
        },
        "ConfidentialityLevel":{
            "type": "string",
            "default": "PUBLIC",
            "example": "PUBLIC",
            "enum":[
                "PUBLIC",
                "CONFIDENTIAL"
              ],
            "description": "Confidentiality level of the Chaincode."
        },
        "ChaincodeInput": {
            "type": "object",
            "properties": {
                "args": {
                    "type": "array",
                    "items": {
                        "type": "string"
                    },
                    "description": "Arguments supplied to the Chaincode function."
                }
            }
        },
        "Secret": {
            "type": "object",
            "properties": {
                "enrollId": {
                    "type": "string",
                    "description": "User enrollment id registered with the certificate authority."
                },
                "enrollSecret": {
                    "type": "string",
                    "description": "User enrollment password registered with the certificate authority."
                }
            }
        },
        "Timestamp": {
            "type": "object",
            "properties": {
                "seconds": {
                    "type": "integer",
                    "format": "int64",
                    "description": "Represents seconds of UTC time since Unix epoch 1970-01-01T00:00:00Z. Must be from from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59Z inclusive."
                },
                "nanos": {
                    "type": "integer",
                    "format": "int32",
                    "description": "Non-negative fractions of a second at nanosecond resolution. Negative second values with fractions must still have non-negative nanos values that count forward in time. Must be from 0 to 999,999,999 inclusive."
                }
            }
        },
        "PeersMessage": {
            "type": "object",
            "properties": {
                "peers": {
                    "type": "array",
                    "items": {
                        "$ref": "#/definitions/PeerEndpoint"
                    }
                }
            }
        },
        "PeerEndpoint": {
            "type": "object",
            "properties": {
                "ID": {
                    "$ref": "#/definitions/PeerID",
                    "description": "Unique peer identifier."
                },
                "address": {
                    "type": "string",
                    "description": "ipaddress:port combination identifying a network peer."
                },
                "type": {
                    "type": "string",
                    "default": "UNDEFINED",
                    "example": "UNDEFINED",
                    "enum":[
                        "UNDEFINED",
                        "VALIDATOR",
                        "NON_VALIDATOR"
                    ],
                    "description": "Network peer type."
                },
                "pkiID": {
                    "type": "string",
                    "format": "bytes",
                    "description": "PKI identifier for the network peer."
                }
            }
        },
        "PeerID": {
            "type": "object",
            "properties": {
                "name": {
                    "type": "string",
                    "description": "Name which uniquely identifies a network peer."
                }
            }
        },
        "Error": {
            "type": "object",
            "properties": {
                "Error": {
                    "type": "string",
                    "description": "A descriptive message explaining the cause of error."
                }
            }
        },
        "OK": {
            "type": "object",
            "properties": {
                "OK": {
                    "type": "string",
                    "description": "A descriptive message confirming a successful request."
                },
                "message": {
                    "type": "string",
                    "description": "An optional parameter containing additional information about the request."
                }
            }
        },
        "ChaincodeOpSuccess": {
           "type": "object",
           "properties": {
              "jsonrpc": {
                 "type": "string",
                 "default": "2.0",
                 "description": "A string specifying the version of the JSON-RPC protocol. Must be exactly '2.0'."
              },
              "result": {
                  "$ref": "#/definitions/rpcResponse",
                  "description": "The value of this element is determined by the method invoked on the server."
              },
              "id": {
                  "type": "integer",
                  "format": "int64",
                  "default": 123,
                  "description": "This number will be the same as the value of the id member in the request object."
              }
           },
           "required": [
              "jsonrpc",
              "result",
              "id"
           ]
        },
        "ChaincodeOpFailure": {
           "type": "object",
           "properties": {
              "jsonrpc": {
                 "type": "string",
                 "default": "2.0",
                 "description": "A string specifying the version of the JSON-RPC protocol. Must be exactly '2.0'."
              },
              "error": {
                 "$ref": "#/definitions/rpcError",
                 "description": "A structured value specifying the code and description of the error that occurred."
             },
             "id": {
                 "type": "integer",
                 "format": "int64",
                 "default": 123,
                 "description": "This number will be the same as the value of the id member in the request object. If there was an error detecting the id in the request object (e.g. Parse error/Invalid Request), it will be null."
             }
          },
          "required": [
            "jsonrpc",
            "error",
            "id"
          ]
        },
        "rpcResponse": {
           "type": "object",
           "properties": {
              "Status": {
                 "type": "string",
                 "default": "OK",
                 "description": "A string confirming successful request execution."
              },
              "Message": {
                 "type": "string",
                 "default": "500",
                 "description": "Additional information about the response or values returned."
              }
           },
           "required": [
             "Status"
           ]
        },
        "rpcError": {
          "type": "object",
          "properties": {
            "code": {
              "type": "integer",
              "format": "int64",
              "default": -32700,
              "description": "A number that indicates the error type that occurred."
            },
            "message": {
              "type": "string",
              "default": "Parse error",
              "description": "A string providing a short description of the error."
            },
            "data": {
              "type": "string",
              "default": "Error unmarshalling chaincode request payload: unexpected end of JSON input",
              "description": "A primitive or structured value that contains additional information about the error (e.g. detailed error information, nested errors etc.)."
            }
          },
          "required": [
            "code",
            "message"
          ]
        }
    }
}