flexo-sdk
Version:
Official TypeScript SDK for the Flexo API - AI-powered Solana token analytics
56 lines (55 loc) • 1.65 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.FlexoClient = void 0;
class FlexoClient {
constructor(baseUrl = 'https://api.flexo.sh') {
this.baseUrl = baseUrl;
}
async request(endpoint, options = {}) {
const url = `${this.baseUrl}${endpoint}`;
const headers = {
'Accept': 'application/json',
'Content-Type': 'application/json',
...options.headers,
};
const response = await fetch(url, { ...options, headers });
const data = await response.json();
if (!response.ok) {
const error = data;
throw new Error(error.message || 'An error occurred');
}
return data;
}
/**
* Get detailed information about a token
* @param address The token's contract address
*/
async getToken(address) {
return this.request(`/v1/token/${address}`);
}
/**
* List all available AI agents
*/
async listAgents() {
return this.request('/v1/agents');
}
/**
* Get details about a specific agent
* @param id The agent's ID
*/
async getAgent(id) {
return this.request(`/v1/agents/${id}`);
}
/**
* Chat with an AI agent
* @param agentId The agent's ID
* @param messages Array of chat messages
*/
async chat(agentId, messages) {
return this.request(`/v1/agents/${agentId}/chat`, {
method: 'POST',
body: JSON.stringify({ messages }),
});
}
}
exports.FlexoClient = FlexoClient;