Skip to main content
API definition packages provide typed interfaces for interacting with various Hive network services. These packages keep the core WAX library lightweight while allowing you to add only the API definitions you need.

Overview

The WAX SDK uses a modular approach to API definitions. Rather than bundling all possible API endpoints in the core library, separate packages provide definitions for different services:
  • JSON-RPC APIs: Core Hive node APIs (database_api, network_broadcast_api, etc.)
  • REST APIs: External services like HAF-based APIs
This approach reduces bundle size and allows you to install only what you need.

Available API packages

Here are the official API definition packages:

JSON-RPC API

@hiveio/wax-api-jsonrpcFull JSON-RPC API definitions for Hive nodes.

HAF Block Explorer

@hiveio/wax-api-hafbeBlock Explorer REST API definitions.

Reputation Tracker

@hiveio/wax-api-reputation-trackerReputation tracking REST API definitions.

Balance Tracker

@hiveio/wax-api-balance-trackerAccount balance tracking API definitions.

Account History

@hiveio/wax-api-hafahHAF Account History REST API definitions.

Using JSON-RPC APIs

The JSON-RPC API package provides definitions for standard Hive node APIs.

Installation

Basic usage

Available JSON-RPC APIs

The package includes definitions for:
  • database_api: Query blockchain data
  • network_broadcast_api: Broadcast transactions
  • block_api: Retrieve blocks and block data
  • account_by_key_api: Find accounts by public key
  • rc_api: Resource credit information

Using REST APIs

REST API packages provide definitions for external services built on HAF (Hive Application Framework).

Installation

Install the REST API package you need:

Basic usage

Creating custom API definitions

You can create your own API definitions for custom services:

For JSON-RPC APIs

For REST APIs

API definition generator

WAX provides a tool to automatically generate API definitions from OpenAPI/Swagger specifications:
Use it to create API definition packages:
This generates TypeScript types and validators for your API, ready to use with WAX.

Benefits of API packages

Type safety

Full TypeScript support with autocomplete and validation.

Smaller bundles

Only include the APIs you actually use.

Versioning

Independent versioning for each API package.

Custom APIs

Easy to add support for custom services.

Example: Multi-API application

Here’s an example using multiple API packages together:

Best practices

Don’t install all API packages if you only use a few endpoints. Keep your bundle size small by installing only the packages you actually use.
Let TypeScript infer types from the API definitions rather than manually typing responses:
Extending the chain creates new instances. Cache the extended chain to avoid recreating it:

Next steps

API extensions guide

Learn more about extending APIs.

TypeScript examples

See complete examples using APIs.