Arg0/Docs

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:

CategoryDescription
AI APICode completion, suggestions, and generation
Collaboration APIReal-time synchronization and team features
Workflow APIAutomation pipelines and task management
Analytics APIMetrics, insights, and performance data

Getting Started

Authentication

All API requests require authentication using an API key:

typescript
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:

  1. Navigate to arg0.dev
  2. Sign in or create an account
  3. Go to Settings > API Keys
  4. Generate a new API key
  5. Copy and securely store your API key

Base URL

The base URL for all API requests is:

text
https://api.arg0.dev/v1

For development and testing, you can use:

text
http://localhost:3004/api

Request Format

Standard Request

All API requests follow this format:

typescript
{
  // 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:

json
{
  "success": true,
  "data": {
    // Response data
  },
  "meta": {
    "requestId": "req_123",
    "timestamp": "2024-01-15T10:30:00Z"
  }
}

Error Response

Error response format:

json
{
  "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:

PlanRequests per MinuteRequests per Hour
Free10010,000
Pro1,000100,000
EnterpriseCustomCustom

Rate Limit Headers

Rate limit information is included in response headers:

text
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:

json
{
  "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

bash
npm install @arg0/sdk
typescript
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

bash
pip install arg0-sdk
python
from arg0 import Arg0Client

client = Arg0Client(api_key='your-api-key')

completion = client.ai.complete(
    code='function hello() {',
    language='typescript'
)

Go

bash
go get github.com/arg0/sdk-go
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

typescript
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 completed
  • workflow.failed: Workflow execution failed
  • deployment.started: Deployment started
  • deployment.completed: Deployment completed
  • deployment.failed: Deployment failed

Webhook Security

Webhooks are signed with a secret for verification:

typescript
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

Next Steps