-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathkoiosapi.yaml
More file actions
3353 lines (3286 loc) · 139 KB
/
Copy pathkoiosapi.yaml
File metadata and controls
3353 lines (3286 loc) · 139 KB
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
openapi: 3.0.2
info:
title: Koios API
version: 1.0.9
description: |
Koios is best described as a Decentralized and Elastic RESTful query layer for exploring data on Cardano blockchain to consume within applications/wallets/explorers/etc.
> Note: While we've done sufficient ground work - we're still going through testing/learning/adapting phase based on feedback. Feel free to give it a go, but just remember it is not yet finalized for production consumption and will be refreshed weekly (Saturday 8am UTC).
# Problems solved by Koios
- As the size of blockchain grows rapidly, we're looking at increasingly expensive resources and maintenance costs (financially as well as time-wise)
to maintain a scalable solution that will automatically failover and have health-checks, ensuring most synched versions are returned. With Koios, anyone is
free to either add their backend instance to the cluster, or use the query layer without running a node or cardano-db-sync instance themselves. There will be
health-checks for each endpoint to ensure that connections do not go to a dud backend with stale information.
- Moreover, folks who do put in tremendous amount of efforts to go through discovery phrase - are often ending up with local solutions, that may not be
consistent across the board (e.g. Live Stake queries across existing explorers). Since all the queries used by/for Koios layer is on GitHub, anyone can contribute
or leverage the query knowledge base, and help each other out while doing so. An additional endpoint added will only be load balanced between the servers that
pass the health-check for the endpoint.
- It is almost impossible to fetch some live data (for example, Live Stake against a pool) due to the cost of computation and amount of data on chain. For
such queries, many folks are already using different cache methods, or capturing ledger information from node. Wouldn't it be nice to have these crunched data that
take quite a few minutes to run be shared and available to be able to pick a relatively recent execution across the nodes? This will be available out of the box as part
of Koios API.
- There is also a worry when going through updates about feasibility/breaking changes/etc. that can become a bottleneck for providers. Since Koios participants
automatically receive failover support, they reduce impact of any subset of clusters going through update process.
- The lightweight query layers currently present are unfortunately closed source, centralised, and create a single point of failure. With Koios, our aim is to
give enough flexibility to all the participants to select their backend, or pick from any of the available ones instead.
- Bad human errors causing an outage? The bandwidth for Koios becomes better with more participation, but just in case there is not enough participation - we will
ensure that at least 4 trusted Koios instances across the globe will be around for the initial year, allowing for enough time for adoption to build up gradually.
- Flexibility to participate at different levels. A consumer of these services can participate with a complete independent instance (optionally extend existing ones), by running only certain parts (e.g. submit-api or PostgREST only), or simply consuming the API without running anything locally.
# Architecture
## How does Koios work?

We will go bottom to top (from builder's eyes to run through the above) briefly:
- *Instance(s)* : These are essentially [PostgREST](https://postgrest.org/en/latest/) instances with the REST service attached to Postgres DB populated using [cardano-db-sync](https://cardano-community.github.io/guild-operators/Build/dbsync/). Every consumer who is providing their own instance will be expected to serve at least a PostgREST instance, as this is what allows us to string instances together after health-checks. If using guild-operator setup instructions, these will be provisioned for you by setup scripts.
- *Health-check Services* : These are lightweight [HAProxy](http://www.haproxy.org) instances that will be gatekeepers for individual endpoints, handling health-checks, sample data verification, etc. A builder _may_ opt-in to run this monitoring service, and add their instance to GitHub repository. Again, setting up HAProxy will be part of setup scripts on guild-operator's repo for those interested.
- *DNS Routing* : These will be the entry points from monitoring layer to trusted instances that will route to health-check proxy services. We will be using at least two DNS servers ourselves to not have single point of failure, but that does not limit users to elect any of the other server endpoints instead, since the API works right from the PostgREST layer itself.
# API Usage
The endpoints served by Koios can be browsed from the left side bar of this site. You will find that almost each endpoint has an example that you can `Try` and will help you get an example in shell using cURL. For public queries, you do not need to register yourself - you can simply use them as per the examples provided on individual endpoints. But in addition, the [PostgREST API](https://postgrest.org/en/stable/api.html) used underneath provides a handful of features that can be quite handy for you to improve your queries to directly grab very specific information pertinent to your calls, reducing data you download and process.
## Vertical Filtering
Instead of returning entire row, you can elect which rows you would like to fetch from the endpoint by using the `select` parameter with corresponding columns separated by commas. See example below (first is complete information for tip, while second command gives us 3 columns we are interested in):<br><br>
``` bash
curl "https://api.koios.rest/api/v0/tip"
# [{"hash":"4d44c8a453e677f933c3df42ebcf2fe45987c41268b9cfc9b42ae305e8c3d99a","epoch":317,"abs_slot":51700871,"epoch_slot":120071,"block_height":6806994,"block_time":1643267162}]
curl "https://api.koios.rest/api/v0/blocks?select=epoch,epoch_slot,block_height"
# [{"epoch":317,"epoch_slot":120071,"block_height":6806994}]
```
## Horizontal Filtering
You can filter the returned output based on specific conditions using operators against a column within returned result. Consider an example where you would want to query blocks minted in first 3 minutes of epoch 250 (i.e. epoch_slot was less than 180). To do so your query would look like below:<br><br>
``` bash
curl "https://api.koios.rest/api/v0/blocks?epoch=eq.250&epoch_slot=lt.180"
# [{"hash":"8fad2808ac6b37064a0fa69f6fe065807703d5235a57442647bbcdba1c02faf8","epoch":250,"abs_slot":22636942,"epoch_slot":142,"block_height":5385757,"block_time":1614203233,"tx_count":65,"vrf_key":"vrf_vk14y9pjprzlsjvjt66mv5u7w7292sxp3kn4ewhss45ayjga5vurgaqhqknuu","pool":null,"op_cert_counter":2},
# {"hash":"9d33b02badaedc0dedd0d59f3e0411e5fb4ac94217fb5ee86719e8463c570e16","epoch":250,"abs_slot":22636800,"epoch_slot":0,"block_height":5385756,"block_time":1614203091,"tx_count":10,"vrf_key":"vrf_vk1dkfsejw3h2k7tnguwrauqfwnxa7wj3nkp3yw2yw3400c4nlkluwqzwvka6","pool":null,"op_cert_counter":2}]
```
Here, we made use of `eq.` operator to denote a filter of "value equal to" against `epoch` column. Similarly, we added a filter using `lt.` operator to denote a filter of "values lower than" against `epoch_slot` column. You can find a complete list of operators supported in PostgREST documentation (commonly used ones extracted below):
|Abbreviation|In PostgreSQL|Meaning |
|------------|-------------|-------------------------------------------|
|eq |`=` |equals |
|gt |`>` |greater than |
|gte |`>=` |greater than or equal |
|lt |`<` |less than |
|lte |`<=` |less than or equal |
|neq |`<>` or `!=` |not equal |
|like |`LIKE` |LIKE operator (use * in place of %) |
|in |`IN` |one of a list of values, e.g. `?a=in.("hi,there","yes,you")`|
|is |`IS` |checking for exact equality (null,true,false,unknown)|
|cs |`@>` |contains e.g. `?tags=cs.{example, new}` |
|cd |`<@` |contained in e.g. `?values=cd.{1,2,3}` |
|not |`NOT` |negates another operator |
|or |`OR` |logical `OR` operator |
|and |`AND` |logical `AND` operator |
## Pagination (offset/limit)
When you query any endpoint in PostgREST, the number of observations returned will be limited to a maximum of 1000 rows (set via `max-rows` config option in the `grest.conf` file. This - however - is a result of a paginated call, wherein the [ up to ] 1000 records you see without any parameters is the first page. If you want to see the next 1000 results, you can always append `offset=1000` to view the next set of results. But what if 1000 is too high for your use-case and you want smaller page? Well, you can specify a smaller limit using parameter `limit`, which will see shortly in an example below. The obvious question at this point that would cross your mind is - how do I know if I need to offset and what range I am querying? This is where headers come in to your aid.
The default headers returned by PostgREST will include a `Content-Range` field giving a range of observations returned. For large tables, this range could include a wildcard `*` as it is expensive to query exact count of observations from endpoint. But if you would like to get an estimate count without overloading servers, PostgREST can utilise Postgres's own maintenance thread results (which maintain stats for each table) to provide you a count, by specifying a header `"Profile: count=estimated"`.
Sounds confusing? Let's see this in practice, to hopefully make it easier.
Consider a simple case where I want query `blocks` endpoint for `block_height` column and focus on `content-range` header to monitor the rows we discussed above.<br><br>
``` bash
curl -s "https://api.koios.rest/api/v0/blocks?select=block_height" -I | grep -i content-range
# content-range: 0-999/*
```
As we can see above, the number of observations returned was 1000 (range being 0-999), but the total size was not queried to avoid wait times. Now, let's modify this default behaviour to query rows beyond the first 999, but this time - also add another clause to limit results by 500. We can do this using `offset=1000` and `limit=500` as below:<br><br>
``` bash
curl -s "https://api.koios.rest/api/v0/blocks?select=block_height&offset=1000&limit=500" -I | grep -i content-range
# content-range: 1000-1499/*
```
There is also another method to achieve the above, instead of adding parameters to the URL itself, you can specify a `Range` header as below to achieve something similar:<br><br>
``` bash
curl -s "https://api.koios.rest/api/v0/blocks?select=block_height" -H "Range: 1000-1499" -I | grep -i content-range
# content-range: 1000-1499/*
```
The above methods for pagination are very useful to keep your queries light as well as process the output in smaller pages, making better use of your resources and respecting server timeouts for response times.
## Ordering
You can set a sorting order for returned queries against specific column(s).
Consider example where you want to check `epoch` and `epoch_slot` for the first 5 blocks created by a particular pool, i.e. you can set order to ascending based on block_height column and add horizontal filter for that pool ID as below:<br><br>
``` bash
curl -s "https://api.koios.rest/api/v0/blocks?pool=eq.pool155efqn9xpcf73pphkk88cmlkdwx4ulkg606tne970qswczg3asc&order=block_height.asc&limit=5"
# [{"hash":"610b4c7bbebeeb212bd002885048cc33154ba29f39919d62a3d96de05d315706","epoch":236,"abs_slot":16594295,"epoch_slot":5495,"block_height":5086774,"block_time":1608160586,"tx_count":1,"vrf_key":"vrf_vk18x0e7dx8j37gdxftnn8ru6jcxs7n6acdazc4ykeda2ygjwg9a7ls7ns699","pool":"pool155efqn9xpcf73pphkk88cmlkdwx4ulkg606tne970qswczg3asc","op_cert_counter":1},
# {"hash":"d93d1db5275329ab695d30c06a35124038d8d9af64fc2b0aa082b8aa43da4164","epoch":236,"abs_slot":16597729,"epoch_slot":8929,"block_height":5086944,"block_time":1608164020,"tx_count":7,"vrf_key":"vrf_vk18x0e7dx8j37gdxftnn8ru6jcxs7n6acdazc4ykeda2ygjwg9a7ls7ns699","pool":"pool155efqn9xpcf73pphkk88cmlkdwx4ulkg606tne970qswczg3asc","op_cert_counter":1},
# {"hash":"dc9496eae64294b46f07eb20499ae6dae4d81fdc67c63c354397db91bda1ee55","epoch":236,"abs_slot":16598058,"epoch_slot":9258,"block_height":5086962,"block_time":1608164349,"tx_count":1,"vrf_key":"vrf_vk18x0e7dx8j37gdxftnn8ru6jcxs7n6acdazc4ykeda2ygjwg9a7ls7ns699","pool":"pool155efqn9xpcf73pphkk88cmlkdwx4ulkg606tne970qswczg3asc","op_cert_counter":1},
# {"hash":"6ebc7b734c513bc19290d96ca573a09cac9503c5a349dd9892b9ab43f917f9bd","epoch":236,"abs_slot":16601491,"epoch_slot":12691,"block_height":5087097,"block_time":1608167782,"tx_count":0,"vrf_key":"vrf_vk18x0e7dx8j37gdxftnn8ru6jcxs7n6acdazc4ykeda2ygjwg9a7ls7ns699","pool":"pool155efqn9xpcf73pphkk88cmlkdwx4ulkg606tne970qswczg3asc","op_cert_counter":1},
# {"hash":"2eac97548829fc312858bc56a40f7ce3bf9b0ca27ee8530283ccebb3963de1c0","epoch":236,"abs_slot":16602308,"epoch_slot":13508,"block_height":5087136,"block_time":1608168599,"tx_count":1,"vrf_key":"vrf_vk18x0e7dx8j37gdxftnn8ru6jcxs7n6acdazc4ykeda2ygjwg9a7ls7ns699","pool":"pool155efqn9xpcf73pphkk88cmlkdwx4ulkg606tne970qswczg3asc","op_cert_counter":1}]
```
## Response Formats
You can get the results from the PostgREST endpoints in CSV or JSON formats. The default response format will always be JSON, but if you'd like to switch, you can do so by specifying header `'Accept: text/csv'` or `'Accept: application/json'`.
Below is an example of JSON/CSV output making use of above to print first in JSON (default), and then override response format to CSV.<br><br>
``` bash
curl -s "https://api.koios.rest/api/v0/blocks?select=epoch,epoch_slot,block_time&limit=3"
# [{"epoch":318,"epoch_slot":27867,"block_time":1643606958},
# {"epoch":318,"epoch_slot":27841,"block_time":1643606932},
# {"epoch":318,"epoch_slot":27839,"block_time":1643606930}]
curl -s "https://api.koios.rest/api/v0/blocks?select=epoch,epoch_slot,block_time&limit=3" -H "Accept: text/csv"
# epoch,epoch_slot,block_time
# 318,28491,1643607582
# 318,28479,1643607570
# 318,28406,1643607497
```
## Limits
While use of Koios is completely free and there are no registration requirements to the usage, the monitoring layer will only restrict spam requests that can potentially cause high amount of load to backends. The emphasis is on using list of objects first, and then [bulk where available] query specific objects to drill down where possible - which forms higher performance results to consumer as well as instance provider. Some basic protection against patterns that could cause unexpected resource spikes are protected as per below:
- Burst Limit: A single IP can query an endpoint up to 100 times within 10 seconds (that's about 8.64 million requests within a day). The sleep time if a limit is crossed is minimal (60 seconds) for that IP - during which, the monitoring layer will return HTTP Status `429 - Too many requests`.
- Pagination/Limits: Any query results fetched will be paginated by 1000 records (you can reduce limit and or control pagination offsets on URL itself, see API > Pagination section for more details).
- Query timeout: If a query from server takes more than 30 seconds, it will return a HTTP Status of `504 - Gateway timeout`. This is because we would want to ensure you're using the queries optimally, and more often than not - it would indicate that particular endpoint is not optimised (or the network connectivity is not optimal between servers).
Yet, there may be cases where the above restrictions may need exceptions (for example, an explorer or a wallet might need more connections than above - going beyond the Burst Limit). For such cases, it is best to approach the team and we can work towards a solution.
# Community projects
A big thank you to the following projects who are already starting to use Koios from early days:
## CLI
- [Koios CLI in GoLang](https://github.com/cardano-community/koios-cli)
## Libraries
- [.Net SDK](https://github.com/CardanoSharp/cardanosharp-koios)
- [Go Client](https://github.com/cardano-community/koios-go-client)
- [Java Client](https://github.com/cardano-community/koios-java-client)
## Community Projects/Tools
- [Building On Cardano](https://buildingoncardano.com)
- [CardaStat](cardastat.info)
- [CNFT.IO](https://cnft.io)
- [CNTools](https://cardano-community.github.io/guild-operators/Scripts/cntools/)
- [Dandelion](https://dandelion.link)
- [Eternl](https://eternl.io/)
- [PoolPeek](https://poolpeek.com)
- [TosiDrop](https://tosidrop.io)
# FAQ
### Is there a price attached to using services?
For most of the queries, there are no charges. But there are DDoS protection and strict timeout rules (see API Usage) that may prevent heavy consumers from using this *remotely* (for which, there should be an interaction to ensure the usage is proportional to sizing and traffic expected).
### Who are the folks behind Koios?
It will be increasing list of community builders. But for initial think-tank and efforts, the work done is primarily by [guild-operators](https://cardano-community.github.io/guild-operators)
who are a well-recognised team of members behind Cardano tools like CNTools, gLiveView, topologyUpdater, etc. We also run a parallel a short (60-min) epoch blockchain, viz, guild used by many
for experiments.
### I am only interested in collaborating on queries, where can I find the code and how to collaborate?
All the Postgres codebase against db-sync instance is available on guild-operator's github repo [here](https://github.com/cardano-community/guild-operators/tree/alpha/files/grest/rpc). Feel free to raise an issue/PR to discuss anything related to those queries.
### I am not sure how to set up an instance. Is there an easy start guide?
Yes, there is a setup script (expect you to read carefully the help section) and instructions [here](https://cardano-community.github.io/guild-operators/Build/grest/). Should you need any assistance, feel free to hop in to the [discussion group](https://t.me/joinchat/+zE4Lce_QUepiY2U1).
### Too much reading, I want to discuss in person
There are bi-weekly calls held that anyone is free to join - or you can drop in to the [telegram group](https://t.me/+zE4Lce_QUepiY2U1) and start a discussion from there.
x-logo:
url: "https://api.koios.rest/koios.png"
servers:
- url: https://api.koios.rest/api/v0
- url: https://guild.koios.rest/api/v0
- url: https://testnet.koios.rest/api/v0
paths:
/tip: #RPC
get:
tags:
- Network
responses:
"200":
description: Array of block summary (limit+paginated)
content:
application/json:
schema:
$ref: "#/components/schemas/tip"
"400":
$ref: "#/components/responses/BadRequest"
"401":
$ref: "#/components/responses/Unauthorized"
"404":
$ref: "#/components/responses/NotFound"
summary: Query Chain Tip
description: Get the tip info about the latest block seen by chain
/genesis: #RPC
get:
tags:
- Network
responses:
"200":
description: Array of genesis parameters used to start each era on chain
content:
application/json:
schema:
$ref: "#/components/schemas/genesis"
"400":
$ref: "#/components/responses/BadRequest"
"401":
$ref: "#/components/responses/Unauthorized"
"404":
$ref: "#/components/responses/NotFound"
summary: Get Genesis info
description: Get the Genesis parameters used to start specific era on chain
/totals: #RPC
get:
tags:
- Network
parameters:
- $ref: "#/components/parameters/_epoch_no"
responses:
"200":
description: Array of supply/reserves/utxo/fees/treasury stats
content:
application/json:
schema:
$ref: "#/components/schemas/totals"
"400":
$ref: "#/components/responses/BadRequest"
"401":
$ref: "#/components/responses/Unauthorized"
"404":
$ref: "#/components/responses/NotFound"
summary: Get historical tokenomic stats
description: >-
Get the circulating utxo, treasury, rewards, supply and reserves in
lovelace for specified epoch, all epochs if empty
/epoch_info: #RPC
get:
tags:
- Epoch
parameters:
- $ref: "#/components/parameters/_epoch_no"
responses:
"200":
description: Array of detailed summary for each epoch
content:
application/json:
schema:
$ref: "#/components/schemas/epoch_info"
"400":
$ref: "#/components/responses/BadRequest"
"401":
$ref: "#/components/responses/Unauthorized"
"404":
$ref: "#/components/responses/NotFound"
summary: Epoch Information
description: Get the epoch information, all epochs if no epoch specified
/epoch_params: #RPC
get:
tags:
- Epoch
parameters:
- $ref: "#/components/parameters/_epoch_no"
responses:
"200":
description: Array of protocol parameters for each epoch
content:
application/json:
schema:
$ref: "#/components/schemas/epoch_params"
"400":
$ref: "#/components/responses/BadRequest"
"401":
$ref: "#/components/responses/Unauthorized"
"404":
$ref: "#/components/responses/NotFound"
summary: Epoch's Protocol Parameters
description: >-
Get the protocol parameters for specific epoch, returns information
about all epochs if no epoch specified
/epoch_block_protocols: #RPC
get:
tags:
- Epoch
parameters:
- $ref: "#/components/parameters/_epoch_no"
responses:
"200":
description: Array of distinct block protocol versions counts in epoch
content:
application/json:
schema:
$ref: "#/components/schemas/epoch_block_protocols"
"400":
$ref: "#/components/responses/BadRequest"
"401":
$ref: "#/components/responses/Unauthorized"
"404":
$ref: "#/components/responses/NotFound"
summary: Epoch's Block Protocols
description: >-
Get the information about block protocol distribution in epoch
/blocks:
get:
tags:
- Block
responses:
"200":
description: Array of block information
content:
application/json:
schema:
$ref: "#/components/schemas/blocks"
"400":
$ref: "#/components/responses/BadRequest"
"401":
$ref: "#/components/responses/Unauthorized"
"404":
$ref: "#/components/responses/NotFound"
summary: Block List
description: Get summarised details about all blocks (paginated - latest first)
/block_info: #RPC
post:
tags:
- Block
requestBody:
$ref: "#/components/requestBodies/block_hashes"
responses:
"200":
description: Array of detailed block information
content:
application/json:
schema:
$ref: "#/components/schemas/block_info"
"400":
$ref: "#/components/responses/BadRequest"
"401":
$ref: "#/components/responses/Unauthorized"
"404":
$ref: "#/components/responses/NotFound"
summary: Block Information
description: Get detailed information about a specific block
/block_txs: #RPC
post:
tags:
- Block
requestBody:
$ref: "#/components/requestBodies/block_hashes"
responses:
"200":
description: Array of transactions hashes
content:
application/json:
schema:
$ref: "#/components/schemas/block_txs"
"400":
$ref: "#/components/responses/BadRequest"
"401":
$ref: "#/components/responses/Unauthorized"
"404":
$ref: "#/components/responses/NotFound"
summary: Block Transactions
description: Get a list of all transactions included in provided blocks
/tx_info: #RPC
post:
tags:
- Transactions
requestBody:
$ref: "#/components/requestBodies/tx_ids"
responses:
"200":
description: Array of detailed information about transaction(s)
content:
application/json:
schema:
$ref: "#/components/schemas/tx_info"
"400":
$ref: "#/components/responses/BadRequest"
"401":
$ref: "#/components/responses/Unauthorized"
"404":
$ref: "#/components/responses/NotFound"
summary: Transaction Information
description: Get detailed information about transaction(s)
/tx_utxos: #RPC
post:
tags:
- Transactions
requestBody:
$ref: "#/components/requestBodies/tx_ids"
responses:
"200":
description: Array of inputs and outputs for given transaction(s)
content:
application/json:
schema:
$ref: "#/components/schemas/tx_utxos"
"400":
$ref: "#/components/responses/BadRequest"
"401":
$ref: "#/components/responses/Unauthorized"
"404":
$ref: "#/components/responses/NotFound"
summary: Transaction UTxOs
description: Get UTxO set (inputs/outputs) of transactions.
/tx_metadata: #RPC
post:
tags:
- Transactions
requestBody:
$ref: "#/components/requestBodies/tx_ids"
responses:
"200":
description: Array of metadata information present in each of the transactions queried
content:
application/json:
schema:
$ref: "#/components/schemas/tx_metadata"
"400":
$ref: "#/components/responses/BadRequest"
"401":
$ref: "#/components/responses/Unauthorized"
"404":
$ref: "#/components/responses/NotFound"
summary: Transaction Metadata
description: Get metadata information (if any) for given transaction(s)
/tx_metalabels: #RPC
get:
tags:
- Transactions
responses:
"200":
description: Array of known metadata labels
content:
application/json:
schema:
$ref: "#/components/schemas/tx_metalabels"
"400":
$ref: "#/components/responses/BadRequest"
"401":
$ref: "#/components/responses/Unauthorized"
"404":
$ref: "#/components/responses/NotFound"
summary: Transaction Metadata Labels
description: Get a list of all transaction metalabels
/submittx: #submit-api
post:
tags:
- Transactions
requestBody:
$ref: "#/components/requestBodies/txbin"
x-code-samples:
- lang: "Shell"
source: |
# Assuming ${data} is a raw binary serialized transaction on the file-system.
# If using a CLI-generated tx file, please ensure to deserialise (using `xxd -p -r <<< $(jq .cborHex ${tx.signed}) > ${data}`) first before submitting.
curl -X POST \
--header "Content-Type: application/cbor" \
--data-binary ${data} https://api.koios.rest/api/v0/submittx
responses:
"202":
description: OK
content:
application/json:
schema:
description: The transaction id.
type: string
format: hex
minLength: 64
maxLength: 64
example: 92bcd06b25dfbd89b578d536b4d3b7dd269b7c2aa206ed518012cffe0444d67f
"400":
description: An error occured while submitting transaction.
summary: Submit Transaction
description: Submit an already serialized transaction to the network.
/tx_status: #RPC
post:
tags:
- Transactions
requestBody:
$ref: "#/components/requestBodies/tx_ids"
responses:
"200":
description: Array of transaction confirmation counts
content:
application/json:
schema:
$ref: "#/components/schemas/tx_status"
"400":
$ref: "#/components/responses/BadRequest"
"401":
$ref: "#/components/responses/Unauthorized"
"404":
$ref: "#/components/responses/NotFound"
summary: Transaction Status (Block Confirmations)
description: Get the number of block confirmations for a given transaction hash list
/address_info: #RPC
post:
tags:
- Address
requestBody:
$ref: "#/components/requestBodies/payment_addresses"
responses:
"200":
description: Array of address information
content:
application/json:
schema:
$ref: "#/components/schemas/address_info"
"400":
$ref: "#/components/responses/BadRequest"
"401":
$ref: "#/components/responses/Unauthorized"
"404":
$ref: "#/components/responses/NotFound"
summary: Address Information
description: Get address info - balance, associated stake address (if any) and UTxO set for given addresses
/address_txs: #RPC
post:
tags:
- Address
requestBody:
$ref: "#/components/requestBodies/address_txs"
responses:
"200":
description: Array of transaction hashes
content:
application/json:
schema:
$ref: "#/components/schemas/address_txs"
"400":
$ref: "#/components/responses/BadRequest"
"401":
$ref: "#/components/responses/Unauthorized"
"404":
$ref: "#/components/responses/NotFound"
summary: Address Transactions
description: Get the transaction hash list of input address array, optionally filtering after specified block height (inclusive)
/address_assets: #RPC
post:
tags:
- Address
requestBody:
$ref: "#/components/requestBodies/payment_addresses"
responses:
"200":
description: Array of address-owned assets
content:
application/json:
schema:
$ref: "#/components/schemas/address_assets"
"400":
$ref: "#/components/responses/BadRequest"
"401":
$ref: "#/components/responses/Unauthorized"
"404":
$ref: "#/components/responses/NotFound"
summary: Address Assets
description: Get the list of all the assets (policy, name and quantity) for given addresses
/credential_txs: #RPC
post:
tags:
- Address
requestBody:
$ref: "#/components/requestBodies/credential_txs"
responses:
"200":
description: Array of transaction hashes
content:
application/json:
schema:
$ref: "#/components/schemas/credential_txs"
"400":
$ref: "#/components/responses/BadRequest"
"401":
$ref: "#/components/responses/Unauthorized"
"404":
$ref: "#/components/responses/NotFound"
summary: Transactions from payment credentials
description: Get the transaction hash list of input payment credential array, optionally filtering after specified block height (inclusive)
/account_list:
get:
tags:
- Account
responses:
"200":
description: Array of account (stake address) IDs
content:
application/json:
schema:
$ref: "#/components/schemas/account_list"
"400":
$ref: "#/components/responses/BadRequest"
"401":
$ref: "#/components/responses/Unauthorized"
"404":
$ref: "#/components/responses/NotFound"
summary: Account List
description: Get a list of all accounts
/account_info: #RPC
post:
tags:
- Account
requestBody:
$ref: "#/components/requestBodies/stake_addresses"
responses:
"200":
description: Array of account information
content:
application/json:
schema:
$ref: "#/components/schemas/account_info"
"400":
$ref: "#/components/responses/BadRequest"
"401":
$ref: "#/components/responses/Unauthorized"
"404":
$ref: "#/components/responses/NotFound"
summary: Account Information
description: Get the account information for given stake addresses (accounts)
/account_info_cached: #RPC
post:
tags:
- Account
requestBody:
$ref: "#/components/requestBodies/stake_addresses"
responses:
"200":
description: Array of account information
content:
application/json:
schema:
$ref: "#/components/schemas/account_info"
"400":
$ref: "#/components/responses/BadRequest"
"401":
$ref: "#/components/responses/Unauthorized"
"404":
$ref: "#/components/responses/NotFound"
summary: Account Information (Cached)
description: Get the cached account information for given stake addresses (accounts)
/account_rewards: #RPC
post:
tags:
- Account
requestBody:
$ref: "#/components/requestBodies/stake_addresses_with_epoch_no"
responses:
"200":
description: Array of reward history information
content:
application/json:
schema:
$ref: "#/components/schemas/account_rewards"
"400":
$ref: "#/components/responses/BadRequest"
"401":
$ref: "#/components/responses/Unauthorized"
"404":
$ref: "#/components/responses/NotFound"
summary: Account Rewards
description: >-
Get the full rewards history (including MIR) for given stake addresses (accounts)
/account_updates: #RPC
post:
tags:
- Account
requestBody:
$ref: "#/components/requestBodies/stake_addresses"
responses:
"200":
description: Array of account updates information
content:
application/json:
schema:
$ref: "#/components/schemas/account_updates"
"400":
$ref: "#/components/responses/BadRequest"
"401":
$ref: "#/components/responses/Unauthorized"
"404":
$ref: "#/components/responses/NotFound"
summary: Account Updates
description: >-
Get the account updates (registration, deregistration, delegation and
withdrawals) for given stake addresses (accounts)
/account_addresses: #RPC
post:
tags:
- Account
requestBody:
$ref: "#/components/requestBodies/stake_addresses"
responses:
"200":
description: Array of payment addresses
content:
application/json:
schema:
$ref: "#/components/schemas/account_addresses"
"400":
$ref: "#/components/responses/BadRequest"
"401":
$ref: "#/components/responses/Unauthorized"
"404":
$ref: "#/components/responses/NotFound"
summary: Account Addresses
description: Get all addresses associated with given staking accounts
/account_assets: #RPC
post:
tags:
- Account
requestBody:
$ref: "#/components/requestBodies/stake_addresses"
responses:
"200":
description: Array of assets owned by account
content:
application/json:
schema:
$ref: "#/components/schemas/account_assets"
"400":
$ref: "#/components/responses/BadRequest"
"401":
$ref: "#/components/responses/Unauthorized"
"404":
$ref: "#/components/responses/NotFound"
summary: Account Assets
description: Get the native asset balance of given accounts
/account_history: #RPC
post:
tags:
- Account
requestBody:
$ref: "#/components/requestBodies/stake_addresses_with_epoch_no"
responses:
"200":
description: Array of active stake values per epoch
content:
application/json:
schema:
$ref: "#/components/schemas/account_history"
"400":
$ref: "#/components/responses/BadRequest"
"401":
$ref: "#/components/responses/Unauthorized"
"404":
$ref: "#/components/responses/NotFound"
summary: Account History
description: Get the staking history of given stake addresses (accounts)
/asset_list:
get:
tags:
- Asset
responses:
"200":
description: Array of policy IDs and asset names
content:
application/json:
schema:
$ref: "#/components/schemas/asset_list"
"400":
$ref: "#/components/responses/BadRequest"
"401":
$ref: "#/components/responses/Unauthorized"
"404":
$ref: "#/components/responses/NotFound"
summary: Asset List
description: Get the list of all native assets (paginated)
/asset_address_list: #RPC
get:
tags:
- Asset
parameters:
- $ref: "#/components/parameters/_asset_policy"
- $ref: "#/components/parameters/_asset_name"
responses:
"200":
description: Array of payment addresses holding the given token (including balances)
content:
application/json:
schema:
$ref: "#/components/schemas/asset_address_list"
"400":
$ref: "#/components/responses/BadRequest"
"401":
$ref: "#/components/responses/Unauthorized"
"404":
$ref: "#/components/responses/NotFound"
summary: Asset Address List
description: Get the list of all addresses holding a given asset
/asset_info: #RPC
get:
tags:
- Asset
parameters:
- $ref: "#/components/parameters/_asset_policy"
- $ref: "#/components/parameters/_asset_name"
responses:
"200":
description: Array of detailed asset information
content:
application/json:
schema:
$ref: "#/components/schemas/asset_info"
"400":
$ref: "#/components/responses/BadRequest"
"401":
$ref: "#/components/responses/Unauthorized"
"404":
$ref: "#/components/responses/NotFound"
summary: Asset Information
description: Get the information of an asset including first minting & token registry metadata
/asset_history: #RPC
get:
tags:
- Asset
parameters:
- $ref: "#/components/parameters/_asset_policy"
- $ref: "#/components/parameters/_asset_name"
responses:
"200":
description: Array of asset mint/burn history
content:
application/json:
schema:
$ref: "#/components/schemas/asset_history"
"400":
$ref: "#/components/responses/BadRequest"
"401":
$ref: "#/components/responses/Unauthorized"
"404":
$ref: "#/components/responses/NotFound"
summary: Asset History
description: Get the mint/burn history of an asset
/asset_policy_info: #RPC
get:
tags:
- Asset
parameters:
- $ref: "#/components/parameters/_asset_policy"
responses:
"200":
description: Array of detailed information of assets under the same policy
content:
application/json:
schema:
$ref: "#/components/schemas/asset_policy_info"
"400":
$ref: "#/components/responses/BadRequest"
"401":
$ref: "#/components/responses/Unauthorized"
"404":
$ref: "#/components/responses/NotFound"
summary: Asset Policy Information
description: Get the information for all assets under the same policy
/asset_summary: #RPC
get:
tags:
- Asset
parameters:
- $ref: "#/components/parameters/_asset_policy"
- $ref: "#/components/parameters/_asset_name"
responses:
"200":
description: Array of asset summary information
content:
application/json:
schema:
$ref: "#/components/schemas/asset_summary"
"400":
$ref: "#/components/responses/BadRequest"
"401":
$ref: "#/components/responses/Unauthorized"
"404":
$ref: "#/components/responses/NotFound"
summary: Asset Summary
description: Get the summary of an asset (total transactions exclude minting/total wallets include only wallets with asset balance)
/asset_txs: #RPC
get:
tags:
- Asset
parameters:
- $ref: "#/components/parameters/_asset_policy"
- $ref: "#/components/parameters/_asset_name"
- $ref: "#/components/parameters/_after_block_height"
- $ref: "#/components/parameters/_history"
responses:
"200":
description: Array of Tx hashes that included the given asset
content:
application/json:
schema:
$ref: "#/components/schemas/asset_txs"
"400":
$ref: "#/components/responses/BadRequest"
"401":
$ref: "#/components/responses/Unauthorized"
"404":
$ref: "#/components/responses/NotFound"
summary: Asset Transactions
description: Get the list of current or all asset transaction hashes (newest first)
/pool_list: #RPC
get:
tags:
- Pool
responses:
"200":
description: Array of pool IDs and tickers
content:
application/json:
schema:
$ref: "#/components/schemas/pool_list"
"400":
$ref: "#/components/responses/BadRequest"
"401":
$ref: "#/components/responses/Unauthorized"
"404":
$ref: "#/components/responses/NotFound"
summary: Pool List
description: A list of all currently registered/retiring (not retired) pools
/pool_info: #RPC
post:
tags:
- Pool
requestBody:
$ref: "#/components/requestBodies/pool_ids"
responses:
"200":
description: Array of pool information
content:
application/json:
schema:
$ref: "#/components/schemas/pool_info"
"400":
$ref: "#/components/responses/BadRequest"
"401":
$ref: "#/components/responses/Unauthorized"
"404":
$ref: "#/components/responses/NotFound"
summary: Pool Information
description: Current pool statuses and details for a specified list of pool ids
/pool_stake_snapshot: #RPC
get:
tags:
- Pool
parameters:
- $ref: "#/components/parameters/_pool_bech32"
responses:
"200":
description: Array of pool stake information for 3 snapshots
content:
application/json: