1.0.1 • Published 1 month ago

dune-api-client v1.0.1

Weekly downloads
-
License
ISC
Repository
github
Last release
1 month ago

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',
  },
})
1.0.1

1 month ago

1.0.0

2 months ago

0.0.5

2 months ago

0.0.4

5 months ago

0.0.3

5 months ago

0.0.2

5 months ago

0.0.1

5 months ago