Skip to content

bh2smith/demo-ts-dune-client

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Example Use Cases for Dune Client SDK (NodeJS)

Demonstrating how to use @duneanalytics/client-sdk

Basic Example: Install, Set ENV & Run

git clone git@github.com:bh2smith/demo-ts-dune-client.git
cd demo-ts-dune-client
yarn
export DUNE_API_KEY=<YOUR-DUNE-API-KEY>
npx ts-node src/index.ts
# or equivalently
yarn test

Runs the following sample script:

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:

[
  {
    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 for syncing queries changes to Dune. Check out the ci.yaml file to see how its used and observe this successful run

About

Small repo demonstrating how to use the ts-dune-client

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •