API Overview
Extend Arg0's capabilities - Comprehensive API for building custom integrations, automating workflows, and extending development environments with powerful REST endpoints.
Comprehensive overview of Arg0's API capabilities and integration options.
Overview
Arg0 provides a powerful set of APIs for extending development environments, building custom integrations, and automating workflows. The API is designed to be flexible, secure, and easy to integrate with your existing tools and workflows.
API Categories
Arg0's API is organized into several categories:
| Category | Description |
|---|---|
| AI API | Code completion, suggestions, and generation |
| Collaboration API | Real-time synchronization and team features |
| Workflow API | Automation pipelines and task management |
| Analytics API | Metrics, insights, and performance data |
Getting Started
Authentication
All API requests require authentication using an API key:
const response = await fetch('https://api.arg0.dev/v1/ai/complete', {
headers: {
'Authorization': `Bearer ${API_KEY}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({
code: 'function hello() {',
language: 'typescript'
})
});
API Keys
To get an API key:
- Navigate to arg0.dev
- Sign in or create an account
- Go to Settings > API Keys
- Generate a new API key
- Copy and securely store your API key
Base URL
The base URL for all API requests is:
https://api.arg0.dev/v1
For development and testing, you can use:
http://localhost:3004/api
Request Format
Standard Request
All API requests follow this format:
{
// Request headers
headers: {
'Authorization': `Bearer ${API_KEY}`,
'Content-Type': 'application/json',
'User-Agent': 'YourApp/1.0'
},
// Request body
body: JSON.stringify({
// API-specific parameters
})
}
Response Format
Standard API response format:
{
"success": true,
"data": {
// Response data
},
"meta": {
"requestId": "req_123",
"timestamp": "2024-01-15T10:30:00Z"
}
}
Error Response
Error response format:
{
"success": false,
"error": {
"code": "INVALID_REQUEST",
"message": "Invalid request parameters",
"details": "Parameter 'code' is required"
},
"meta": {
"requestId": "req_123",
"timestamp": "2024-01-15T10:30:00Z"
}
}
Rate Limits
API rate limits ensure fair usage and system stability:
| Plan | Requests per Minute | Requests per Hour |
|---|---|---|
| Free | 100 | 10,000 |
| Pro | 1,000 | 100,000 |
| Enterprise | Custom | Custom |
Rate Limit Headers
Rate limit information is included in response headers:
X-RateLimit-Limit: 1000
X-RateLimit-Remaining: 999
X-RateLimit-Reset: 1605724800
Handling Rate Limits
When you exceed rate limits, you'll receive a 429 Too Many Requests response:
{
"error": {
"code": "RATE_LIMIT_EXCEEDED",
"message": "API rate limit exceeded",
"details": {
"limit": 1000,
"remaining": 0,
"reset": "2024-01-15T11:00:00Z"
}
}
}
SDKs
Official SDKs are available for popular languages:
JavaScript/TypeScript
npm install @arg0/sdk
import { Arg0Client } from '@arg0/sdk';
const client = new Arg0Client({
apiKey: 'your-api-key'
});
const completion = await client.ai.complete({
code: 'function hello() {',
language: 'typescript'
});
Python
pip install arg0-sdk
from arg0 import Arg0Client
client = Arg0Client(api_key='your-api-key')
completion = client.ai.complete(
code='function hello() {',
language='typescript'
)
Go
go get github.com/arg0/sdk-go
import "github.com/arg0/sdk-go"
client := arg0.NewClient("your-api-key")
completion, err := client.AI.Complete(
"function hello() {",
"typescript",
)
Webhooks
Configure webhooks to receive real-time notifications:
Setting Up Webhooks
POST /v1/webhooks
{
"url": "https://your-server.com/webhook",
"events": ["workflow.completed", "deployment.failed"],
"secret": "your-webhook-secret"
}
Webhook Events
Available webhook events:
workflow.completed: Workflow execution completedworkflow.failed: Workflow execution faileddeployment.started: Deployment starteddeployment.completed: Deployment completeddeployment.failed: Deployment failed
Webhook Security
Webhooks are signed with a secret for verification:
import crypto from 'crypto';
function verifyWebhook(payload, signature, secret) {
const hmac = crypto.createHmac('sha256', secret);
hmac.update(payload);
const expectedSignature = hmac.digest('hex');
return crypto.timingSafeEqual(
Buffer.from(signature),
Buffer.from(expectedSignature)
);
}
Best Practices
Security
- Never expose API keys: Store keys securely in environment variables
- Use HTTPS: Always use HTTPS in production
- Rotate keys regularly: Periodically rotate your API keys
- Monitor usage: Monitor API usage for unusual activity
Performance
- Cache responses: Cache API responses when appropriate
- Batch requests: Combine multiple requests when possible
- Use webhooks: Use webhooks instead of polling
- Optimize payload size: Minimize request and response sizes
Error Handling
- Implement retry logic: Handle transient failures gracefully
- Log errors: Log API errors for debugging
- Handle rate limits: Implement exponential backoff
- Validate responses: Validate API responses before use
Support
Documentation
- API Reference: Detailed API documentation
- SDK Documentation: SDK-specific guides
- Examples: Code examples and tutorials
- Status Page: status.arg0.dev
Getting Help
- Community Forum: forum.arg0.dev
- Support Email: support@arg0.dev
- GitHub Issues: github.com/arg0/issues
- Documentation: docs.arg0.dev
Next Steps
- AI API - AI-powered code completion
- Collaboration API - Real-time collaboration
- Workflow API - Workflow automation
- Analytics API - Metrics and insights