nexus-agent-sdk
v1.0.0
Published
Official JavaScript/TypeScript SDK for NEXUS AI Agent Marketplace - Discover, test, and integrate APIs for AI agents
Downloads
22
Maintainers
Readme
NEXUS AI Agent Marketplace - JavaScript/TypeScript SDK
Official JavaScript/TypeScript SDK for the NEXUS AI Agent Marketplace.
Installation
npm install nexus-aimarket-sdk
# or
yarn add nexus-aimarket-sdkQuick Start
import { NexusClient } from 'nexus-aimarket-sdk';
// Create a client (no auth needed for public endpoints)
const client = new NexusClient();
// Search for services
const services = await client.search({ protocol: 'mcp', sandbox: true });
console.log(`Found ${services.total} services`);
// Get trending
const trending = await client.trending({ limit: 10 });
trending.trending.forEach(svc => {
console.log(` ${svc.name}: score ${svc.trending_score}`);
});
// Get registry export
const registry = await client.getRegistry({ protocol: 'aitp' });Authenticated Operations
import { NexusClient } from 'nexus-aimarket-sdk';
// Create client with API key
const client = new NexusClient({ apiKey: 'nxs_your_api_key' });
// Register a service
const service = await client.registerService({
name: 'My AI Service',
description: 'A powerful AI-powered API',
category: 'ai',
tags: ['nlp', 'text-generation'],
pricePerRequest: 0.5,
sandboxEnabled: true,
sandboxCallLimit: 50
});
console.log(`Registered: ${service.service_id}`);
// Create webhook subscription
const webhook = await client.createWebhookSubscription({
url: 'https://my-server.com/webhooks/nexus',
events: ['service.registered', 'service.trending']
});
console.log(`Webhook secret: ${webhook.secret}`); // Save this!API Reference
Discovery (No Auth Required)
search(params)- Search services with filtersgetProtocols()- List supported protocolsgetCategories()- List categoriesgetService(serviceId)- Get service detailsgetServiceHealth(serviceId)- Get health status
Registry
getRegistry(params)- Get agents.json exportgetRegistryStats()- Get statistics
Trending
trending(params)- Get trending serviceshotSandbox(limit)- Get hot sandbox servicesrising(params)- Get fastest growing services
Metrics
getServiceMetrics(serviceId, period)- Service metricsgetProtocolMetrics(protocol, period)- Protocol metricsgetPlatformMetrics(period)- Platform metrics
MCP Gateway
listTools()- List MCP toolsexecuteTool(params)- Execute with payment
Sandbox
listSandboxServices()- List sandbox servicesexecuteSandbox(params)- Execute in sandbox (free)getSandboxUsage(agentId, serviceId)- Check usage
Agent Management
registerAgent(params)- Register new agentgetAgentBalance(agentId)- Check balancegeneratePaymentProof(agentId, amount)- Generate proof
API Keys (Auth Required)
createApiKey(params)- Create new keylistApiKeys()- List your keysrotateApiKey(keyId)- Rotate keyrevokeApiKey(keyId)- Revoke key
Service Registration (Auth Required)
registerService(params)- Register servicelistMyServices()- List your servicesupdateService(serviceId, updates)- Update servicerequestPromotion(serviceId, justification)- Request production
Webhooks (Auth Required)
createWebhookSubscription(params)- SubscribelistWebhookSubscriptions()- List subscriptionsdeleteWebhookSubscription(id)- Unsubscribe
Error Handling
import { NexusClient, NexusError, NexusRateLimitError, NexusAuthError } from 'nexus-aimarket-sdk';
const client = new NexusClient({ apiKey: 'nxs_...' });
try {
const result = await client.search({ protocol: 'mcp' });
} catch (error) {
if (error instanceof NexusAuthError) {
console.log('Auth failed');
} else if (error instanceof NexusRateLimitError) {
console.log(`Rate limited. Retry after ${error.retryAfter} seconds`);
} else if (error instanceof NexusError) {
console.log(`API error: ${error.message} (status: ${error.statusCode})`);
}
}License
MIT
