koios-artifacts
koios-artifacts copied to clipboard
Add a Query by Metadata Label
Is your feature request related to a problem? Please describe. There are instances where we would like to index an follow the history of a chain of metadata labels that may or may not be related to the minting or burning of tokens. In this case, there is currently no simple solution to querying all instances of a metadata label appearing in transactions from Koios.
Describe the solution you'd like An endpoint similar to that found in Blockfrost here. Fetching a list of transactions by label and allowing vertical filtering so we can request only the latest until we catch up to our last observed state.
Describe alternatives you've considered The primary alternative is needing to run an indexer such as Oura and listening for specific metadata tags appearing in all transactions but this tends to be much slower since you must parse through all transactions rather than leveraging database indexing.
Additional context I would recommend adding the block/transaction's absolute slot, timestamp, or some other field to the returned result set to minimize the number of queries needed to filter based on "already seen" results for those that are trying to maintain an index of only the latest transactions since their last check. i.e. Please give me all transactions and metadata where key = 867 and time >= 2025-08-16 00:00:03
Since this involves join on block/tx/tx_metadata tables, and input filter will be on tx_netadata (key) and optionally block (_after_block_height - inline with other endpoints), for joins to be optimal and have guardrail on dynamic URL filtering, to avoid some getaway queries - implementation checkpoints:
- Ensure created function is fully inline
- When _after_block_height is specified, instead of applying that on a where statement, use baseline tx_id (CTE if we have to inline function) to avoid race condition with 'where filter'
- The output will still contain usual epoch_no, epoch_slot_no, block_no, block_time fields to still allow filtering based on column. Additional input allows users to control the performance if they'd like to cut join records at source