https://github.com/bh2smith/demo-ts-dune-client
Small repo demonstrating how to use the ts-dune-client
https://github.com/bh2smith/demo-ts-dune-client
Last synced: 9 months ago
JSON representation
Small repo demonstrating how to use the ts-dune-client
- Host: GitHub
- URL: https://github.com/bh2smith/demo-ts-dune-client
- Owner: bh2smith
- License: mit
- Created: 2022-10-05T10:45:08.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2024-10-17T08:56:36.000Z (almost 2 years ago)
- Last Synced: 2024-12-26T08:18:41.377Z (over 1 year ago)
- Language: TypeScript
- Size: 41 KB
- Stars: 5
- Watchers: 2
- Forks: 5
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Example Use Cases for Dune Client SDK (NodeJS)
Demonstrating how to use [@duneanalytics/client-sdk](https://www.npmjs.com/package/@duneanalytics/client-sdk)
## Basic Example: Install, Set ENV & Run
```sh
git clone git@github.com:bh2smith/demo-ts-dune-client.git
cd demo-ts-dune-client
yarn
```
```sh
export DUNE_API_KEY=
```
```sh
npx ts-node src/index.ts
# or equivalently
yarn test
```
Runs the following sample script:
```ts
import { QueryParameter, DuneClient } from "@duneanalytics/client-sdk";
const client = new DuneClient(process.env.DUNE_API_KEY!);
const queryId = 1215383;
const query_parameters = [
QueryParameter.text("TextField", "Plain Text"),
QueryParameter.number("NumberField", 3.1415926535),
QueryParameter.date("DateField", "2022-05-04 00:00:00"),
QueryParameter.enum("ListField", "Option 1"),
];
// Exclude the debug logs from lower level dependency.
// console.debug = function () {};
client
.runQuery({ queryId, query_parameters })
.then((response) => console.log(response.result?.rows));
```
Should yield the following output in your shell:
```sh
[
{
date_field: '2022-05-04 00:00:00',
list_field: 'Option 1',
number_field: '3.1415926535',
text_field: 'Plain Text'
}
]
```
## Github Actions
There is a dedicated [github action](https://github.com/marketplace/actions/dune-query-updater) for syncing queries changes to Dune. Check out the [ci.yaml](./.github/workflows/ci.yaml) file to see how its used and observe this [successful run](https://github.com/bh2smith/demo-ts-dune-client/actions/)