|
1 | | -# duneanalytics |
2 | | -Unofficial Python Library for Dune Analytics |
| 1 | +# Dune Analytics |
| 2 | + |
| 3 | +[](https://www.python.org/downloads/release/python-350/) |
| 4 | +[](https://www.python.org/downloads/release/python-360/) |
| 5 | +[](https://www.python.org/downloads/release/python-370/) |
| 6 | +[](https://www.python.org/downloads/release/python-380/) |
| 7 | +[](https://www.python.org/downloads/release/python-390/) |
| 8 | + |
| 9 | +[](https://opensource.org/licenses/Apache-2.0) |
| 10 | + |
| 11 | +------- |
| 12 | + |
| 13 | +### Unofficial Python Library for [Dune Analytics](https://duneanalytics.com/) |
| 14 | + |
| 15 | +The library can be used to fetch the table data from `python` backend. |
| 16 | + |
| 17 | +#### Disclaimer: Use at your own risk! |
| 18 | +It may not work for some/all urls. |
| 19 | + |
| 20 | +This library doesn't run the query, rather it fetches the query result from the backend. |
| 21 | + |
| 22 | +### Installation: |
| 23 | + |
| 24 | +use pip to install: |
| 25 | + |
| 26 | +``` |
| 27 | +pip install duneanalytics |
| 28 | +``` |
| 29 | + |
| 30 | +----------- |
| 31 | + |
| 32 | +### Authentication: |
| 33 | + |
| 34 | +You need to have `username` & `password` for [Dune Analytics](https://duneanalytics.com/) |
| 35 | + |
| 36 | +----------- |
| 37 | + |
| 38 | +### Example usage: |
| 39 | + |
| 40 | +``` |
| 41 | +from duneanalytics import DuneAnalytics |
| 42 | +
|
| 43 | +# initialize client |
| 44 | +dune = DuneAnalytics('username', 'password') |
| 45 | +
|
| 46 | +# try to login |
| 47 | +dune.login() |
| 48 | +
|
| 49 | +# fetch token |
| 50 | +dune.fetch_auth_token() |
| 51 | +
|
| 52 | +# fetch query result id using query id |
| 53 | +# query id for any query can be found from the url of the query: |
| 54 | +# for example: |
| 55 | +# https://duneanalytics.com/queries/4494/8769 => 4494 |
| 56 | +# https://duneanalytics.com/queries/3705/7192 => 3705 |
| 57 | +# https://duneanalytics.com/queries/3751/7276 => 3751 |
| 58 | +
|
| 59 | +result_id = dune.query_result_id(query_id=5508) |
| 60 | +
|
| 61 | +# fetch query result |
| 62 | +data = dune.query_result(result_id) |
| 63 | +``` |
| 64 | + |
0 commit comments