SDKs
Go Integration
Go Integration
Access Hive Intelligence using Go's standard net/http package.
Quick Start
package main
import (
"bytes"
"encoding/json"
"fmt"
"net/http"
)
const apiURL = "https://api.hiveintelligence.xyz/api/execute"
type Request struct {
ToolName string `json:"toolName"`
Arguments map[string]interface{} `json:"arguments"`
}
func callHive(toolName string, args map[string]interface{}) (map[string]interface{}, error) {
payload, _ := json.Marshal(Request{
ToolName: toolName,
Arguments: args,
})
resp, err := http.Post(apiURL, "application/json", bytes.NewBuffer(payload))
if err != nil {
return nil, err
}
defer resp.Body.Close()
var result map[string]interface{}
if err := json.NewDecoder(resp.Body).Decode(&result); err != nil {
return nil, err
}
return result, nil
}
func main() {
result, err := callHive("get_price", map[string]interface{}{
"ids": "bitcoin",
"vs_currencies": "usd",
})
if err != nil {
panic(err)
}
data := result["data"].(map[string]interface{})
bitcoin := data["bitcoin"].(map[string]interface{})
fmt.Printf("Bitcoin: $%.2f\n", bitcoin["usd"].(float64))
}
Helper Client
Create a reusable client struct:
package main
import (
"bytes"
"encoding/json"
"fmt"
"net/http"
"time"
)
type HiveClient struct {
BaseURL string
HTTPClient *http.Client
}
func NewHiveClient() *HiveClient {
return &HiveClient{
BaseURL: "https://api.hiveintelligence.xyz",
HTTPClient: &http.Client{
Timeout: 30 * time.Second,
},
}
}
type request struct {
ToolName string `json:"toolName"`
Arguments map[string]interface{} `json:"arguments"`
}
func (c *HiveClient) Execute(toolName string, args map[string]interface{}) (map[string]interface{}, error) {
payload, err := json.Marshal(request{
ToolName: toolName,
Arguments: args,
})
if err != nil {
return nil, err
}
resp, err := c.HTTPClient.Post(
c.BaseURL+"/api/execute",
"application/json",
bytes.NewBuffer(payload),
)
if err != nil {
return nil, err
}
defer resp.Body.Close()
var result map[string]interface{}
if err := json.NewDecoder(resp.Body).Decode(&result); err != nil {
return nil, err
}
return result, nil
}
func (c *HiveClient) GetPrice(coinID, currency string) (float64, error) {
result, err := c.Execute("get_price", map[string]interface{}{
"ids": coinID,
"vs_currencies": currency,
})
if err != nil {
return 0, err
}
data := result["data"].(map[string]interface{})
coin := data[coinID].(map[string]interface{})
return coin[currency].(float64), nil
}
func main() {
client := NewHiveClient()
price, err := client.GetPrice("bitcoin", "usd")
if err != nil {
panic(err)
}
fmt.Printf("Bitcoin: $%.2f\n", price)
}
Type-Safe Responses
package main
import (
"bytes"
"encoding/json"
"fmt"
"net/http"
)
type PriceResponse struct {
Data map[string]map[string]float64 `json:"data"`
}
type SecurityResponse struct {
Data struct {
IsHoneypot bool `json:"is_honeypot"`
IsOpenSource bool `json:"is_open_source"`
IsMintable bool `json:"is_mintable"`
BuyTax string `json:"buy_tax"`
SellTax string `json:"sell_tax"`
HolderCount int `json:"holder_count"`
} `json:"data"`
}
func callHiveTyped[T any](toolName string, args map[string]interface{}) (*T, error) {
payload, _ := json.Marshal(map[string]interface{}{
"toolName": toolName,
"arguments": args,
})
resp, err := http.Post(
"https://api.hiveintelligence.xyz/api/execute",
"application/json",
bytes.NewBuffer(payload),
)
if err != nil {
return nil, err
}
defer resp.Body.Close()
var result T
if err := json.NewDecoder(resp.Body).Decode(&result); err != nil {
return nil, err
}
return &result, nil
}
func main() {
// Typed price response
price, err := callHiveTyped[PriceResponse]("get_price", map[string]interface{}{
"ids": "bitcoin",
"vs_currencies": "usd",
})
if err != nil {
panic(err)
}
fmt.Printf("Bitcoin: $%.2f\n", price.Data["bitcoin"]["usd"])
// Typed security response
security, err := callHiveTyped[SecurityResponse]("get_token_security", map[string]interface{}{
"contract_addresses": "0x6982508145454Ce325dDbE47a25d4ec3d2311933",
"chain_id": "1",
})
if err != nil {
panic(err)
}
fmt.Printf("Honeypot: %v\n", security.Data.IsHoneypot)
}
Working with Tools
Market Data
client := NewHiveClient()
// Get market data
marketData, err := client.Execute("get_coins_market_data", map[string]interface{}{
"vs_currency": "usd",
"order": "market_cap_desc",
"per_page": 10,
})
// Get trending
trending, err := client.Execute("get_trending", map[string]interface{}{})
DeFi Analytics
// Get protocols
protocols, err := client.Execute("get_protocols", map[string]interface{}{})
// Get yields
yields, err := client.Execute("get_yield_pools", map[string]interface{}{
"chain": "ethereum",
})
Security Analysis
// Check token security
security, err := client.Execute("get_token_security", map[string]interface{}{
"contract_addresses": "0x...",
"chain_id": "1",
})
data := security["data"].(map[string]interface{})
if isHoneypot, ok := data["is_honeypot"].(bool); ok && isHoneypot {
fmt.Println("WARNING: Honeypot detected!")
}
Concurrent Requests
package main
import (
"fmt"
"sync"
)
func getMultiplePrices(client *HiveClient, coins []string) map[string]float64 {
results := make(map[string]float64)
var mu sync.Mutex
var wg sync.WaitGroup
for _, coin := range coins {
wg.Add(1)
go func(c string) {
defer wg.Done()
price, err := client.GetPrice(c, "usd")
if err != nil {
return
}
mu.Lock()
results[c] = price
mu.Unlock()
}(coin)
}
wg.Wait()
return results
}
func main() {
client := NewHiveClient()
prices := getMultiplePrices(client, []string{"bitcoin", "ethereum", "solana"})
for coin, price := range prices {
fmt.Printf("%s: $%.2f\n", coin, price)
}
}
Error Handling
func callHiveSafe(toolName string, args map[string]interface{}) (map[string]interface{}, error) {
payload, _ := json.Marshal(map[string]interface{}{
"toolName": toolName,
"arguments": args,
})
resp, err := http.Post(
"https://api.hiveintelligence.xyz/api/execute",
"application/json",
bytes.NewBuffer(payload),
)
if err != nil {
return nil, fmt.Errorf("request failed: %w", err)
}
defer resp.Body.Close()
if resp.StatusCode == 429 {
return nil, fmt.Errorf("rate limited")
}
if resp.StatusCode != 200 {
return nil, fmt.Errorf("API error: status %d", resp.StatusCode)
}
var result map[string]interface{}
if err := json.NewDecoder(resp.Body).Decode(&result); err != nil {
return nil, fmt.Errorf("decode error: %w", err)
}
return result, nil
}
Context Support
import (
"context"
"net/http"
"time"
)
func callHiveWithContext(ctx context.Context, toolName string, args map[string]interface{}) (map[string]interface{}, error) {
payload, _ := json.Marshal(map[string]interface{}{
"toolName": toolName,
"arguments": args,
})
req, err := http.NewRequestWithContext(
ctx,
"POST",
"https://api.hiveintelligence.xyz/api/execute",
bytes.NewBuffer(payload),
)
if err != nil {
return nil, err
}
req.Header.Set("Content-Type", "application/json")
resp, err := http.DefaultClient.Do(req)
if err != nil {
return nil, err
}
defer resp.Body.Close()
var result map[string]interface{}
json.NewDecoder(resp.Body).Decode(&result)
return result, nil
}
func main() {
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()
result, err := callHiveWithContext(ctx, "get_price", map[string]interface{}{
"ids": "bitcoin",
"vs_currencies": "usd",
})
if err != nil {
panic(err)
}
fmt.Println(result)
}
Quick Reference
| Tool | Description |
|---|---|
get_price | Get current prices |
get_coins_market_data | Market data with pagination |
get_trending | Trending coins |
get_protocols | DeFi protocol list |
get_token_security | Token security analysis |
get_wallet_balance | Wallet balances |