# @hiveio/dhive

> Hive blockchain RPC client library

Latest version **1.3.6** (published 2026-04-02) · BSD-3-Clause-No-Military-License license · 0 weekly downloads

## Install

```sh
npm install @hiveio/dhive
pnpm add @hiveio/dhive
yarn add @hiveio/dhive
bun add @hiveio/dhive
```

## Health

**Score 55/100 (C)** — status: stable.

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

Warnings: low downloads; no esm support.

## Facts

| | |
|---|---|
| Version | 1.3.6 |
| Published | 2026-04-02 |
| First published | 2020-05-18 |
| Weekly downloads | 0 |
| License | BSD-3-Clause-No-Military-License |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 13 |
| Unpacked size | 3.6 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | hive-network |
| Maintainers | mahdiyari, therealwolf, bgornicki, openhive, feruzm, mtyszczak, thebeedevs |
| Keywords | blockchain, client, rpc, hive, dhive |

## Links

- npm: https://www.npmjs.com/package/@hiveio/dhive
- Repository: https://gitlab.syncad.com/hive/dhive
- npm.io page: https://npm.io/package/@hiveio/dhive

## Dependencies (13)

- [bigi](https://npm.io/package/bigi.md) ^1.4.2
- [bs58](https://npm.io/package/bs58.md) ^4.0.1
- [jsbi](https://npm.io/package/jsbi.md) ^3.1.4
- [https](https://npm.io/package/https.md) ^1.0.0
- [ecurve](https://npm.io/package/ecurve.md) ^1.0.6
- [verror](https://npm.io/package/verror.md) ^1.10.0
- [core-js](https://npm.io/package/core-js.md) ^3.6.4
- [ripemd160](https://npm.io/package/ripemd160.md) ^2.0.2
- [secp256k1](https://npm.io/package/secp256k1.md) ^3.8.0
- [node-fetch](https://npm.io/package/node-fetch.md) ^2.6.0
- [cross-fetch](https://npm.io/package/cross-fetch.md) ^3.0.4
- [whatwg-fetch](https://npm.io/package/whatwg-fetch.md) ^3.0.0
- [@ecency/bytebuffer](https://npm.io/package/@ecency/bytebuffer.md) ^6.0.0

## Alternatives

- [launchdarkly-js-client-sdk](https://npm.io/package/launchdarkly-js-client-sdk.md) — 2.5M weekly downloads
- [@elastic/elasticsearch](https://npm.io/package/@elastic/elasticsearch.md) — 2.1M weekly downloads
- [@c8y/client](https://npm.io/package/@c8y/client.md) — 15.3K weekly downloads
- [@signaldb/maverickjs](https://npm.io/package/@signaldb/maverickjs.md) — 1.7K weekly downloads
- [@bbc/http-transport-cache](https://npm.io/package/@bbc/http-transport-cache.md) — 1.2K weekly downloads

## Recent versions

- 1.3.6 (latest) — 2026-04-02
- 1.0.0-beta.0 (beta) — 2021-07-30
- 1.3.5 — 2026-03-09
- 1.3.4 — 2026-02-26
- 1.3.3 — 2026-02-26
- 1.3.2 — 2024-10-30
- 1.3.1-beta — 2024-08-07
- 1.3.0 — 2024-05-03
- 1.2.9 — 2024-05-02
- 1.2.8 — 2023-11-09
- 1.2.7 — 2023-06-29
- 1.2.6 — 2023-03-17
- 1.2.6-rc.0 — 2023-03-17
- 1.2.5 — 2022-12-31
- 1.2.4 — 2022-10-20
- … 26 more at https://npm.io/package/@hiveio/dhive/versions

## README

# [dhive](https://github.com)

Robust hive client library that runs in both node.js and the browser.

Needs test net urls, chain id

---

**note** As of version 0.7.0 WebSocket support has been removed. The only transport provided now is HTTP(2). For most users the only change required is to swap `wss://` to `https://` in the address. If you run your own full node make sure to set the proper [CORS headers](https://en.wikipedia.org/wiki/Cross-origin_resource_sharing) if you plan to access it from a browser.

---

## Browser compatibility

[![Build Status](https://saucelabs.com/browser-matrix/feruzm-dhive.svg)](https://saucelabs.com/open_sauce/user/feruzm-dhive)

## Installation

### Via npm

For node.js or the browser with [browserify](https://github.com/substack/node-browserify) or [webpack](https://github.com/webpack/webpack).

```
npm install @hiveio/dhive
```

### From cdn or self-hosted script

Grab `dist/dhive.js` from git and include in your html:

```html
<script src="@hiveio/dhive.js"></script>
```

Or from the [unpkg](https://unpkg.com) cdn:

```html
<script src="https://unpkg.com/@hiveio/dhive@latest/dist/dhive.js"></script>
```

Make sure to set the version you want when including from the cdn, you can also use `dhive@latest` but that is not always desirable. See [unpkg.com](https://unpkg.com) for more information.

## Usage

### In the browser

```html
<script src="https://unpkg.com/@hiveio/dhive@latest/dist/dhive.js"></script>
<script>
  var client = new dhive.Client(["https://api.hive.blog", "https://api.hivekings.com", "https://anyx.io", "https://api.openhive.network"]);
  client.database
    .getDiscussions("trending", { tag: "writing", limit: 1 })
    .then(function(discussions) {
      document.body.innerHTML += "<h1>" + discussions[0].title + "</h1>";
      document.body.innerHTML += "<h2>by " + discussions[0].author + "</h2>";
      document.body.innerHTML +=
        '<pre style="white-space: pre-wrap">' + discussions[0].body + "</pre>";
    });
</script>
```

See the [demo source](https://github.com/openhive-network/dhive/tree/master/examples/comment-feed) for an example on how to setup a livereloading TypeScript pipeline with [wintersmith](https://github.com/jnordberg/wintersmith) and [browserify](https://github.com/substack/node-browserify).

### In node.js

With TypeScript:

```typescript
import { Client } from "@hiveio/dhive";

const client = new Client(["https://api.hive.blog", "https://api.hivekings.com", "https://anyx.io", "https://api.openhive.network"]);

for await (const block of client.blockchain.getBlocks()) {
  console.log(`New block, id: ${block.block_id}`);
}
```

With JavaScript:

```javascript
var dhive = require("@hiveio/dhive");

var client = new dhive.Client(["https://api.hive.blog", "https://api.hivekings.com", "https://anyx.io", "https://api.openhive.network"]);
var key = dhive.PrivateKey.fromLogin("username", "password", "posting");

client.broadcast
  .vote(
    {
      voter: "username",
      author: "almost-digital",
      permlink: "dhive-is-the-best",
      weight: 10000
    },
    key
  )
  .then(
    function(result) {
      console.log("Included in block: " + result.block_num);
    },
    function(error) {
      console.error(error);
    }
  );
```

With ES2016 (node.js 7+):

```javascript
const { Client } = require("@hiveio/dhive");

const client = new Client(["https://api.hive.blog", "https://api.hivekings.com", "https://anyx.io", "https://api.openhive.network"]);

async function main() {
  const props = await client.database.getChainProperties();
  console.log(`Maximum blocksize consensus: ${props.maximum_block_size} bytes`);
  client.disconnect();
}

main().catch(console.error);
```

With node.js streams:

```javascript
var dhive = require("@hiveio/dhive");
var es = require("event-stream"); // npm install event-stream
var util = require("util");

var client = new dhive.Client(["https://api.hive.blog", "https://api.hivekings.com", "https://anyx.io", "https://api.openhive.network"]);

var stream = client.blockchain.getBlockStream();

stream
  .pipe(
    es.map(function(block, callback) {
      callback(null, util.inspect(block, { colors: true, depth: null }) + "\n");
    })
  )
  .pipe(process.stdout);
```

## Bundling

The easiest way to bundle dhive (with browserify, webpack etc.) is to just `npm install @hiveio/dhive` and `require('@hiveio/dhive')` which will give you well-tested (see browser compatibility matrix above) pre-bundled code guaranteed to JustWork™. However, that is not always desirable since it will not allow your bundler to de-duplicate any shared dependencies dhive and your app might have.

To allow for deduplication you can `require('@hiveio/dhive/lib/index-browser')`, or if you plan to provide your own polyfills: `require('@hiveio/dhive/lib/index')`. See `src/index-browser.ts` for a list of polyfills expected.

---

_Share and Enjoy!_

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