invokeapi
v0.1.1
Published
Node.js SDK for invokeAPI — the API marketplace for AI and data endpoints
Maintainers
Readme
invokeAPI Node.js SDK
Official Node.js SDK for invokeAPI — the API marketplace for AI and data endpoints.
npm install invokeapiGetting Started
- Sign up at invoke-api.com
- Get an API key from your Consumer Dashboard
- Browse builds on the Marketplace to find endpoints to call
Quick Start
const InvokeAPI = require('invokeapi');
const client = new InvokeAPI('am_live_your_key_here');
// Call a build
const result = await client.call('drc-pattern-scanner', { type: 'symbols' });
console.log(result);
// Call a specific tool
const candles = await client.call('drc-pattern-scanner',
{ type: 'candles', symbol: 'BTCUSDT', timeframe: '1d', limit: 5 },
{ tool: 'get-candles' }
);
// Check your balance
console.log(`Balance: $${await client.getBalance()}`);Configuration
const client = new InvokeAPI('am_live_your_key_here', {
baseUrl: 'https://invokeapi-production.up.railway.app', // default
timeout: 30000, // request timeout in ms (default: 30s)
});Features
Synchronous Calls
const result = await client.call('build-slug', { key: 'value' });
// With idempotency (prevents duplicate charges on retries)
const result = await client.call('build-slug', { key: 'value' }, {
idempotencyKey: 'unique-request-id'
});Streaming (SSE)
for await (const event of client.stream('build-slug', { prompt: 'hello' })) {
console.log(event);
}Async Jobs
// Submit a job
const job = await client.submitJob('build-slug', 'backtest', {
symbol: 'BTCUSDT', strategy: 'drc'
});
// Wait for completion with progress updates
const result = await client.waitForJob(job.job_id, {
pollInterval: 3000, // check every 3s (default)
timeout: 600000, // max 10 min (default)
onProgress: (d) => console.log(`Status: ${d.status}`)
});
// Or check manually
const status = await client.getJob(job.job_id);
await client.cancelJob(job.job_id);Discovery
// List all available builds
const builds = await client.listBuilds();
// Get build details
const build = await client.getBuild('drc-pattern-scanner');
// Search builds
const results = await client.search('crypto', { category: 'trading' });
// Trending builds
const trending = await client.trending(7); // last 7 daysPipelines
const output = await client.runPipeline('my-pipeline', { symbol: 'BTCUSDT' });Response Metadata
Every response includes _meta with billing and request info:
const result = await client.call('build-slug', { key: 'value' });
console.log(result._meta);
// {
// status: 200,
// creditsCharged: '0.01',
// creditsRemaining: '19.99',
// requestId: 'req_abc123',
// cached: false
// }Error Handling
const { InvokeAPIError } = require('invokeapi');
try {
await client.call('build-slug', { key: 'value' });
} catch (err) {
if (err instanceof InvokeAPIError) {
console.log(err.message); // Error description
console.log(err.statusCode); // HTTP status (402 = insufficient credits)
console.log(err.response); // Raw response object
}
}API Reference
| Method | Description |
|--------|-------------|
| call(slug, params, { tool, idempotencyKey }) | Call a build |
| stream(slug, params, { tool }) | SSE streaming (async generator) |
| submitJob(slug, jobType, params) | Submit async job |
| getJob(jobId) | Check job status |
| waitForJob(jobId, { pollInterval, timeout, onProgress }) | Poll until done |
| cancelJob(jobId) | Cancel a job |
| listBuilds() | List all live builds |
| getBuild(slug) | Get build details |
| search(query, filters) | Search builds |
| trending(days) | Get trending builds |
| runPipeline(slug, input) | Execute a pipeline |
| me() | Get account info |
| getBalance() | Current credit balance |
Links
License
MIT
