This CLI tool is a simple, and minimal, command-line interface for executing commands with the Dune API Client. It allows users to run queries and retrieve results efficiently, making it easier to interact with the Dune Analytics platform.
- Execute queries using the Dune API.
- Retrieve results for previously executed queries.
- Support for query parameters in JSON format.
- Ability to save results as CSV files.
- Rust
- Dune API Key (can be set as an env variable)
To get started with the Dune CLI, clone the repository and build the project:
git clone https://github.com/0xrusowsky/dune-cli.git
cd dune-cli
cargo buildThe CLI tool can be run using the following command structure:
cargo run <command> [options]Execute a new query with the Dune API.
cargo run execute --query-id <QUERY_ID> [--engine-size <ENGINE_SIZE>] [--params <PARAMS>]--id: The unique identifier of the query to execute (required).--engine-size: (Optional) The engine size to use for the query execution. Can be eithermediumorlarge. Defaults tomedium.--params: (Optional) Query parameters in JSON format.
Example:
cargo run execute --query-id 3998990 --params '{"min_lp_value_usd": 1000000000}'Retrieve results for a previously executed query.
cargo run get-results --id <ID> [--peak <true|false>] [--path-csv <PATH>]--id: The unique identifier of the execution for which to retrieve results (required).--peak: (Optional) Whether to retrieve all rows or only the first 10 records.--path-csv: (Optional) Path where the resulting CSV file should be saved.
Example:
cargo run get-results --id 3998990 --peak true --path-csv outputs/test.csvYou can set the Dune API key as an environment variable:
export DUNE_API_KEY=YOUR_API_KEYor use a .env file in the root directory of the project with the following content:
DUNE_API_KEY=YOUR_API_KEYAlternatively, you can provide it directly using the -k or --api-key option when running the CLI tool.
Contributions are welcome! Please feel free to submit a pull request or open an issue if you have suggestions or encounter any problems.
This project is licensed under the MIT License. See the LICENSE file for more details.