@nexapi/sdk
v1.0.0
Published
Official SDK for APIFlow - AI-powered API automation platform
Maintainers
Readme
NexAPI SDK
Official TypeScript/JavaScript SDK for NexAPI - the AI-powered API automation platform.
Installation
npm install @nexapi/sdkQuick Start
import NexAPISDK from '@nexapi/sdk';
const nexapi = new NexAPISDK({
apiKey: 'your-api-key-here',
baseURL: 'https://api.nexapi.com' // optional
});
// Create a new automation flow
const flow = await nexapi.createFlow('Send SMS when Stripe payment received');
// Execute a test
const testResult = await nexapi.executeTest(flow.id, {
mockData: { amount: 100, currency: 'USD' }
});
// Deploy the flow
const deployment = await nexapi.deployFlow(flow.id, 'replit');Configuration
Basic Configuration
const nexapi = new NexAPISDK({
apiKey: 'your-api-key-here'
});Advanced Configuration
const nexapi = new NexAPISDK({
apiKey: 'your-api-key-here',
baseURL: 'https://api.nexapi.com',
timeout: 30000 // 30 seconds
});Flow Management
Create a Flow
const flow = await nexapi.createFlow('Send email when new GitHub issue created');
console.log(flow.id, flow.intent, flow.apis);Get Flow Details
const flow = await nexapi.getFlow('flow-id');
console.log(flow.name, flow.status, flow.code);List All Flows
const flows = await nexapi.listFlows();
flows.forEach(flow => console.log(flow.name));Update Flow
const updatedFlow = await apiflow.updateFlow('flow-id', {
name: 'Updated Flow Name',
status: 'active'
});Delete Flow
await apiflow.deleteFlow('flow-id');API Discovery
Search APIs
const apis = await apiflow.searchAPIs('payment', ['webhook', 'processing']);
apis.forEach(api => console.log(api.name, api.category));Get API Details
const api = await apiflow.getAPI(123);
console.log(api.name, api.documentation, api.capabilities);List All APIs
const apis = await apiflow.listAPIs();
console.log(`Found ${apis.length} APIs`);Templates
Get Templates
const templates = await apiflow.getTemplates();
templates.forEach(template => console.log(template.name, template.category));Get Template by ID
const template = await apiflow.getTemplate(1);
console.log(template.prompt, template.usageCount);Get Templates by Category
const ecommerceTemplates = await apiflow.getTemplatesByCategory('E-commerce');Testing
Execute Test
const testExecution = await apiflow.executeTest(flowId, {
apiKeys: {
stripe: 'sk_test_...',
twilio: 'AC...'
},
mockData: {
amount: 100,
currency: 'USD',
customer: 'cus_...'
}
});Get Test Results
const testResult = await apiflow.getTestExecution(testId);
console.log(testResult.status, testResult.results, testResult.logs);Get All Test Executions for Flow
const tests = await apiflow.getTestExecutions(flowId);
tests.forEach(test => console.log(test.status, test.duration));Deployment
Deploy Flow
const deployment = await apiflow.deployFlow(flowId, 'replit');
console.log(deployment.status, deployment.url);Get Deployment Status
const deployment = await apiflow.getDeployment(deploymentId);
console.log(deployment.status, deployment.logs);Get All Deployments for Flow
const deployments = await apiflow.getDeployments(flowId);
deployments.forEach(dep => console.log(dep.platform, dep.status));Subflows (Reusable Components)
Get Subflows
const subflows = await apiflow.getSubflows();
subflows.forEach(subflow => console.log(subflow.name, subflow.category));Create Subflow
const subflow = await apiflow.createSubflow({
name: 'Email Notification',
description: 'Send email with template',
category: 'Communication',
isPublic: true,
steps: [
{ type: 'email', template: 'notification', to: '{{email}}' }
]
});Update Subflow
const updatedSubflow = await apiflow.updateSubflow(subflowId, {
description: 'Updated description',
isPublic: false
});Plugins
Get Available Plugins
const plugins = await apiflow.getPlugins();
plugins.forEach(plugin => console.log(plugin.name, plugin.category));Install Plugin
const plugin = await apiflow.installPlugin('plugin-id');
console.log(`Installed ${plugin.name}`);Uninstall Plugin
await apiflow.uninstallPlugin('plugin-id');Usage & Billing
Get Usage Metrics
const usage = await apiflow.getUsage('30d');
console.log(usage.usage.flows, usage.limits.flows);Get Billing Plans
const plans = await apiflow.getBillingPlans();
plans.forEach(plan => console.log(plan.plan, plan.price));Webhooks
Create Webhook
const webhook = await apiflow.createWebhook('https://your-app.com/webhook', [
'flow.created',
'flow.executed',
'test.completed'
]);Get Webhooks
const webhooks = await apiflow.getWebhooks();
webhooks.forEach(webhook => console.log(webhook.url, webhook.events));Delete Webhook
await apiflow.deleteWebhook('webhook-id');Utility Methods
Validate API Key
const isValid = await apiflow.validateAPIKey();
if (!isValid) {
console.error('Invalid API key');
}Check Service Health
const health = await apiflow.getHealth();
console.log(health.status, health.uptime);Error Handling
try {
const flow = await apiflow.createFlow('Invalid prompt');
} catch (error) {
if (error.response?.status === 400) {
console.error('Bad request:', error.response.data.message);
} else if (error.response?.status === 401) {
console.error('Unauthorized: Check your API key');
} else {
console.error('Unexpected error:', error.message);
}
}TypeScript Support
The SDK is written in TypeScript and includes full type definitions:
import NexAPISDK, { Flow, API, Template } from '@nexapi/sdk';
const nexapi = new NexAPISDK({ apiKey: 'your-key' });
// Full typing support
const flow: Flow = await nexapi.createFlow('prompt');
const apis: API[] = await nexapi.searchAPIs('query');
const templates: Template[] = await nexapi.getTemplates();Authentication
Get your API key from the NexAPI Dashboard.
Rate Limits
- Free plan: 100 requests per hour
- Pro plan: 1,000 requests per hour
- Enterprise plan: 10,000 requests per hour
Support
- Documentation: https://docs.nexapi.com
- GitHub Issues: https://github.com/nexapi/sdk/issues
- Email: [email protected]
License
MIT License - see LICENSE file for details.
