-
Notifications
You must be signed in to change notification settings - Fork 5
/
apiary.apib
4700 lines (3718 loc) · 181 KB
/
apiary.apib
1
2
3
4
5
6
7
8
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
72
73
74
75
76
77
78
79
80
81
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
408
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
454
455
456
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
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
FORMAT: 1A
HOST: https://test.ambrosus.io
# Ambrosus Node API
Welcome to Ambrosus Node API Documentation. This document describes Api for both Hermes and Atlas nodes.
### Authentication
Before you can start interacting with API you need to create an account. An account is a pair: address and secret.
Depending on the type of operation you want to perform you are required to provide one of two forms of authentication: signed content or token based.
For entity upload operations the body of the request needs to contain a `content.signature` field. It is generated by signing the [serialized](Serialization) `content.idData` object using the standard ethereum sign function and your private key.
For other operations (modifying accounts and querying entities) a token should be provided using the http authorization header with `AMB_TOKEN ...` .
There is a special third option where you provide a http authorization header `AMB ...` with your account private key. When doing so the gateway will calculate the signature for you. This mechanism can be enabled using a config parameter. __Warning__: Sharing your private key is a security risk. This mechanism should therefore only be used in development and testing environments.
### Immutability
__Note:__ All data is immutable, therefore, you will not find update or delete calls. The organization and account are exceptions.
## Serialization
When serialising data for hashing and signing, special care needs to be taken so that the result is deterministic. Otherwise the output values may not match, and lead to validation errors. Following rules need to be followed:
* The JSON is serialized to a single-line string without any whitespace characters outside of strings
* All fields in objects are sorted lexicographically
* In other aspects the output should match `JSON.stringify`
## Hashing
Hashes are a very important part of proving the persistence and the immutability of the data. All hashes in the AMB-NODE are computed using the ethereum standard `hashMessage` function as described in [web3 docs](https://web3js.readthedocs.io/en/1.0/web3-eth-accounts.html#hashmessage). The underlying hash function is [Keccak256](https://keccak.team/index.html).
## Errors
The majority of errors along to the error code provide additional information in `body` with following format:
```{json}
{
"reason": "What happened"
}
```
## Group Account
__ⓘ Note:__ Used for compatibility with an old Dashboard.\
__ⓘ Note:__ Available only for Hermes node.
An account represents an actor in the supply chain. This can be a person, a company, a location, etc.
It consists of a pair - a public identifier `address` (compatible with ethereum address) and a `secret` (compatible with ethereum private key). Additionally an account has a list of permissions, which specify what actions user can perform and an access levels, which specifies what data is user able to view.
Account can hold any number of following permissions:
* super_account - Almighty administrator account. Is able to perform all kinds of calls.
* protected_account - account protected from modification. Protected accounts can be created only by super accounts or other protected accounts. Only super accounts can modify the protected accounts.
* create_asset - allows account to create assets
* create_event - allows account to create events
* register_accounts - allows account to add new accounts
* manage_accounts - allows account to view and manage existing accounts
## /account/keyPair
#### Get keyPair for new account [GET]
+ Response 200
+ Attributes
+ data (object)
+ address (string) - the publica account address
+ privateKey (string) - the secret user's key
+ meta (object) - the metadata
+ code (number) - the status code
+ Body
{
"data": {
"address": "0x14eabBFc07127AEb2a92c5889663B2887cD10a9c",
"privateKey": "0xb95567df8f398fe4c5f4268831e34f30e059fec2286d252068d063f2c1018d19"
},
"meta": {
"code": 200
}
}
## /account{?limit,next,previous}
__ⓘ Note:__ super_account and manage_accounts permissions are required
#### Get list of all accounts [GET]
+ Parameters
+ limit (integer, optional) - Number of accounts to return per page (limited to 100)
+ next (string, optional) - the id of the next page. Take from response.
+ previous (string, optional) - the id of the previous page. Take from response.
+ Request (application/json)
+ Headers
Accept: application/json
Authorization: AMB_TOKEN ...
+ Response 200 (application/json)
+ Attributes (object)
+ data (array) - The latest 100 accounts matching provided criteria
+ (object) - Account.
+ registeredBy (string) - The address which has registered the account.
+ registeredOn (number) - UNIX timestamp of account registration.
+ permissions (array) - A list of permissions granted to this account
+ accessLevel (number) - Access level of the account. Should be a non-negative integer.
+ organization (number) - Identifier of the organization the account belongs to.
+ address (string) - An address of the account.
+ email (string) - An email of the account.
+ active (boolean) - State of the account.
+ meta (object) - the metadata
+ code (number) - the status code
+ count (number) - the count of result object
+ pagination (object) - the helper to handle pagination
+ hasNext (boolean) - shows if there is next page
+ next (string) - the id of the next page
+ hasPrevious (boolean) - shows if there is previous page
+ previous (string) - the id of the previous page
+ Body
{
"data": [
{
"address":"0x918eACF10eA2C47B001f761460Ed19607656f01C",
"email":"email1C@domain.com",
"fullName":null,
"accessLevel":100,
"organization":9,
"permissions":["create_asset", "create_event"],
"registeredBy":"0xC769C64a70ECA2606A927DC28DD947A5Dbec237B",
"registeredOn":1584685139,
"active":true
}
],
"meta": {
"code": 200,
"count": 1
},
"pagination": {
"hasNext": false,
"hasPrevious": false
}
}
+ Response 400 (application/json)
Validation error
+ Body
+ Response 401 (application/json)
Authentication error
+ Body
+ Response 403 (application/json)
Invalid signature or missing permissions
+ Body
+ Response 404 (application/json)
Requested account does not exist
+ Body
## /account/{accountAddress}
##### Get info about account [GET]
+ Parameters
+ accountAddress (string) - An address of the account
+ Request (application/json)
+ Headers
Accept: application/json
Authorization: AMB_TOKEN ...
+ Response 200 (application/json)
+ Attributes (object)
+ data (array)
+ (object)
+ registeredBy (string) - The address which has registered the account.
+ registeredOn (number) - UNIX timestamp of account registration.
+ permissions (array) - A list of permissions granted to this account
+ accessLevel (number) - Access level of the account. Should be a non-negative integer.
+ organization (number) - Identifier of the organization the account belongs to.
+ address (string) - An address of the account.
+ email (string) - An email of the account.
+ active (boolean) - State of the account.
+ meta (object)
+ code (number) - the status code
+ count (number) - the number of objects in data
+ Body
{
"data":[
{
"address":"0x918eACF10eA2C47B001f761460Ed19607656f01C",
"email":"email1C@domain.com",
"fullName":null,
"accessLevel":100,
"organization":9,
"permissions":["create_asset", "create_event"],
"registeredBy":"0xC769C64a70ECA2606A927DC28DD947A5Dbec237B",
"registeredOn":1584685139,
"active":true
}],
"meta": {
"code": 200,
"count": 1
}
}
+ Response 400 (application/json)
Validation error
+ Body
+ Response 401 (application/json)
Authentication error
+ Body
+ Response 403 (application/json)
Invalid signature or missing permission
+ Body
##### Update account info [PUT]
+ Parameters
+ accountAddress (string) - An address of the account
+ Request
+ Headers
Accept: application/json
Authorization: AMB_TOKEN ...
+ Attributes
+ fullName (string, optional) - the full name a user
+ email (string, optional) - the user's email
+ timeZone (string, optional) - the user's time zone
+ Body
{
"fullName": "Test Name",
"email": "test@example.com",
"timeZone": "Australia/Sydney"
}
+ Response 200 (application/json)
+ Attributes (object)
+ data (array)
+ (object)
+ address (string) - An address of the account.
+ registeredBy (string) - The address which has registered the account.
+ email (string) - An email of the account.
+ fullName (string) - a user's full name.
+ registeredOn (number) - UNIX timestamp of account registration.
+ permissions (array) - A list of permissions granted to this account
+ accessLevel (number) - Access level of the account. Should be a non-negative integer.
+ organization (number) - Identifier of the organization the account belongs to.
+ active (boolean) - State of the account.
+ meta (object) - the metadata
+ code (number) - the status code
+ count (number) - the number of objects in data
+ pagination (object) - the helper to handle pagination
+ hasNext (boolean) - shows if there is a next page
+ hasPrevious (boolean) - shows if there is a previous page
+ Body
{
"data": [
{
"address":"0x918eACF10eA2C47B001f761460Ed19607656f01C",
"email":"email1C@domain.com",
"fullName":null,
"accessLevel":100,
"organization":9,
"permissions":["create_asset", "create_event"],
"registeredBy":"0xC769C64a70ECA2606A927DC28DD947A5Dbec237B",
"registeredOn":1584685139,
"active":true
}
],
"meta": {
"code": 200,
"count": 1
},
"pagination": {
"hasNext": false,
"hasPrevious": false
}
}
+ Response 400 (application/json)
Validation error
+ Body
+ Response 401 (application/json)
Authentication error
+ Body
+ Response 403 (application/json)
Invalid signature or missing permission
+ Body
## /account/secret
#### Get secret by email [POST]
+ Request (application/json)
+ Headers
Accept: application/json
Authorization: AMB_TOKEN ...
+ Attributes
+ email (string) - the email of the user
+ Body
{
"email": "test@example.com"
}
+ Response 200 (application/json)
+ Attributes
+ data (object)
+ secret (string) - the user's secret
+ meta (object)
+ code (number) - the status code
+ Body
{
"data": {
"secret": "long hex value"
},
"meta": {
"code": 200
}
}
## /account/{accountAddress}/details
#### Get detailed info about account [GET]
+ Parameters
+ accountAddress (string) - An address of the account
+ Request (application/json)
+ Headers
Accept: application/json
Authorization: AMB_TOKEN ...
+ Response 200 (application/json)
+ Attributes
+ data (object)
+ (object) - the account
+ address (string) - An address of the account.
+ email (string) - An email of the account.
+ fullName (string) - A full name of a person.
+ (object) - the organization
+ owner (string) - the organization's owner
+ title (string) - the name of organization
+ timeZone (string) - the time zone where organization works
+ legalAddress (string) - the address of organization headquarter
+ active (boolean) - the status of organization
+ organizationId (number) - the id of organization
+ meta (object)
+ code (number) - the status code
+ Body
{
"data": {
{
"address":"0x918eACF10eA2C47B001f761460Ed19607656f01C",
"email":"email1C@domain.com",
"fullName":null
},
{
"owner": "0x2A52139de123c9fa265C206772d1606e326CC044",
"title": "Fast eddies musical chairs",
"timeZone": "Australia/Sydney",
"legalAddress": "1234 Bondi Beach",
"active": true,
"organizationId": 9
}
},
"meta": {
"code": 200
}
}
+ Response 400 (application/json)
Validation error
+ Body
+ Response 401 (application/json)
Authentication error
+ Body
+ Response 403 (application/json)
Invalid signature or missing permission
+ Body
## /account/{accountAddress}/exists
#### Check if account exists [GET]
+ Response 200 (application/json)
+ Attributes
+ data (boolean) - the result
+ meta (object) - the metadata
+ code (number) - the result code
+ Body
{
"data": true,
"meta": {
"code": 200
}
}
## /account/query{?limit,next,previous}
#### Make a mongoDB query [POST]
+ Parameters
+ limit (integer, optional) - Number of accounts to return per page (limited to 100)
+ next (string, optional) - the id of the next page. Take from response.
+ previous (string, optional) - the id of the previous page. Take from response.
+ Request (application/json)
+ Headers
Accept: application/json
Authorization: AMB_TOKEN ...
+ Attributes
+ query (array) - the array of mongoDb operators
+ (object) - the one mongo Operation
+ field (string) - the name of the filed
+ value (string) - the searched value
+ operator (string) - the mongoOperator
+ Body
{
"query": [{
"field": "registeredBy",
"value": "0x0C7401498719555B2119C01bB6af0dFA904AD69e",
"operator": "equal"
}]
}
+ Response 200 (application/json)
+ Attributes (object)
+ data (array) - The latest 100 accounts matching provided criteria
+ (object) - Account.
+ registeredBy (string) - The address which has registered the account.
+ registeredOn (number) - UNIX timestamp of account registration.
+ permissions (array) - A list of permissions granted to this account
+ accessLevel (number) - Access level of the account. Should be a non-negative integer.
+ organization (number) - Identifier of the organization the account belongs to.
+ address (string) - An address of the account.
+ email (string) - An email of the account.
+ active (boolean) - State of the account.
+ meta (object) - the metadata
+ code (number) - the status code
+ count (number) - the count of result object
+ pagination (object) - the helper to handle pagination
hasNext (boolean) - shows if there is next page
hasPrevious (boolean) - shows if there is previous page
+ Body
{
"data": [
{
"address":"0x918eACF10eA2C47B001f761460Ed19607656f01C",
"email":"email1C@domain.com",
"fullName":null,
"accessLevel":100,
"organization":9,
"permissions":["create_asset", "create_event"],
"registeredBy":"0xC769C64a70ECA2606A927DC28DD947A5Dbec237B",
"registeredOn":1584685139,
"active":true
}
],
"meta": {
"code": 200,
"count": 0
},
"pagination": {
"hasNext": false,
"hasPrevious": false
}
}
+ Response 400 (application/json)
Validation error
+ Body
+ Response 401 (application/json)
Authentication error
+ Body
## Group Account2
__ⓘ Note:__ Available only for Hermes node.
An account represents an actor in the supply chain. This can be a person, a company, a location, etc.
It consists of a pair - a public identifier `address` (compatible with ethereum address) and a `secret` (compatible with ethereum private key). Additionally an account has a list of permissions, which specify what actions user can perform and an access levels, which specifies what data is user able to view.
Account can hold any number of following permissions:
* super_account - Almighty administrator account. Is able to perform all kinds of calls.
* protected_account - account protected from modification. Protected accounts can be created only by super accounts or other protected accounts. Only super accounts can modify the protected accounts.
* create_asset - allows account to create assets
* create_event - allows account to create events
* register_accounts - allows account to add new accounts
* manage_accounts - allows account to view and manage existing accounts
### /account2/list{?limit,next,previous}
#### List accounts [GET]
__Warning__ Request sender needs to have "manage_accounts" permission
Finds accounts satisfying provided criteria.
+ Parameters
+ limit (integer, optional) - Number of accounts to return per page (limited to 100)
+ next (string, optional) - the id of the next page. Take from response.
+ previous (string, optional) - the id of the previous page. Take from response.
+ Request (application/json)
+ Headers
Accept: application/json
Authorization: AMB_TOKEN ...
+ Response 200 (application/json)
+ Attributes (object)
+ data (array) - The latest 100 accounts matching provided criteria
+ (object) - Account.
+ registeredBy (string) - The address which has registered the account.
+ registeredOn (number) - UNIX timestamp of account registration.
+ permissions (array) - A list of permissions granted to this account
+ accessLevel (number) - Access level of the account. Should be a non-negative integer.
+ organization (number) - Identifier of the organization the account belongs to.
+ address (string) - An address of the account.
+ email (string) - An email of the account.
+ active (boolean) - State of the account.
+ meta (object) - the metadata
+ code (number) - the status code
+ count (number) - the number of accounts returned
+ pagination (object)
+ hasNext (boolean) - shows if there is a next page
+ hasPrevious (boolean) - shows if there is a previous page
+ Body
{
"data":[
{
"address":"0x918eACF10eA2C47B001f761460Ed19607656f01C",
"email":"email1C@domain.com",
"fullName":null,
"accessLevel":100,
"organization":9,
"permissions":["create_asset", "create_event"],
"registeredBy":"0xC769C64a70ECA2606A927DC28DD947A5Dbec237B",
"registeredOn":1584685139,
"active":true
}],
"meta": {
"code": 200,
"count": 1
},
"pagination": {
"hasNext": false,
"hasPrevious": false
}
}
+ Response 400 (application/json)
Validation error
+ Body
+ Response 401 (application/json)
Authentication error
+ Body
+ Response 403 (application/json)
Invalid signature or missing manage_accounts permission
+ Body
+ Response 404 (application/json)
Requested account does not exist
+ Body
### /account2/info/{accountAddress}
#### Info account [GET]
__Warning__ Request sender needs to have "manage_accounts" permission
+ Parameters
+ accountAddress (string) - An address of the account
+ Request (application/json)
+ Headers
Accept: application/json
Authorization: AMB_TOKEN ...
+ Response 200 (application/json)
+ Attributes (object)
+ data (object)
+ registeredBy (string) - The address which has registered the account.
+ registeredOn (number) - UNIX timestamp of account registration.
+ permissions (array) - A list of permissions granted to this account
+ accessLevel (number) - Access level of the account. Should be a non-negative integer.
+ organization (number) - Identifier of the organization the account belongs to.
+ address (string) - An address of the account.
+ email (string) - An email of the account.
+ active (boolean) - State of the account.
+ meta (object)
+ code (number) - the status code
+ Body
{
"data": {
"address":"0x918eACF10eA2C47B001f761460Ed19607656f01C",
"email":"email1C@domain.com",
"fullName":null,
"accessLevel":100,
"organization":9,
"permissions":["create_asset", "create_event"],
"registeredBy":"0xC769C64a70ECA2606A927DC28DD947A5Dbec237B",
"registeredOn":1584685139,
"active":true
},
"meta": {
"code": 200
}
}
+ Response 400 (application/json)
Validation error
+ Body
+ Response 401 (application/json)
Authentication error
+ Body
+ Response 403 (application/json)
Invalid signature or missing register_accounts permission
+ Body
### /account2/create/{accountAddress}
#### Create account [POST]
__Warning__ Request sender needs to have "register_accounts" permission
+ Request (application/json)
+ Headers
Accept: application/json
Authorization: AMB_TOKEN ...
+ Parameters
+ address (string) - An address of the new account
+ Attributes (object)
+ permissions (array) - A list of permissions granted to this account. It is not possible to give permissions the request sender lacks.
+ accessLevel (number) - Access level of the account. Should be a non-negative integer. Cannot be higher than sender's accessLevel.
+ email (string) - Email for the account.
+ Body
{
"permissions" : ["register_accounts", "create_asset", "create_event"],
"accessLevel" : 100,
"email" : "email1C@domain.com"
}
+ Response 201 (application/json)
Created.
+ Body
{"data":
{
"address":"0x918eACF10eA2C47B001f761460Ed19607656f01C",
"email":"email1C@domain.com",
"fullName":null,
"accessLevel":100,
"organization":9,
"permissions":["create_asset", "create_event", "create_event"],
"registeredBy":"0xC769C64a70ECA2606A927DC28DD947A5Dbec237B",
"registeredOn":1584685139,
"active":true
}
}
+ Response 400 (application/json)
Validation error
+ Body
+ Response 401 (application/json)
Authentication error
+ Body
+ Response 403 (application/json)
Invalid signature or missing register_accounts permission
+ Body
### /account2/modify/{accountAddress}
#### Modify account [POST]
__Warning__ Request sender needs to have "manage_accounts" permission
It is not possible to modify protected accounts and accounts belonging to different organizations.
+ Parameters
+ accountAddress (string) - An address of the account
+ Request (application/json)
+ Headers
Accept: application/json
Authorization: AMB_TOKEN ...
+ Attributes (object)
+ permissions (array, optional) - A list of permissions granted to this account. It is not possible to give permissions the request sender lacks.
+ accessLevel (number, optional) - Access level of the account. Should be a non-negative integer. Cannot be higher than sender's accessLevel.
+ email (string, optional) - Email of the account.
+ Body
{
"permissions" : ["register_accounts", "create_asset"],
"accessLevel" : 0
}
+ Response 200 (application/json)
+ Body
{
"address": "0x162a44701727a31f457a53801cd181cd38eb5bbd",
"registeredBy": "0x345b44701723a31f457a534801cd181cd38eb5bcd",
"registeredOn": 32141243,
"permissions": ["register_accounts", "create_asset"],
"accessLevel": 4
}
+ Response 400 (application/json)
Validation error
+ Body
+ Response 401 (application/json)
Authentication error
+ Body
+ Response 403 (application/json)
Invalid signature or missing register_accounts permission
+ Body
## Group Assets
Assets are primary elements moving through a supply chain. The are the nouns of the system. They can represent an ingredient, product, package of products or any other type of container.
An Asset on its own function only as a handle for a Event stream. Because of this, they only contain an `idData` structure holding minimal information about their creation.
Assets are identified by an `assetId` field which is a sha3 hash calculated from the `content` field. \
### /assets/{assetId}
__ⓘ Note:__ Available only for Atlas node.
#### Fetch an asset by Id [GET]
Fetches asset with provided assetId in the system.
+ Parameters
+ assetId (string, required) - ID of an asset
+ Response 200 (application/json)
Asset with provided assetId
+ Attributes (object)
+ assetId (string) - Content-addressable identifier of the asset.
+ content (object) - All meaningful content of the asset, base of assetId.
+ signature (string) - elliptic-curve signature of the idData field signed with the creator's private address.
+ idData (object) - General information about an asset.
+ createdBy (string) - Public address of the asset creator.
+ timestamp (number) - UNIX timestamp of asset creation.
+ sequenceNumber (number) - Used to assure that all assets are unique
+ metadata (object) - Asset service data.
+ bundleId (string) - If the asset has already been added to a bundle, Id of the bundle holding the event
+ bundleTransactionHash (string) - If the asset has already been added to a bundle, identifier of the transaction on which the proof of bundle has been uploaded.
More info on the transaction can be found under `http://explorer.ambrosus.io/#/tx/{bundleTransactionHash}`
+ bundleProofBlock (number) - If the asset has already been added to a bundle, block number in which the proof of the bundle has been included
+ bundleUploadTimestamp (number) - If the asset has already been added to a bundle, timestamp of bundle proof upload
+ Body
{
"data":[
{
"_id":"5e672f4a80d54c1fc22754d2",
"assetId":"0x3450e3c846338bc2486fd6a3dc1738db8943d0bf4bc5426f571863b1b814a018",
"metadata":
{
"bundleId":"0x5042e9e79fc23bb938cf377bf5379d4287c26203c259d342eb2d1f23b181f353",
"bundleUploadTimestamp":1583820645,
"bundleProofBlock":38,
"bundleTransactionHash":"0x7757fef7f32f020fb1f23ce32a93b193fe0d14a70c2dbea9655cefa80e7348f7"
},
"content":{
"idData":{
"createdBy":"0x2D2a0BE476559200D87EdD128Bd31c100be74e0f",
"timestamp":1582616736,
"sequenceNumber":0
},
"signature":"0x669f6a33dafaa9c35953bbab201eba63ad4b6960252af398d7cea230c17ec5323dae8c637e8995a799da8c13aeb5101163876e3411e43852a1cb4c7669bc9cc21c"},
"repository":{}
}
],
"meta":{
"code":200,
"count":1
},
"pagination":{
"hasNext":false,
"next":"WzE1ODI2MTY3MzYseyIkb2lkIjoiNWU2NzJmNGE4MGQ1NGMxZmMyMjc1NGQyIn1d",
"hasPrevious":false,
"previous":"WzE1ODI2MTY3MzYseyIkb2lkIjoiNWU2NzJmNGE4MGQ1NGMxZmMyMjc1NGQyIn1d"
}
}
+ Response 404 (application/json)
No asset with such assetId found
+ Body
### /assets{?perPage,page,createdBy,fromTimestamp,toTimestamp,identifier}
__ⓘ Note:__ Available only for Atlas node. For Hermes use asset2/query.
#### Find assets [GET]
Finds assets satisfying provided criteria.
+ Parameters
+ perPage (integer, optional) - number of assets to return per page (limited to 100)
+ page (integer, optional) - number of page (more search results than specified in perPage parameter concludes more than one page)
+ createdBy (string, optional) - address of account that created targeting assets
+ fromTimestamp (integer, optional) - earliest timestamp for the asset
+ toTimestamp (integer, optional) - latest timestamp for the asset
+ identifier : identifier[{identifierType}]={identifierValue} (string, optional) - This syntax allows to query for assets that have an associated event containing data type `ambrosus.event.identifier` (see Events Data field section) with same identifier of same type. It is possible to find identifiers matching a pattern with help of the pattern decorator. You can use like this: identifier[vin]=pattern(3FRNF65N*). It supports 2 kinds of special characters:
- __*__ matches any string, including the null string.
- __?__ matches any single character
Note that patterns cannot have a special character as the first symbol for performance reasons. It is not possible to escape special characters.
+ Response 200 (application/json)
Up to 100 newest assets
+ Attributes (object)
+ results (array) - An array of assets.
+ (object) - Asset.
+ assetId (string) - Content-addressable identifier of the asset.
+ content (object) - All meaningful content of the asset, base of assetId.
+ signature (string) - elliptic-curve signature of the idData field signed with the creator's private address.
+ idData (object) - General information about an asset.
+ createdBy (string) - Public address of the asset creator.
+ timestamp (number) - UNIX timestamp of asset creation.
+ sequenceNumber (number) - Used to assure that all assets are unique
+ metadata (object) - Asset service data.
+ bundleId (string) - If the asset has already been added to a bundle, Id of the bundle holding the event
+ bundleTransactionHash (string) - If the asset has already been added to a bundle, identifier of the transaction on which the proof of bundle has been uploaded.
More info on the transaction can be found under `http://explorer.ambrosus.io/#/tx/{bundleTransactionHash}`
+ bundleProofBlock (number) - If the asset has already been added to a bundle, block number in which the proof of the bundle has been included
+ bundleUploadTimestamp (number) - If the asset has already been added to a bundle, timestamp of bundle proof upload
+ resultCount (number) - Total number of assets.
+ Body
{
"data":[
{
"_id":"5e672f4a80d54c1fc22754d2",
"assetId":"0x3450e3c846338bc2486fd6a3dc1738db8943d0bf4bc5426f571863b1b814a018",
"metadata":
{
"bundleId":"0x5042e9e79fc23bb938cf377bf5379d4287c26203c259d342eb2d1f23b181f353",
"bundleUploadTimestamp":1583820645,