SDKs
JavaScript Integration
Use Hive from browsers, serverless functions, and Node.js with fetch.
Quick Start
const baseUrl = "https://mcp.hiveintelligence.xyz";
const apiKey = process.env.HIVE_API_KEY;
async function execute(tool, args = {}) {
const response = await fetch(`${baseUrl}/api/v1/execute`, {
method: "POST",
headers: {
"Content-Type": "application/json",
"x-api-key": apiKey,
},
body: JSON.stringify({ tool, args }),
});
if (!response.ok) {
throw new Error(`Hive request failed: ${response.status} ${await response.text()}`);
}
return response.json();
}
const price = await execute("get_price", {
ids: "bitcoin",
vs_currencies: "usd",
});
console.log(price.bitcoin.usd);
Reusable Client
class HiveClient {
constructor({
apiKey,
baseUrl = "https://mcp.hiveintelligence.xyz",
}) {
this.apiKey = apiKey;
this.baseUrl = baseUrl;
}
async execute(tool, args = {}) {
const response = await fetch(`${this.baseUrl}/api/v1/execute`, {
method: "POST",
headers: {
"Content-Type": "application/json",
"x-api-key": this.apiKey,
},
body: JSON.stringify({ tool, args }),
});
if (!response.ok) {
throw new Error(`Hive request failed: ${response.status} ${await response.text()}`);
}
return response.json();
}
async listTools(limit = 50) {
const response = await fetch(`${this.baseUrl}/api/v1/tools?limit=${limit}`, {
headers: { "x-api-key": this.apiKey },
});
if (!response.ok) {
throw new Error(`Tool discovery failed: ${response.status}`);
}
return response.json();
}
}
const client = new HiveClient({ apiKey: process.env.HIVE_API_KEY });
const market = await client.execute("get_coins_market_data", {
vs_currency: "usd",
order: "market_cap_desc",
per_page: 5,
});
const wallet = await client.execute("moralis_get_wallet_net_worth", {
address: "0x1234...",
chain: "eth",
});
TypeScript Shape
type ExecuteArgs = Record<string, unknown>;
interface HiveClientOptions {
apiKey: string;
baseUrl?: string;
}
class HiveClient {
constructor(private options: HiveClientOptions) {}
async execute<T>(tool: string, args: ExecuteArgs = {}): Promise<T> {
const response = await fetch(`${this.options.baseUrl ?? "https://mcp.hiveintelligence.xyz"}/api/v1/execute`, {
method: "POST",
headers: {
"Content-Type": "application/json",
"x-api-key": this.options.apiKey,
},
body: JSON.stringify({ tool, args }),
});
if (!response.ok) {
throw new Error(`Hive request failed: ${response.status}`);
}
return response.json() as Promise<T>;
}
}
type PriceResponse = {
bitcoin?: { usd?: number };
};
Common Patterns
Market monitoring
const gainers = await client.execute("get_gainers_losers", {
vs_currency: "usd",
duration: "24h",
});
Wallet analysis
const balances = await client.execute("get_wallet_balances", {
network: "eth",
address: "0x1234...",
});
DeFi monitoring
const pools = await client.execute("get_yield_pools", {
chain: "ethereum",
});
Prediction markets
const markets = await client.execute("codex_prediction_markets", {
networkId: 1,
});
Notes
- The current REST payload keys are
toolandargs. - Use
GET /api/v1/toolsor Live Catalog when choosing tool names. - Prefer the MCP endpoint if your runtime already supports tool discovery natively.