Hive Intelligence

SDKs

Rust Integration

Use Hive from async Rust services with reqwest.


Installation

[dependencies]
reqwest = { version = "0.12", features = ["json"] }
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
tokio = { version = "1", features = ["macros", "rt-multi-thread"] }

Quick Start

use reqwest::Client;
use serde_json::{json, Value};

const BASE_URL: &str = "https://mcp.hiveintelligence.xyz";

async fn execute(api_key: &str, tool: &str, args: Value) -> Result<Value, reqwest::Error> {
    let client = Client::new();

    client
        .post(format!("{BASE_URL}/api/v1/execute"))
        .header("x-api-key", api_key)
        .json(&json!({
            "tool": tool,
            "args": args
        }))
        .send()
        .await?
        .json()
        .await
}

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let api_key = std::env::var("HIVE_API_KEY")?;
    let price = execute(&api_key, "get_price", json!({
        "ids": "bitcoin",
        "vs_currencies": "usd"
    })).await?;

    println!("Bitcoin: {}", price["bitcoin"]["usd"]);
    Ok(())
}

Reusable Client

use reqwest::Client;
use serde_json::{json, Value};

pub struct HiveClient {
    api_key: String,
    base_url: String,
    client: Client,
}

impl HiveClient {
    pub fn new(api_key: String) -> Self {
        Self {
            api_key,
            base_url: "https://mcp.hiveintelligence.xyz".to_string(),
            client: Client::new(),
        }
    }

    pub async fn execute(&self, tool: &str, args: Value) -> Result<Value, reqwest::Error> {
        self.client
            .post(format!("{}/api/v1/execute", self.base_url))
            .header("x-api-key", &self.api_key)
            .json(&json!({
                "tool": tool,
                "args": args
            }))
            .send()
            .await?
            .json()
            .await
    }

    pub async fn list_tools(&self, limit: usize) -> Result<Value, reqwest::Error> {
        self.client
            .get(format!("{}/api/v1/tools?limit={limit}", self.base_url))
            .header("x-api-key", &self.api_key)
            .send()
            .await?
            .json()
            .await
    }
}

Example Calls

let client = HiveClient::new(std::env::var("HIVE_API_KEY")?);

let market = client.execute("get_coins_market_data", json!({
    "vs_currency": "usd",
    "order": "market_cap_desc",
    "per_page": 5
})).await?;

let wallet = client.execute("moralis_get_wallet_net_worth", json!({
    "address": "0x1234...",
    "chain": "eth"
})).await?;

let security = client.execute("get_token_security", json!({
    "contract_addresses": "0x6982508145454Ce325dDbE47a25d4ec3d2311933",
    "chain_id": "1"
})).await?;

Notes

  • The current REST payload keys are tool and args.
  • Use GET /api/v1/tools to inspect the live catalog before hard-coding schemas.
  • Older toolName / arguments examples are legacy.
Previous
Java SDK