Overview
Makes REST API calls to Hive blockchain REST endpoints with automatic retry and failover support. Provides type-safe access to various Hive REST APIs with automatic path and query parameter handling.Function Signature
Parameters
The REST API method name. Available options:
'balance'- Balance API for account balances'hafah'- HAF Account History API'hafbe'- HAF Block Explorer API'hivemind'- Hivemind social API'hivesense'- Hivesense API'reputation'- Reputation API'nft-tracker'- NFT Tracker API'hafsql'- HAF SQL API'status'- Status API
The specific endpoint path within the API (e.g.,
'/accounts/{account-name}/balances')Optional parameters for path and query string replacement. Path parameters are replaced in the endpoint URL, remaining parameters become query parameters.
Request timeout in milliseconds. If not specified, uses the default timeout from configuration.
Number of retry attempts before throwing an error. The function will try different REST nodes on failure.
Return Type
Returns a Promise that resolves to the API response data with proper TypeScript typing based on the endpoint specification.
API Method Types
The function supports the following REST API endpoints:| API Method | Base Path | Description |
|---|---|---|
balance | /balance-api | Account balance and transaction history |
hafah | /hafah-api | HAF Account History operations |
hafbe | /hafbe-api | HAF Block Explorer data |
hivemind | /hivemind-api | Social features (posts, followers, etc.) |
hivesense | /hivesense-api | Hivesense analytics |
reputation | /reputation-api | Account reputation data |
nft-tracker | /nft-tracker-api | NFT tracking and data |
hafsql | /hafsql | SQL-based queries |
status | /status-api | Node status information |
Path and Query Parameters
The function intelligently handles parameters:- Path Parameters: Parameters matching
{param-name}in the endpoint are replaced in the URL - Query Parameters: Remaining parameters are added as query string parameters
Examples
Balance API - Get Account Balances
Balance API - Get Aggregated History
Status API - Get Node Status
HAF Account History - Get Account Operations
Hivemind API - Get Account Followers
Custom Timeout and Retry
Array Query Parameters
Error Handling
TypeScript Type Safety
The function uses TypeScript generics to provide full type safety:Behavior
- Automatically rotates through configured REST nodes on failure
- Properly encodes path parameters in URLs
- Converts remaining parameters to query strings
- Handles array parameters by appending multiple values
- Throws error immediately on HTTP 404 responses
- Retries on network or timeout errors with different nodes
See Also
- callRPC - JSON-RPC API calls
- callWithQuorum - Consensus-based calls
- Configuration - Configure REST nodes and timeouts