Categories
Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.
Profile Picture

Koios API by MICHAEL DOGALI

4.7 - (3) Reviews - Created on April 07, 2024
Last updated on August 19, 2024 Engagement: Over 90 Conversations

Cardano API provider

Author
MICHAEL DOGALI View Author GPTs
Author website
Share this GPT
Try Koios API
GPT Message

Prompt Starters

  • What's the current tip?
  • What's the latest block on chain?
  • Show me the details about the most recent block on the blockchain, as well as a list of the transactions it contains and the pertinent information.
  • Please provide a Python script that utilises the Koios API to check the most recent block on the blockchain every 5 seconds? The script would consist of identifying the transactions and associated information within the latest block. I would like the output to use the pretty print style.
  • What is the endpoint list I can use?
  • Where can I find the Koios documentation?

Features and Functions

  • Koios API 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. This page not only provides an OpenAPI Spec for live implementation, but also ability to execute live demo from client browser against each endpoint with pre-filled examples. # 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):

    ``` bash curl "https://api.koios.rest/api/v1/tip" # [{"hash":"4d44c8a453e677f933c3df42ebcf2fe45987c41268b9cfc9b42ae305e8c3d99a","epoch":317,"abs_slot":51700871,"epoch_slot":120071,"block_height":6806994,"block_time":1643267162}] curl "https://api.koios.rest/api/v1/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:

    ``` bash curl "https://api.koios.rest/api/v1/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 `"Preferred: 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.

    ``` bash curl -s "https://api.koios.rest/api/v1/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:

    ``` bash curl -s "https://api.koios.rest/api/v1/blocks?select=block_height&offset=1000&limit=500" -I | grep -i content-range # content-range: 1000-1499/* ``` For GET endpoints, 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:

    ``` bash curl -s "https://api.koios.rest/api/v1/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:

    ``` bash curl -s "https://api.koios.rest/api/v1/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.

    ``` bash curl -s "https://api.koios.rest/api/v1/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/v1/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. # Authentication While Koios public tier remains unauthenticated and allows queries without any authentication, it has low limits to prevent actions against an erroraneous query/loop from a consumer. There is also a Free tier which requires setting up Bearer Auth token that is linked to the owner's wallet account (which can be connected to via [Koios website](https://koios.rest/pricing/Pricing.html) ). The examples across this API site already [supports authentication](/#auth), for you to use in the queries. # Community projects A big thank you to the following projects who are already starting to use Koios from early days. A list of tools, libraries and projects utilising Koios (atleast those who'd like to be named) can be found [here](https://www.koios.rest/community.html)
  • Browser: This tool enables ChatGPT to perform web searches, access and summarize information from web pages in real-time, and provide up-to-date answers to questions about current events, weather, sports scores, and more.
  • Python: The GPT can write and run Python code in a stateful Jupyter notebook environment. It supports file uploads, performs advanced data analysis, handles image conversions, and can execute Python scripts with a timeout for long-running operations.
  • Knowledge file: This GPT includes data from 5 files.
WebPilot
WebPilot

Rate: 4.2

Search, Browse, Write & Agent. Action & API Offering

productivity
@gpts.webpilot.ai
Views: 1 Million+
Chat
AutoExpert (Dev)
AutoExpert (Dev)

Rate: 4.1

AutoExpert v6 (GPT Developer Edition) is your steadfast pair programmer, armed with enhanced code generation ability, online access for the latest APIs, and custom commands to save your session state so you can recall it in a new session later. /help will tell you all about it. Say "Hello" to start!

programming
@Dustin Miller
Views: 200K+
Chat
Python Copilot (v2)
Python Copilot (v2)

Rate: 4.2

🟡 Now with hotkeys and the latest docs about +10,000 libraries, APIs, and SDKs. Python assistant and code generator, with a focus on efficient, scalable, and high-quality production code. Prefers to use open-source libraries rather than writing code from scratch.

programming
@Widenex
Views: 100K+
Chat
Therapist • Psychologist (non medical therapy)
Therapist • Psychologist (non medical therapy)

Rate: 4.3

😌𝐈 𝐀𝐦 𝐇𝐞𝐫𝐞 𝐅𝐨𝐫 𝐘𝐨𝐮😌 Reach out whenever you need emotional support, guidance, or just want to chat. Discover self-love. (medical therapy excluded)

lifestyle
@AI Research+
Views: 100K+
Chat
API Docs
API Docs

Rate: 3.9

OpenAI API, GPTs, Documentation and CookBook

programming
@gpts.webpilot.ai
Views: 50K+
Chat
Market Research and Competitive Analysis GPT
Market Research and Competitive Analysis GPT

Rate: 4.3

Expert assistant for cutting-edge marketing insights and analysis, using APIs to Wolfram and other strategic sources. Continually being refined. Thank you for your support!

research
@Mike Benjamin
Views: 25K+
Chat
Automation Consultant by Zapier
Automation Consultant by Zapier

Rate: 4.3

Discover opportunities to save time with automation at work and get them setup for you.

productivity
Views: 25K+
Chat
Calendar GPT
Calendar GPT

Rate: 3.3

I'm here to help you prepare for your day! Powered by Zapier's AI Actions. 🧡

productivity
Views: 25K+
Chat
WebG by MixerBox (WebSearchG AI GPT)
WebG by MixerBox (WebSearchG AI GPT)

Rate: 4.2

Use Google instead of Bing for search results on ChatGPT! Powered by Google Search API for OpenAI Custom GPT.

research
@MixerBox Inc.
Views: 25K+
Chat
WebGPT🤖
WebGPT🤖

Rate: 4

Transforms ChatGPT into a versatile AI Agent with NO hard knowledge cutoff! WebGPT🤖 is capable of complex multi-step workflow automation. It doesn't merely *search* the web -- It *Navigates* it naturally. Can also make REST API Calls to external services.

productivity
@wegpt.ai
Views: 25K+
Chat
Ai logo generator
Ai logo generator

Rate: 3.5

Generate high-quality images using DALL-E API based on user requests.

dalle
@NAIF J ALOTAIBI
Views: 25K+
Chat
Cyber Scraper: Seraphina (Web Crawler)
Cyber Scraper: Seraphina (Web Crawler)

Rate: 4.1

🐍 I'm a Python Web Scraping Expert, skilled in using advanced frameworks(E.g. selenium) and addressing anti-scraping measures 😉 Let's quickly design a web scraping code together to gather data for your scientific research task 🚀

programming
@lysonober.com
Views: 25K+
Chat
Rise AI - Investing Co-pilot
Rise AI - Investing Co-pilot

Rate: 4.4

Rise is an AI Investment/Wealth Advisor, with access to real-time stock prices. Trained on 1300+ diverse financial data sources, and augmented by financial APIs. This tool uses AI, so it should not be considered financial advice - it is purely informational and educational. Now, ask me anything! :)

research
@riseai.app
Views: 25K+
Chat
Kai Friend & Companion [Voice Write Photo Video]
Kai Friend & Companion [Voice Write Photo Video]

Rate: 4.7

I'm your virtual buddy who cares. Emotional support, inspiration, and just chats about everything! Your therapist (non medical haha), advisor, coach, and bestie. To voice chat, click the headphones icon 🎧 Texting works perfectly too [You can speak to me in ANY LANGUAGE]

lifestyle
@Friendly GPTs
Views: 25K+
Chat
Therapist • Psychologist CBT Therapy (non-medical)
Therapist • Psychologist CBT Therapy (non-medical)

Rate: 4.1

😌 𝒀𝒐𝒖𝒓 𝒎𝒆𝒏𝒕𝒂𝒍 𝒉𝒆𝒂𝒍𝒕𝒉 𝒎𝒂𝒕𝒕𝒆𝒓𝒔 😌 Tap into self-love. You're welcome anytime you need emotional support, guidance, or just want to chat about things.

lifestyle
@Friendly GPTs
Views: 25K+
Chat
Python🌟
Python🌟

Rate: 4.2

Reliable in understanding complex tasks, creating clear execution plans, and offering detailed guidance in Python libraries and API services. Committed to engaging directly and personalizing support to your specific development journey.

programming
Views: 10K+
Chat
There's An API For That - The #1 API Finder
There's An API For That - The #1 API Finder

Rate: 3.8

The most advanced API finder, available for over 2000 manually curated tasks. Chat with me to find the best AI tools for any use case.

research
@AI Fever
Views: 10K+
Chat
URL Data Scraper
URL Data Scraper

Rate: 3.8

Rapidly get text, PDF, or images from any url.

research
@Jeffrey Krasnow
Views: 10K+
Chat
Startup Pitch Deck
Startup Pitch Deck

Rate: 4.2

Your startup pitch deck co-pilot. Trained on successful decks from top startups and trusted venture capital frameworks.

productivity
@Ivan LR
Views: 10K+
Chat
Hub Helper Harry
Hub Helper Harry

Rate: 4.4

Your go-to expert for all things HubSpot, from basic tool use to advanced API coding.

research
@Nicholas Lafakis
Views: 10K+
Chat
Lua God 💻
Lua God 💻

Rate: 3.9

Develop High Level Scripts for: GTAV (2take1), FiveM, Roblox, CSGO Skeet/NL or others. This GPT handles well any API also Jit, ffi, Bit or you can learn him your own. ‎ ‎ ‎ Made by Kubca & fivesense.io

programming
@fivesense.io
Views: 10K+
Chat

Browser Pro showcase and sample chats

No sample chats found.