Hive Intelligence

SDKs

Go Integration

Use Hive from Go services with net/http.


Quick Start

package main

import (
	"bytes"
	"encoding/json"
	"fmt"
	"io"
	"net/http"
)

const baseURL = "https://mcp.hiveintelligence.xyz"

type ExecuteRequest struct {
	Tool string         `json:"tool"`
	Args map[string]any `json:"args"`
}

func execute(apiKey string, tool string, args map[string]any) (map[string]any, error) {
	body, err := json.Marshal(ExecuteRequest{
		Tool: tool,
		Args: args,
	})
	if err != nil {
		return nil, err
	}

	req, err := http.NewRequest(http.MethodPost, baseURL+"/api/v1/execute", bytes.NewReader(body))
	if err != nil {
		return nil, err
	}

	req.Header.Set("Content-Type", "application/json")
	req.Header.Set("x-api-key", apiKey)

	resp, err := http.DefaultClient.Do(req)
	if err != nil {
		return nil, err
	}
	defer resp.Body.Close()

	if resp.StatusCode >= 300 {
		raw, _ := io.ReadAll(resp.Body)
		return nil, fmt.Errorf("hive request failed: %s", raw)
	}

	var result map[string]any
	if err := json.NewDecoder(resp.Body).Decode(&result); err != nil {
		return nil, err
	}

	return result, nil
}

Reusable Client

type HiveClient struct {
	BaseURL string
	APIKey  string
	Client  *http.Client
}

func NewHiveClient(apiKey string) *HiveClient {
	return &HiveClient{
		BaseURL: "https://mcp.hiveintelligence.xyz",
		APIKey:  apiKey,
		Client:  http.DefaultClient,
	}
}

func (c *HiveClient) Execute(tool string, args map[string]any) (map[string]any, error) {
	body, err := json.Marshal(ExecuteRequest{Tool: tool, Args: args})
	if err != nil {
		return nil, err
	}

	req, err := http.NewRequest(http.MethodPost, c.BaseURL+"/api/v1/execute", bytes.NewReader(body))
	if err != nil {
		return nil, err
	}

	req.Header.Set("Content-Type", "application/json")
	req.Header.Set("x-api-key", c.APIKey)

	resp, err := c.Client.Do(req)
	if err != nil {
		return nil, err
	}
	defer resp.Body.Close()

	var result map[string]any
	if err := json.NewDecoder(resp.Body).Decode(&result); err != nil {
		return nil, err
	}

	return result, nil
}

Tool Discovery

func (c *HiveClient) ListTools(limit int) (map[string]any, error) {
	req, err := http.NewRequest(http.MethodGet, fmt.Sprintf("%s/api/v1/tools?limit=%d", c.BaseURL, limit), nil)
	if err != nil {
		return nil, err
	}

	req.Header.Set("x-api-key", c.APIKey)

	resp, err := c.Client.Do(req)
	if err != nil {
		return nil, err
	}
	defer resp.Body.Close()

	var result map[string]any
	if err := json.NewDecoder(resp.Body).Decode(&result); err != nil {
		return nil, err
	}

	return result, nil
}

Example Calls

client := NewHiveClient("YOUR_HIVE_API_KEY")

market, _ := client.Execute("get_coins_market_data", map[string]any{
	"vs_currency": "usd",
	"order":       "market_cap_desc",
	"per_page":    5,
})

wallet, _ := client.Execute("moralis_get_wallet_net_worth", map[string]any{
	"address": "0x1234...",
	"chain":   "eth",
})

security, _ := client.Execute("get_token_security", map[string]any{
	"contract_addresses": "0x6982508145454Ce325dDbE47a25d4ec3d2311933",
	"chain_id":           "1",
})

Notes

  • The current REST payload uses tool and args.
  • Use GET /api/v1/tools before hard-coding tool names or parameters.
  • Prefer MCP instead of REST when your runtime already supports tool discovery and JSON-RPC.