KOIOS
Last updated
Last updated
In the previous section, we looked at cardano cli. Apart from Cardano Node, there is cardano dbsync. This helps in organizing blockchain data as sql database. Running Cardano node and Cardano dbsync needs high end machine and has to be online 24x7. KOIOS is a framework which is maintained by stakepool operators and provides API for end user usage. Regular users are rate limited to prevent DDOS attack and projects that want to use the service are provided with seperate path.
This section will talk about KOIOS. 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.
For more details read the sections in the KOIOS documentation
We will go bottom to top (from builder's eyes to run through the above) briefly:
Instance(s) : These are essentially PostgREST instances with the REST service attached to Postgres DB populated using cardano-db-sync. 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 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.
KOIOS Python
Koios API is a very useful tool for those who want to develop on Cardano, but don’t want or don’t have the resources and the knowledge to run a full node and cardano-db-sync. Some of the endpoints are GET endpoints, some are POST endpoints, and some of them have or need pagination, some of them don’t need pagination. Sometimes, when the API is overloaded, the requests are failing, and you need to retry the request. For all these reasons, it was decided to implement all the possible queries to the Koios API in a python module, which takes care internally of all these problems that need to be resolved. The result is this: https://pypi.org/project/koios-api/. The source code and the documentation are available on Github (https://github.com/cardano-apexpool/koios-api-python).
So you can write python programs and access blockchain data from dbsync servers using KOIOS. In this section only python is introduced. However these APIs are supported in other frameworks also like go, .NET and Java client