pharos-agent-kit
Version:
Connect AI Agents to Pharos protocols
78 lines • 3.3 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.pingElfaAiApi = pingElfaAiApi;
exports.getElfaAiApiKeyStatus = getElfaAiApiKeyStatus;
exports.getSmartMentions = getSmartMentions;
exports.getTopMentionsByTicker = getTopMentionsByTicker;
exports.searchMentionsByKeywords = searchMentionsByKeywords;
exports.getTrendingTokensUsingElfaAi = getTrendingTokensUsingElfaAi;
exports.getSmartTwitterAccountStats = getSmartTwitterAccountStats;
const axios_1 = __importDefault(require("axios"));
function createAxiosInstance(apiKey) {
if (!apiKey) {
throw new Error("ELFA_AI_API_KEY is not configured in PharosAgentKit config.");
}
return axios_1.default.create({
baseURL: "https://api.elfa.ai",
headers: {
"x-elfa-api-key": apiKey,
"Content-Type": "application/json",
},
});
}
async function pingElfaAiApi(agent) {
const apiKey = agent.config?.ELFA_AI_API_KEY;
const axiosInstance = createAxiosInstance(apiKey);
const response = await axiosInstance.get("/v1/ping");
return response.data;
}
async function getElfaAiApiKeyStatus(agent) {
const apiKey = agent.config?.ELFA_AI_API_KEY;
const axiosInstance = createAxiosInstance(apiKey);
const response = await axiosInstance.get("/v1/key-status");
return response.data;
}
async function getSmartMentions(agent, limit = 100, offset = 0) {
const apiKey = agent.config?.ELFA_AI_API_KEY;
const axiosInstance = createAxiosInstance(apiKey);
const response = await axiosInstance.get("/v1/mentions", {
params: { limit, offset },
});
return response.data;
}
async function getTopMentionsByTicker(agent, ticker, timeWindow = "1h", page = 1, pageSize = 10, includeAccountDetails = false) {
const apiKey = agent.config?.ELFA_AI_API_KEY;
const axiosInstance = createAxiosInstance(apiKey);
const response = await axiosInstance.get("/v1/top-mentions", {
params: { ticker, timeWindow, page, pageSize, includeAccountDetails },
});
return response.data;
}
async function searchMentionsByKeywords(agent, keywords, from, to, limit = 20, cursor) {
const apiKey = agent.config?.ELFA_AI_API_KEY;
const axiosInstance = createAxiosInstance(apiKey);
const response = await axiosInstance.get("/v1/mentions/search", {
params: { keywords, from, to, limit, cursor },
});
return response.data;
}
async function getTrendingTokensUsingElfaAi(agent, timeWindow = "24h", page = 1, pageSize = 50, minMentions = 5) {
const apiKey = agent.config?.ELFA_AI_API_KEY;
const axiosInstance = createAxiosInstance(apiKey);
const response = await axiosInstance.get("/v1/trending-tokens", {
params: { timeWindow, page, pageSize, minMentions },
});
return response.data;
}
async function getSmartTwitterAccountStats(agent, username) {
const apiKey = agent.config?.ELFA_AI_API_KEY;
const axiosInstance = createAxiosInstance(apiKey);
const response = await axiosInstance.get("/v1/account/smart-stats", {
params: { username },
});
return response.data;
}
//# sourceMappingURL=elfa_ai_api.js.map