dune-api-client
TypeScript icon, indicating that this package has built-in type declarations

0.0.4 • Public • Published

Dune Analytics API Client

npm

A minimal typescript client for interacting with the Dune Analytics API.

Examples

There are two ways to get data from a query. The first approach is to read the results from a specific execution.

import { Dune } from 'dune-api-client'

const dune = new Dune('xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx')

const execute = await dune.execute(3224138)
const status = await dune.status(execute.execution_id)
const res = await dune.results(execute.execution_id)

The second approach is to read the latest results from a query, regardless of how it was executed (including on the Dune website).

import { Dune } from 'dune-api-client'

const dune = new Dune('xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx')

const res = await dune.results(3224138)

The dune.results method accepts an optional type parameter to improve response type safety.

type DuneData = {
  rank: number
  username: string
  followers: number
}

const res = await dune.results<DuneData>(3224138)
// res.result.rows will be of type DuneData[]

The dune.execute and dune.results methods support query params (text, number, and date).

const execute = await dune.execute(2411864, {
  params: {
    text_record_key: 'avatar',
  },
})

Package Sidebar

Install

npm i dune-api-client

Weekly Downloads

4

Version

0.0.4

License

ISC

Unpacked Size

12.5 kB

Total Files

9

Last publish

Collaborators

  • gregskril