README
¶
Koios CLI
Koios API is Elastic Cardano Query Layer!
A consistent query layer for developers to build upon Cardano, with
multiple, redundant endpoints that allow $$for easy scalability.
Development Status
Usage
see koios-cli -h
for available commands
List of API commands
koios-cli api --help
NAME:
koios-cli - Koios CLI Client
USAGE:
koios-cli [global options] command [command options] [arguments...]
VERSION:
(devel)
AUTHOR:
The Cardano Community Authors
COMMANDS:
help, h Shows a list of commands or help for one command
KOIOS REST API:
api Interact with Koios API REST endpoints
GLOBAL OPTIONS:
--help, -h show help (default: false)
--version, -v print the version (default: false)
COPYRIGHT:
(c) 2022 The Cardano Community
[mkungla@howi-main koios-cli]$ go run . api -h
NAME:
koios-cli api - Interact with Koios API REST endpoints
USAGE:
koios-cli api command [command options] [arguments...]
COMMANDS:
tip Get the tip info about the latest block seen by chain.
genesis Get the Genesis parameters used to start specific era on chain.
totals Get the circulating utxo, treasury rewards, supply and reserves in lovelace for specified epoch, all epochs if empty.
epoch-info Get the epoch information, all epochs if no epoch specified.
epoch-params Get the protocol parameters for specific epoch, returns information about all epochs if no epoch specified.
epoch-block-protocols Get the information about block protocol distribution in epoch
blocks Get summarised details about all blocks (paginated - latest first).
blocks-info Get detailed information about a blocks.
block-info Get detailed information about a specific block.
block-txs Get a list of all transactions included in a provided block.
txs-info Get detailed information about transaction(s).
tx-info Get detailed information about single transaction.
tx-utxos Get UTxO set (inputs/apiOutputs) of transactions.
txs-metadata Get metadata information (if any) for given transaction(s).
tx-metadata Get metadata information (if any) for given transaction.
tx-metalabels Get a list of all transaction metalabels.
tx-submit Submit signed transaction to the network.
txs-statuses Get the number of block confirmations for a given transaction hash list
tx-status Get the number of block confirmations for a given transaction hash
address-info Get address info - balance, associated stake address (if any) and UTxO set.
address-txs Get the transaction hash list of input address array, optionally filtering after specified block height (inclusive).
address-assets Get the list of all the assets (policy, name and quantity) for a given address.
credential-txs Get the transaction hash list of input payment credentials, optionally filtering after specified block height (inclusive).
account-list Get a list of all accounts returns array of stake addresses.
account-info Get the account info of any (payment or staking) address.
account-rewards Get the full rewards history (including MIR) for a stake address, or certain epoch if specified.
account-updates Get the account updates (registration, deregistration, delegation and withdrawals).
account-addresses Get all addresses associated with an account payment or staking address
account-assets Get the native asset balance of an account.
account-history Get the staking history of an account.
asset-list Get the list of all native assets (paginated).
asset-address-list Get the list of all addresses holding a given asset.
asset-info Get the information of an asset including first minting & token registry metadata.
asset-summary Get the summary of an asset (total transactions exclude minting/total wallets include only wallets with asset balance).
asset-history Get the mint/burn history of an asset.
asset-txs Get the list of all asset transaction hashes (newest first).
asset-policy-info Get the information for all assets under the same policy.
pool-list A list of all currently registered/retiring (not retired) pools.
pool-infos Current pool statuses and details for a specified list of pool ids.
pool-info Current pool status and details for a specified pool by pool id.
pool-delegators Return information about delegators by a given pool and optional epoch (current if omitted).
pool-history Return information about delegators by a given pool and optional epoch (current if omitted).
pool-blocks Return information about blocks minted by a given pool in current epoch (or _epoch_no if provided).
pool-updates Return all pool updates for all pools or only updates for specific pool if specified.
pool-relays A list of registered relays for all currently registered/retiring (not retired) pools.
pool-metadata Metadata(on & off-chain) for all currently registered/retiring (not retired) pools.
pool-delegators-history Return information about active delegators (incl. history) for a given pool and epoch number - current epoch if not provided.
pool-stake-snapshot Returns Mark, Set and Go stake snapshots for the selected pool, useful for leaderlog calculation.
native-script-list List of all existing native script hashes along with their creation transaction hashes.
plutus-script-list List of all existing Plutus script hashes along with their creation transaction hashes.
script-redeemers List of all redeemers for a given script hash.
help, h Shows a list of commands or help for one command
OPTIONS:
--port value Set port (default: 443)
--host value Set host (default: "api.koios.rest")
--api-version value Set API version (default: "v0")
--scheme value Set URL scheme (default: "https")
--origin value Set Origin header for requests. (default: "https://github.com/cardano-community/koios-go-client")
--rate-limit value Set API Client rate limit for outgoing requests (default: 10)
--no-format prints response json strings directly without calling json pretty. (default: false)
--enable-req-stats Enable request stats. (default: false)
--preview use preview host. (default: false)
--preprod use preprod host. (default: false)
--guildnet use guildnet host. (default: false)
--page value Set current page for request (default: 1)
--page-size value Set page size for request (default: 1000)
--help, -h show help (default: false)
Example Usage
koios-cli api --enable-req-stats tip
response
{
"request_url": "https://api.koios.rest/api/v0/tip",
"request_method": "GET",
"status_code": 200,
"status": "200 OK",
"date": "Mon, 07 Feb 2022 12:49:49 GMT",
"content_range": "0-0/*",
"stats": {
"req_started_at": "2022-02-07T12:49:48.565834833Z",
"req_dns_lookup_dur": 1284269, // dns lookup duration in nanosecons.
"tls_hs_dur": 208809082, // handshake duration in nanosecons.
"est_cxn_dur": 159857626, // time it took to establish connection with server in nanosecons.
"ttfb": 998874037, // time since start of the request it took to recieve first byte.
"req_dur": 999186595, // total request duration in nanoseconds
"req_dur_str": "999.186595ms" // string of req_dur
},
"data": {
"abs_slot": 52671876,
"block_no": 6852764,
"block_time": "2022-02-07T12:49:27",
"epoch": 319,
"epoch_slot": 227076,
"hash": "1dad134750188460dd48068e655b5935403d2f51afaf53a39337a4c89771754a"
}
Example to query testnet tip from cli
koios-cli api --enable-req-stats --testnet tip
# OR
koios-cli api --enable-req-stats --host testnet.koios.rest tip
response
{
"request_url": "https://testnet.koios.rest/api/v0/tip",
"request_method": "GET",
"status_code": 200,
"status": "200 OK",
"date": "Mon, 07 Feb 2022 12:50:04 GMT",
"content_range": "0-0/*",
"stats": {
"req_started_at": "2022-02-07T12:50:03.98615637Z",
"req_dns_lookup_dur": 1383437,
"tls_hs_dur": 69093093,
"est_cxn_dur": 43733700,
"ttfb": 167423049,
"req_dur": 167738287,
"req_dur_str": "167.738287ms"
},
"data": {
"abs_slot": 49868948,
"block_no": 3300758,
"block_time": "2022-02-07T12:49:24",
"epoch": 185,
"epoch_slot": 318548,
"hash": "d7623e68cb78f450f42ba4b5a169124b26677f08f676ca4241b27edb6dbf0071"
}
}
Install
It's highly recommended installing a latest version of koios-cli
available on the releases page.
Install from Source
go install github.com/cardano-community/koios-cli@latest
verify installation
koios-cli --version
Contributing
We would love for you to contribute to Koios API Client Library for Go and help make it even better than it is today! As a contributor, here are the guidelines we would like you to follow:
- Code of Conduct
- Question or Problem?
- Found a Bug?
- Missing a Feature?
- Submission Guidelines
- Coding Rules
- Commit Message Guidelines
- Development Documentation
Code of Conduct
Help us keep Koios API Client Library for Go open and inclusive. Please read and follow our Code of Conduct
Got a Question or Problem?
Do not open issues for general support questions as we want to keep GitHub issues for bug reports and feature requests. You've got much better chances of getting your question answered on Koios Telegram Group
Issues and Bugs
If you find a bug in the source code, you can help us by submitting an issue to our GitHub Repository. Even better, you can submit a Pull Request with a fix.
Feature Requests
You can request a new feature by submitting an issue to our GitHub Repository. If you would like to implement a new feature, please submit an issue with a proposal for your work first, to be sure that we can use it. Please consider what kind of change it is:
- For a Major Feature, first open an issue and outline your proposal so that it can be discussed. This will also allow us to better coordinate our efforts, prevent duplication of work, and help you to craft the change so that it is successfully accepted into the project.
- Small Features can be crafted and directly submitted as a Pull Request.
Submission Guidelines
Submitting an Issue
Before you submit an issue, please search the issue tracker, maybe an issue for your problem already exists and the discussion might inform you of workarounds readily available.
You can file new issues by filling out our new issue form.
Submitting a Pull Request (PR)
Before you submit your Pull Request (PR) consider the following guidelines:
-
Search GitHub for an open or closed PR that relates to your submission. You don't want to duplicate effort.
-
Fork the cardano-community/koios-cli repo.
-
Setup you local repository
git@github.com:<your-github-username>/koios-cli.git cd koios-cli git remote add upstream git@github.com:cardano-community/koios-cli.git
-
Make your changes in a new git branch and ensure that you always start from up to date main branch. Repeat this step every time you are about to start woking on new PR.
e.g. Start new change work to update readme:
# if you are not in main branch e.g. still on previous work branch git checkout main git pull --ff upstream main git checkout -b update-readme main
-
Create your patch, including appropriate test cases.
-
Follow our Coding Rules.
-
If changes are in source code except documentations then run the full test suite, as described in the developer documentation, and ensure that all tests pass.
-
Commit your changes using a descriptive commit message that follows our commit message conventions. Adherence to these conventions is necessary because release notes are automatically generated from these messages.
git add -A git commit --signoff # or in short git commit -sm"docs(markdown): update readme examples"
-
Push your branch to GitHub:
git push -u origin update-readme
-
In GitHub, send a pull request to
main
branch.
- If we suggest changes then:
-
Make the required updates.
-
Re-run the test suites to ensure tests are still passing.
-
Rebase your branch and force push to your GitHub repository (this will update your Pull Request):
git fetch --all git rebase upstream main git push -uf origin update-readme
-
That's it! Thank you for your contribution!
After your pull request is merged
After your pull request is merged, you can safely delete your branch and pull the changes from the main (upstream) repository:
-
Delete the remote branch on GitHub either through the GitHub web UI or your local shell as follows:
git push origin --delete update-readme
-
Check out the main branch:
git checkout main -f
-
Delete the local branch:
git branch -D update-readme
-
Update your master with the latest upstream version:
git pull --ff upstream main
Coding Rules
To ensure consistency throughout the source code, keep these rules in mind as you are working:
- All features or bug fixes must be tested by one or more specs (unit-tests).
- All public API methods must be documented.
Commit Message Guidelines
We have very precise rules over how our git commit messages can be formatted. This leads to more readable messages that are easy to follow when looking through the project history. Commit messages should be well formatted, and to make that "standardized", we are using Conventional Commits. Our release workflow uses these rules to generate changelogs.
Commit Message Format
Each commit message consists of a header, a body and a footer. The header has a special format that includes a type, a scope and a subject:
<type>(<scope>): <subject>
<BLANK LINE>
<body>
<BLANK LINE>
<footer>
When maintainers are merging PR merge commit should be edited:
<type>(<scope>): <subject> (#pr)
<BLANK LINE>
<body>
<BLANK LINE>
<footer>
The header is mandatory and the scope of the header is optional.
Any line of the commit message cannot be longer 100 characters! This allows the message to be easier to read on GitHub as well as in various git tools.
The footer should contain a closing reference to an issue if any.
Samples:
docs(markdown): update readme examples
fix(endpoint): update Tip endpoint to latest specs.
description of your change.
refactor(client): change Client GET function signature
change order of client GET method arguments.
BREAKING CHANGE: Clien.Get signature has changed
Revert
If the commit reverts a previous commit, it should begin with revert:
, followed by the header of the reverted commit. In the body it should say: This reverts commit <hash>.
, where the hash is the SHA of the commit being reverted.
Type
Must be one of the following:
- build: Changes that affect the build system or external dependencies (example scopes: goreleaser, taskfile)
- chore: Other changes that don't modify src or test files.
- ci: Changes to our CI configuration files and scripts.
- dep: Changes related to dependecies e.g.
go.mod
- docs: Documentation only changes (example scopes: markdown, godoc)
- feat: A new feature
- fix: A bug fix
- perf: A code change that improves performance
- refactor: A code change that neither fixes a bug nor adds a feature
- revert: Reverts a previous commit
- style: Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)
- test: Adding missing tests or correcting existing tests
Scope
The following is the list of supported scopes:
scope | description |
---|---|
client | API client related changes |
endpoint | Changes related to api endpoints |
godoc | Go documentation |
markdown | Markdown files |
Subject
The subject contains a succinct description of the change:
- use the imperative, present tense: "change" not "changed" nor "changes"
- don't capitalize the first letter
- no dot (.) at the end
Body
Just as in the subject, use the imperative, present tense: "change" not "changed" nor "changes". The body should include the motivation for the change and contrast this with previous behavior.
Footer
The footer should contain any information about Breaking Changes and is also the place to reference GitHub issues that this commit Closes.
Breaking Changes should start with the word BREAKING CHANGE:
with a space or two newlines. The rest of the commit message is then used for this.
A detailed explanation can be found in this [document][commit-message-format].
Development Documentation
Setup your machine
Prerequisites:
-
Working Go environment. See the install instructions for Go.
-
golangci-lint - Go linters aggregator should be installed
-
taskfile - task runner / build tool should be installed
-
svu - Semantic Version Util tool should be installed
-
Fork the cardano-community/koios-cli repo.
-
Setup you local repository
git@github.com:<your-github-username>/koios-cli.git cd koios-cli git remote add upstream git@github.com:cardano-community/koios-cli.git
Setup local env
task setup
Lint your code
task lint
Test your change
task test
View code coverage report from in browser (results from task test
)
task cover
Credits
Original author.
koios-cli was moved under Cardano Community from howijd/koios-rest-go-client
Documentation
¶
There is no documentation for this package.