# @cowprotocol/ts-dune-client

> Node Client for Dune Analytics' officially supported API.

Latest version **0.0.2** (published 2023-05-18) · 0 weekly downloads

## Install

```sh
npm install @cowprotocol/ts-dune-client
pnpm add @cowprotocol/ts-dune-client
yarn add @cowprotocol/ts-dune-client
bun add @cowprotocol/ts-dune-client
```

## Health

**Score 35/100 (D)** — status: abandoned.

Positive: has types; no vulnerabilities; high maintenance score.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 0.0.2 |
| Published | 2023-05-18 |
| First published | 2022-10-05 |
| Weekly downloads | 0 |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 13.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 53 |
| Author | Ben Smith |
| Maintainers | bh2smith, w3stside, nenad91, anxolin, fairlighteth, fedgiac, harisang, cowprotocol_dev |

## Links

- npm: https://www.npmjs.com/package/@cowprotocol/ts-dune-client
- Repository: https://github.com/cowprotocol/ts-dune-client
- Homepage: https://github.com/cowprotocol/ts-dune-client#readme
- Issues: https://github.com/cowprotocol/ts-dune-client/issues
- npm.io page: https://npm.io/package/@cowprotocol/ts-dune-client

## Dependencies (2)

- [loglevel](https://npm.io/package/loglevel.md) ^1.8.0
- [cross-fetch](https://npm.io/package/cross-fetch.md) ^3.1.5

## Recent versions

- 0.0.2 (latest) — 2023-05-18
- 0.0.1 — 2023-04-26
- 0.0.0-beta.2 — 2022-10-05
- 0.0.0-beta.1 — 2022-10-05
- 0.0.0-beta.0 — 2022-10-05

## README

[![Styled With Prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg)](https://prettier.io/)
[![Build](https://github.com/cowprotocol/ts-dune-client/actions/workflows/pull-request.yaml/badge.svg)](https://github.com/cowprotocol/ts-dune-client/actions/workflows/pull-request.yaml/badge.svg)

# Dune Client TS

This [NPM package](https://www.npmjs.com/package/@cowprotocol/ts-dune-client) implements all the basic routes defined in the [Dune API Docs](https://dune.com/docs/api/). It also introduces a convenience method `refresh` which combines `execute`, `getStatus` and `getResults` in a way that makes it nearly trivial to fetch query execution results.

Install the package

```sh
yarn add @cowprotocol/ts-dune-client
```

```ts
import { QueryParameter, DuneClient } from "@cowprotocol/ts-dune-client";
const { DUNE_API_KEY } = process.env;

const client = new DuneClient(DUNE_API_KEY ?? "");
const queryID = 1215383;
const 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"),
];

client
  .refresh(queryID, parameters)
  .then((executionResult) => console.log(executionResult.result?.rows));

// should look like
// [
//   {
//     date_field: "2022-05-04 00:00:00",
//     list_field: "Option 1",
//     number_field: "3.1415926535",
//     text_field: "Plain Text",
//   },
// ]
```

Note also that the client has methods `execute`, `getStatus`, `getResult` and `cancelExecution`

Check out this [Demo Project](https://github.com/bh2smith/demo-ts-dune-client)!

---
_Source: https://npm.io/package/@cowprotocol/ts-dune-client · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
