Official TypeScript/JavaScript SDK for the Prometheus Swarm platform. Create bounties, manage swarm tasks, and interact with the decentralized workforce platform programmatically.
npm install prometheus-swarm-sdk
# or
yarn add prometheus-swarm-sdk
# or
pnpm add prometheus-swarm-sdkimport { PrometheusSwarmSDK } from 'prometheus-swarm-sdk';
// Initialize the SDK
const sdk = new PrometheusSwarmSDK({
apiKey: 'your-api-key-here',
baseUrl: 'https://prometheusswarm.ai' // optional, defaults to production
});
// Create a bounty
const bounty = await sdk.createBounty({
email: 'user@example.com',
githubUrl: 'https://github.com/owner/repo',
description: 'Detailed task description',
bountyAmount: 100,
swarmType: 'find-bugs', // 'document-summarizer' | 'find-bugs' | 'build-feature'
projectName: 'My Project' // optional
});
console.log('Bounty created:', bounty.data);interface SDKConfig {
apiKey: string; // Required: Your Prometheus API key
baseUrl?: string; // Optional: API base URL (default: https://prometheusswarm.ai)
timeout?: number; // Optional: Request timeout in ms (default: 30000)
retryAttempts?: number; // Optional: Number of retry attempts (default: 3)
retryDelay?: number; // Optional: Delay between retries in ms (default: 1000)
}Creates a new swarm bounty.
const bounty = await sdk.createBounty({
email: 'user@example.com',
githubUrl: 'https://github.com/owner/repo',
description: 'Detailed task description',
bountyAmount: 100,
swarmType: 'find-bugs', // 'document-summarizer' | 'find-bugs' | 'build-feature'
projectName: 'My Project' // optional
});Retrieves all bounties for a specific user.
const userBounties = await sdk.getUserBounties('user@example.com');
console.log(`Found ${userBounties.count} bounties:`, userBounties.data);Gets detailed information about a specific bounty.
const details = await sdk.getBountyDetails('bounty-id');
console.log('Bounty details:', details.data);document-summarizer: Document analysis and summarization tasksfind-bugs: Bug finding and security auditing tasksbuild-feature: Feature development and implementation tasks
All bounties are paid using platform credits. Credits are automatically deducted from your account balance when creating a bounty.
The SDK provides detailed error types for better error handling:
import {
PrometheusSDKError,
PrometheusAPIError,
ValidationError,
RateLimitError,
AuthenticationError,
NetworkError
} from 'prometheus-swarm-sdk';
try {
const bounty = await sdk.createBounty(bountyRequest);
} catch (error) {
if (error instanceof ValidationError) {
console.error('Validation failed:', error.message, 'Field:', error.field);
} else if (error instanceof AuthenticationError) {
console.error('Authentication failed:', error.message);
} else if (error instanceof RateLimitError) {
console.error('Rate limit exceeded. Retry after:', error.retryAfter, 'seconds');
} else if (error instanceof PrometheusAPIError) {
console.error('API error:', error.message, 'Status:', error.status);
} else if (error instanceof NetworkError) {
console.error('Network error:', error.message);
}
}- Get API Key: Contact the Prometheus team or obtain your API key through the platform dashboard
- Set Environment Variable: Store your API key securely
export PROMETHEUS_API_KEY="your-api-key-here"
- Initialize SDK:
const sdk = new PrometheusSwarmSDK({ apiKey: process.env.PROMETHEUS_API_KEY! });
const bugBounty = await sdk.createBounty({
email: 'security@company.com',
githubUrl: 'https://github.com/company/secure-app',
description: 'Perform comprehensive security audit of user authentication system. Focus on SQL injection, XSS, and authentication bypass vulnerabilities.',
bountyAmount: 75,
swarmType: 'find-bugs',
projectName: 'SecureApp Audit'
});
if (bugBounty.success) {
console.log('Bug bounty created successfully!');
console.log('Bounty ID:', bugBounty.data.id);
console.log('Status:', bugBounty.data.status);
}const featureBounty = await sdk.createBounty({
email: 'product@startup.com',
githubUrl: 'https://github.com/startup/mobile-app',
description: 'Implement OAuth 2.0 social login integration with Google, GitHub, and Discord. Include proper error handling and user session management.',
bountyAmount: 200,
swarmType: 'build-feature',
projectName: 'Mobile App Social Login'
});
if (featureBounty.success) {
console.log('Feature bounty created successfully!');
console.log('Project:', featureBounty.data.projectName);
console.log('Amount:', featureBounty.data.bountyAmount, 'credits');
}const docBounty = await sdk.createBounty({
email: 'docs@company.com',
githubUrl: 'https://github.com/company/api-docs',
description: 'Create comprehensive API documentation with code examples, authentication guides, and troubleshooting sections.',
bountyAmount: 50,
swarmType: 'document-summarizer',
projectName: 'API Documentation'
});// Get all bounties for a user
const bounties = await sdk.getUserBounties('user@example.com');
for (const bounty of bounties.data) {
console.log(`Bounty: ${bounty['project-name']}`);
console.log(`Status: ${bounty.status}`);
console.log(`Amount: ${bounty['bounty-amount']} credits`);
// Get detailed information
const details = await sdk.getBountyDetails(bounty.id);
if (details.success && details.data) {
console.log(`Assigned to: ${details.data.githubUsername || 'Unassigned'}`);
console.log(`Subtasks: ${details.data.subTasks.length || 0}`);
}
console.log('---');
}The SDK automatically handles rate limiting with exponential backoff:
- API Rate Limit: 10 requests per 15 minutes per API key
- Automatic Retry: Up to 3 attempts with increasing delays
- Custom Configuration: Adjust retry behavior via SDK config
const sdk = new PrometheusSwarmSDK({
apiKey: 'your-key',
retryAttempts: 5, // Increase retry attempts
retryDelay: 2000, // Increase initial delay
timeout: 60000 // Increase timeout
});- Automatic Deduction: Credits are automatically deducted when creating bounties
- Insufficient Credits: API will return an error if you don't have enough credits
- Credit Balance: Contact support to check your current credit balance
- Purchasing Credits: Reach out to the Prometheus team to purchase additional credits
try {
// This will deduct 100 credits from your account
const bounty = await sdk.createBounty({
email: 'user@example.com',
githubUrl: 'https://github.com/user/repo',
description: 'High-value feature development',
bountyAmount: 100,
swarmType: 'build-feature'
});
} catch (error) {
if (error.message.includes('Credits validation failed')) {
console.error('Insufficient credits! Please contact support to purchase more.');
}
}The SDK is built with TypeScript and provides full type safety:
import type {
CreateBountyRequest,
BountyData,
SwarmType
} from 'prometheus-swarm-sdk';
// Full IntelliSense and type checking
const createBounty = (data: CreateBountyRequest): Promise<BountyData> => {
return sdk.createBounty(data).then(response => response.data!);
};We welcome contributions! Please see our Contributing Guide for details.
MIT License - see LICENSE file for details.
- Platform: https://prometheusswarm.ai
- Documentation: API Docs
- Support: Discord | GitHub Issues
If you encounter any issues or have questions:
- Check the examples directory
- Review the API documentation
- Search existing issues
- Create a new issue
- Join our Discord community
Contact the Prometheus team to:
- Check your current credit balance
- Purchase additional credits
- Set up auto-renewal for your account
- Discuss enterprise credit packages
Built with β€οΈ by the Prometheus team