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

1.0.1 • 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.data.execution_id)
const res = await dune.results(execute.data.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.data.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',
  },
})

/dune-api-client/

    Package Sidebar

    Install

    npm i dune-api-client

    Weekly Downloads

    2

    Version

    1.0.1

    License

    ISC

    Unpacked Size

    13.5 kB

    Total Files

    14

    Last publish

    Collaborators

    • gregskril