{"id":28561270,"url":"https://github.com/duneanalytics/dune-client","last_synced_at":"2025-06-10T10:42:02.891Z","repository":{"id":59463724,"uuid":"531604797","full_name":"duneanalytics/dune-client","owner":"duneanalytics","description":"A framework for interacting with Dune Analytics' officially supported API service","archived":false,"fork":false,"pushed_at":"2025-03-24T12:56:05.000Z","size":227,"stargazers_count":110,"open_issues_count":18,"forks_count":29,"subscribers_count":16,"default_branch":"main","last_synced_at":"2025-06-08T11:45:34.258Z","etag":null,"topics":["api-client","dune-analytics","web3"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/duneanalytics.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-09-01T16:42:29.000Z","updated_at":"2025-06-03T07:44:21.000Z","dependencies_parsed_at":"2023-11-22T23:30:04.761Z","dependency_job_id":"229de327-44b6-4c68-a853-e460b0c1f8c7","html_url":"https://github.com/duneanalytics/dune-client","commit_stats":null,"previous_names":["bh2smith/dune-client","cowprotocol/dune-client","duneanalytics/dune-client"],"tags_count":42,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/duneanalytics%2Fdune-client","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/duneanalytics%2Fdune-client/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/duneanalytics%2Fdune-client/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/duneanalytics%2Fdune-client/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/duneanalytics","download_url":"https://codeload.github.com/duneanalytics/dune-client/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/duneanalytics%2Fdune-client/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259058104,"owners_count":22799300,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api-client","dune-analytics","web3"],"created_at":"2025-06-10T10:41:46.575Z","updated_at":"2025-06-10T10:42:02.883Z","avatar_url":"https://github.com/duneanalytics.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Python 3.11](https://img.shields.io/badge/python-3.11-blue.svg)](https://www.python.org/downloads/release/python-3102/)\n[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)\n[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)\n[![Build](https://github.com/duneanalytics/dune-client/actions/workflows/pull-request.yaml/badge.svg)](https://github.com/duneanalytics/dune-client/actions/workflows/pull-request.yaml)\n\n# Dune Client\n\nA python framework for interacting with Dune Analytics' [officially supported API\nservice](https://docs.dune.com/api-reference/overview/introduction).\n\n## Installation\n\nImport as a project dependency\n\n```shell\npip install dune-client\n```\n\n# Example Usage\n\n## Quickstart: run_query\n\nExport your `DUNE_API_KEY` (or place it in a `.env` file - as in\nhere [.env.sample](./.env.sample) and `source .env`).\n\n```python\nfrom dune_client.types import QueryParameter\nfrom dune_client.client import DuneClient\nfrom dune_client.query import QueryBase\n\nquery = QueryBase(\n    name=\"Sample Query\",\n    query_id=1215383,\n    params=[\n        QueryParameter.text_type(name=\"TextField\", value=\"Word\"),\n        QueryParameter.number_type(name=\"NumberField\", value=3.1415926535),\n        QueryParameter.date_type(name=\"DateField\", value=\"2022-05-04 00:00:00\"),\n        QueryParameter.enum_type(name=\"ListField\", value=\"Option 1\"),\n    ],\n)\nprint(\"Results available at\", query.url())\n\ndune = DuneClient.from_env()\nresults = dune.run_query(query)\n\n# or as CSV\n# results_csv = dune.run_query_csv(query)\n\n# or as Pandas Dataframe\n# results_df = dune.run_query_dataframe(query)\n```\n\n## Further Examples\n\n### Get Latest Results\nUse `get_latest_results` to get the most recent query results without using execution credits. \nYou can specify a `max_age_hours` to re-run the query if the data is too outdated.\n\n```python\nfrom dune_client.client import DuneClient\n\ndune = DuneClient.from_env()\nresults = dune.get_latest_result(1215383, max_age_hours=8)\n```\n\n## Paid Subscription Features\n\n### CRUD Operations\n\nIf you're writing scripts that rely on Dune query results and want to ensure that your local, \npeer-reviewed, queries are being used at runtime, you can call `update_query` before `run_query`!\n\nHere is a fictitious example making use of this functionality;\n\n```python\nfrom dune_client.types import QueryParameter\nfrom dune_client.client import DuneClient\n\nsql = \"\"\"\n    SELECT block_time, hash,\n    FROM ethereum.transactions\n    ORDER BY CAST(gas_used as uint256) * CAST(gas_price AS uint256) DESC\n    LIMIT {{N}}\n    \"\"\"\n\ndune = DuneClient.from_env()\nquery = dune.create_query(\n    name=\"Top {N} Most Expensive Transactions on Ethereum\",\n    query_sql=sql,\n    # Optional fields\n    params=[QueryParameter.number_type(name=\"N\", value=10)],\n    is_private=False  # default\n)\nquery_id = query.base.query_id\nprint(f\"Created query with id {query.base.query_id}\")\n# Could retrieve using \n# dune.get_query(query_id)\n\ndune.update_query(\n    query_id, \n    # All parameters below are optional\n    name=\"Top {N} Most Expensive Transactions on {Blockchain}\",\n    query_sql=sql.replace(\"ethereum\", \"{{Blockchain}}\"),\n    params=query.base.parameters() + [QueryParameter.text_type(\"Blockchain\", \"ethereum\")],\n    description=\"Shows time and hash of the most expensive transactions\",\n    tags=[\"XP€N$IV $H1T\"]\n)\n\ndune.archive_query(query_id)\ndune.unarchive_query(query_id)\n\ndune.make_private(query_id)\ndune.make_public(query_id)\n```\n\n# Developer Usage \u0026 Deployment\n\n## Makefile\nThis project's makefile comes equipped with sufficient commands for local development.\n\n### Installation\n\n```shell\nmake install\n````\n\n### Format, Lint \u0026 Types\n```shell\nmake check\n```\ncan also be run individually with `fmt`, `lint` and `types` respectively. \n\n### Testing\n```shell\nmake test-unit  # Unit tests \nmake test-e2e   # Requires valid `DUNE_API_KEY`\n```\ncan also run both with `make test-all`\n\n## Deployment\n\nPublishing releases to PyPi is configured automatically via github actions \n(cf. [./.github/workflows/py-publish.yaml](./.github/workflows/py-publish.yaml)).\nAny time a branch is tagged for release this workflow is triggered and published with the same version name.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fduneanalytics%2Fdune-client","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fduneanalytics%2Fdune-client","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fduneanalytics%2Fdune-client/lists"}