UNPKG

@agentek/tools

Version:

Blockchain tools for AI agents

27 lines 1.05 kB
import { z } from "zod"; import { createTool } from "../client.js"; import { clean } from "../utils.js"; const getFearAndGreedIndexToolParams = z.object({}); export const fearGreedIndexTool = createTool({ name: "getFearAndGreedIndex", description: "Retrieves the current Fear and Greed Index value from Alternative.me API.", parameters: getFearAndGreedIndexToolParams, execute: async (_client, _args) => { try { const response = await fetch("https://api.alternative.me/fng/"); const data = await response.json(); if (!data || !data.data || !Array.isArray(data.data) || !data.data[0] || !data.data[0].value) { throw new Error("Invalid response format from Fear and Greed API."); } return clean(data.data[0]); } catch (error) { throw new Error(`Failed to fetch Fear and Greed Index: ${error.message}`); } }, }); //# sourceMappingURL=tools.js.map