feat: add marketplace metrics, privacy features, and service registry endpoints
- Add Prometheus metrics for marketplace API throughput and error rates with new dashboard panels - Implement confidential transaction models with encryption support and access control - Add key management system with registration, rotation, and audit logging - Create services and registry routers for service discovery and management - Integrate ZK proof generation for privacy-preserving receipts - Add metrics instru
This commit is contained in:
77
docs/developer/api-authentication.md
Normal file
77
docs/developer/api-authentication.md
Normal file
@@ -0,0 +1,77 @@
|
||||
---
|
||||
title: API Authentication
|
||||
description: Understanding and implementing API authentication
|
||||
---
|
||||
|
||||
# API Authentication
|
||||
|
||||
All AITBC API endpoints require authentication using API keys.
|
||||
|
||||
## Getting API Keys
|
||||
|
||||
1. Visit the [AITBC Dashboard](https://dashboard.aitbc.io)
|
||||
2. Create an account or sign in
|
||||
3. Navigate to API Keys section
|
||||
4. Generate a new API key
|
||||
|
||||
## Using API Keys
|
||||
|
||||
### HTTP Header
|
||||
```http
|
||||
X-API-Key: your_api_key_here
|
||||
```
|
||||
|
||||
### Environment Variable
|
||||
```bash
|
||||
export AITBC_API_KEY="your_api_key_here"
|
||||
```
|
||||
|
||||
### SDK Configuration
|
||||
```python
|
||||
from aitbc import AITBCClient
|
||||
|
||||
client = AITBCClient(api_key="your_api_key")
|
||||
```
|
||||
|
||||
## Security Best Practices
|
||||
|
||||
- Never commit API keys to version control
|
||||
- Use environment variables in production
|
||||
- Rotate keys regularly
|
||||
- Use different keys for different environments
|
||||
- Monitor API key usage
|
||||
|
||||
## Rate Limits
|
||||
|
||||
API requests are rate-limited based on your plan:
|
||||
- Free: 60 requests/minute
|
||||
- Pro: 600 requests/minute
|
||||
- Enterprise: 6000 requests/minute
|
||||
|
||||
## Error Handling
|
||||
|
||||
```python
|
||||
from aitbc.exceptions import AuthenticationError
|
||||
|
||||
try:
|
||||
client.jobs.create({...})
|
||||
except AuthenticationError:
|
||||
print("Invalid API key")
|
||||
```
|
||||
|
||||
## Key Management
|
||||
|
||||
### View Your Keys
|
||||
```bash
|
||||
aitbc api-keys list
|
||||
```
|
||||
|
||||
### Revoke a Key
|
||||
```bash
|
||||
aitbc api-keys revoke <key_id>
|
||||
```
|
||||
|
||||
### Regenerate a Key
|
||||
```bash
|
||||
aitbc api-keys regenerate <key_id>
|
||||
```
|
||||
111
docs/developer/api/api/coordinator/authentication.md
Normal file
111
docs/developer/api/api/coordinator/authentication.md
Normal file
@@ -0,0 +1,111 @@
|
||||
---
|
||||
title: API Authentication
|
||||
description: Understanding authentication for the Coordinator API
|
||||
---
|
||||
|
||||
# API Authentication
|
||||
|
||||
All Coordinator API endpoints require authentication using API keys.
|
||||
|
||||
## Getting Started
|
||||
|
||||
1. Sign up at [AITBC Dashboard](https://dashboard.aitbc.io)
|
||||
2. Generate an API key
|
||||
3. Include the key in your requests
|
||||
|
||||
## Authentication Methods
|
||||
|
||||
### HTTP Header (Recommended)
|
||||
```http
|
||||
X-API-Key: your_api_key_here
|
||||
```
|
||||
|
||||
### Query Parameter
|
||||
```http
|
||||
GET /v1/jobs?api_key=your_api_key_here
|
||||
```
|
||||
|
||||
## Example Requests
|
||||
|
||||
### cURL
|
||||
```bash
|
||||
curl -X GET https://api.aitbc.io/v1/jobs \
|
||||
-H "X-API-Key: your_api_key_here"
|
||||
```
|
||||
|
||||
### Python
|
||||
```python
|
||||
import requests
|
||||
|
||||
headers = {
|
||||
"X-API-Key": "your_api_key_here"
|
||||
}
|
||||
|
||||
response = requests.get(
|
||||
"https://api.aitbc.io/v1/jobs",
|
||||
headers=headers
|
||||
)
|
||||
```
|
||||
|
||||
### JavaScript
|
||||
```javascript
|
||||
const headers = {
|
||||
"X-API-Key": "your_api_key_here"
|
||||
};
|
||||
|
||||
fetch("https://api.aitbc.io/v1/jobs", {
|
||||
headers: headers
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(data => console.log(data));
|
||||
```
|
||||
|
||||
## Security Best Practices
|
||||
|
||||
- Never expose API keys in client-side code
|
||||
- Use environment variables in production
|
||||
- Rotate keys regularly
|
||||
- Monitor API usage
|
||||
- Use HTTPS for all requests
|
||||
|
||||
## Rate Limits
|
||||
|
||||
API requests are rate-limited based on your plan:
|
||||
- Free: 60 requests/minute
|
||||
- Pro: 600 requests/minute
|
||||
- Enterprise: 6000 requests/minute
|
||||
|
||||
Rate limit headers are included in responses:
|
||||
```http
|
||||
X-RateLimit-Limit: 60
|
||||
X-RateLimit-Remaining: 59
|
||||
X-RateLimit-Reset: 1640995200
|
||||
```
|
||||
|
||||
## Error Handling
|
||||
|
||||
```json
|
||||
{
|
||||
"error": {
|
||||
"code": "INVALID_API_KEY",
|
||||
"message": "The provided API key is invalid"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Key Management
|
||||
|
||||
### View Your Keys
|
||||
Visit the [Dashboard](https://dashboard.aitbc.io/api-keys)
|
||||
|
||||
### Revoke a Key
|
||||
```bash
|
||||
curl -X DELETE https://api.aitbc.io/v1/api-keys/{key_id} \
|
||||
-H "X-API-Key: your_master_key"
|
||||
```
|
||||
|
||||
### Regenerate a Key
|
||||
```bash
|
||||
curl -X POST https://api.aitbc.io/v1/api-keys/{key_id}/regenerate \
|
||||
-H "X-API-Key: your_master_key"
|
||||
```
|
||||
575
docs/developer/api/api/coordinator/endpoints.md
Normal file
575
docs/developer/api/api/coordinator/endpoints.md
Normal file
@@ -0,0 +1,575 @@
|
||||
---
|
||||
title: API Endpoints
|
||||
description: Complete list of Coordinator API endpoints
|
||||
---
|
||||
|
||||
# API Endpoints
|
||||
|
||||
## Jobs
|
||||
|
||||
### Create Job
|
||||
```http
|
||||
POST /v1/jobs
|
||||
```
|
||||
|
||||
Create a new AI job.
|
||||
|
||||
**Request Body:**
|
||||
```json
|
||||
{
|
||||
"name": "image-classification",
|
||||
"type": "ai-inference",
|
||||
"model": {
|
||||
"type": "python",
|
||||
"entrypoint": "model.py",
|
||||
"requirements": ["numpy", "torch"]
|
||||
},
|
||||
"input": {
|
||||
"type": "image",
|
||||
"format": "jpeg"
|
||||
},
|
||||
"output": {
|
||||
"type": "json"
|
||||
},
|
||||
"resources": {
|
||||
"cpu": "1000m",
|
||||
"memory": "2Gi",
|
||||
"gpu": "1"
|
||||
},
|
||||
"pricing": {
|
||||
"max_cost": "0.10"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
**Response:**
|
||||
```json
|
||||
{
|
||||
"job_id": "job_1234567890",
|
||||
"status": "submitted",
|
||||
"created_at": "2024-01-01T12:00:00Z",
|
||||
"estimated_completion": "2024-01-01T12:05:00Z"
|
||||
}
|
||||
```
|
||||
|
||||
### Get Job Status
|
||||
```http
|
||||
GET /v1/jobs/{job_id}
|
||||
```
|
||||
|
||||
Retrieve the current status of a job.
|
||||
|
||||
**Response:**
|
||||
```json
|
||||
{
|
||||
"job_id": "job_1234567890",
|
||||
"status": "running",
|
||||
"progress": 75,
|
||||
"created_at": "2024-01-01T12:00:00Z",
|
||||
"started_at": "2024-01-01T12:01:00Z",
|
||||
"estimated_completion": "2024-01-01T12:05:00Z",
|
||||
"miner_id": "miner_1234567890"
|
||||
}
|
||||
```
|
||||
|
||||
### List Jobs
|
||||
```http
|
||||
GET /v1/jobs
|
||||
```
|
||||
|
||||
List all jobs with optional filtering.
|
||||
|
||||
**Query Parameters:**
|
||||
- `status` (string): Filter by status (submitted, running, completed, failed)
|
||||
- `type` (string): Filter by job type
|
||||
- `limit` (integer): Maximum number of jobs to return (default: 50)
|
||||
- `offset` (integer): Number of jobs to skip (default: 0)
|
||||
|
||||
**Response:**
|
||||
```json
|
||||
{
|
||||
"jobs": [
|
||||
{
|
||||
"job_id": "job_1234567890",
|
||||
"status": "completed",
|
||||
"type": "ai-inference",
|
||||
"created_at": "2024-01-01T12:00:00Z"
|
||||
}
|
||||
],
|
||||
"total": 1,
|
||||
"limit": 50,
|
||||
"offset": 0
|
||||
}
|
||||
```
|
||||
|
||||
### Cancel Job
|
||||
```http
|
||||
DELETE /v1/jobs/{job_id}
|
||||
```
|
||||
|
||||
Cancel a running or submitted job.
|
||||
|
||||
**Response:**
|
||||
```json
|
||||
{
|
||||
"job_id": "job_1234567890",
|
||||
"status": "cancelled",
|
||||
"cancelled_at": "2024-01-01T12:03:00Z"
|
||||
}
|
||||
```
|
||||
|
||||
### Get Job Results
|
||||
```http
|
||||
GET /v1/jobs/{job_id}/results
|
||||
```
|
||||
|
||||
Retrieve the results of a completed job.
|
||||
|
||||
**Response:**
|
||||
```json
|
||||
{
|
||||
"job_id": "job_1234567890",
|
||||
"status": "completed",
|
||||
"results": {
|
||||
"prediction": "cat",
|
||||
"confidence": 0.95,
|
||||
"processing_time": 1.23
|
||||
},
|
||||
"completed_at": "2024-01-01T12:04:00Z"
|
||||
}
|
||||
```
|
||||
|
||||
## Marketplace
|
||||
|
||||
### Create Offer
|
||||
```http
|
||||
POST /v1/marketplace/offers
|
||||
```
|
||||
|
||||
Create a new marketplace offer for job execution.
|
||||
|
||||
**Request Body:**
|
||||
```json
|
||||
{
|
||||
"job_type": "image-classification",
|
||||
"price": "0.001",
|
||||
"max_jobs": 10,
|
||||
"requirements": {
|
||||
"min_gpu_memory": "4Gi",
|
||||
"min_cpu": "2000m"
|
||||
},
|
||||
"duration": 3600
|
||||
}
|
||||
```
|
||||
|
||||
**Response:**
|
||||
```json
|
||||
{
|
||||
"offer_id": "offer_1234567890",
|
||||
"miner_id": "miner_1234567890",
|
||||
"status": "active",
|
||||
"created_at": "2024-01-01T12:00:00Z"
|
||||
}
|
||||
```
|
||||
|
||||
### List Offers
|
||||
```http
|
||||
GET /v1/marketplace/offers
|
||||
```
|
||||
|
||||
List all active marketplace offers.
|
||||
|
||||
**Query Parameters:**
|
||||
- `job_type` (string): Filter by job type
|
||||
- `max_price` (string): Maximum price filter
|
||||
- `limit` (integer): Maximum number of offers (default: 50)
|
||||
|
||||
**Response:**
|
||||
```json
|
||||
{
|
||||
"offers": [
|
||||
{
|
||||
"offer_id": "offer_1234567890",
|
||||
"miner_id": "miner_1234567890",
|
||||
"job_type": "image-classification",
|
||||
"price": "0.001",
|
||||
"reputation": 4.8
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### Accept Offer
|
||||
```http
|
||||
POST /v1/marketplace/offers/{offer_id}/accept
|
||||
```
|
||||
|
||||
Accept a marketplace offer for job execution.
|
||||
|
||||
**Request Body:**
|
||||
```json
|
||||
{
|
||||
"job_id": "job_1234567890",
|
||||
"bid_price": "0.001"
|
||||
}
|
||||
```
|
||||
|
||||
**Response:**
|
||||
```json
|
||||
{
|
||||
"transaction_id": "tx_1234567890",
|
||||
"status": "pending",
|
||||
"created_at": "2024-01-01T12:00:00Z"
|
||||
}
|
||||
```
|
||||
|
||||
## Receipts
|
||||
|
||||
### Get Receipt
|
||||
```http
|
||||
GET /v1/receipts/{job_id}
|
||||
```
|
||||
|
||||
Retrieve the receipt for a completed job.
|
||||
|
||||
**Response:**
|
||||
```json
|
||||
{
|
||||
"receipt_id": "receipt_1234567890",
|
||||
"job_id": "job_1234567890",
|
||||
"miner_id": "miner_1234567890",
|
||||
"signature": {
|
||||
"sig": "base64_signature",
|
||||
"public_key": "base64_public_key"
|
||||
},
|
||||
"attestations": [
|
||||
{
|
||||
"type": "completion",
|
||||
"timestamp": "2024-01-01T12:04:00Z",
|
||||
"signature": "base64_attestation"
|
||||
}
|
||||
],
|
||||
"created_at": "2024-01-01T12:04:00Z"
|
||||
}
|
||||
```
|
||||
|
||||
### Verify Receipt
|
||||
```http
|
||||
POST /v1/receipts/verify
|
||||
```
|
||||
|
||||
Verify the authenticity of a receipt.
|
||||
|
||||
**Request Body:**
|
||||
```json
|
||||
{
|
||||
"receipt": {
|
||||
"receipt_id": "receipt_1234567890",
|
||||
"signature": {
|
||||
"sig": "base64_signature",
|
||||
"public_key": "base64_public_key"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
**Response:**
|
||||
```json
|
||||
{
|
||||
"valid": true,
|
||||
"miner_signature_valid": true,
|
||||
"coordinator_attestations": 2,
|
||||
"verified_at": "2024-01-01T12:05:00Z"
|
||||
}
|
||||
```
|
||||
|
||||
## Analytics
|
||||
|
||||
### Get Marketplace Stats
|
||||
```http
|
||||
GET /v1/marketplace/stats
|
||||
```
|
||||
|
||||
Retrieve marketplace statistics.
|
||||
|
||||
**Response:**
|
||||
```json
|
||||
{
|
||||
"total_jobs": 10000,
|
||||
"active_jobs": 150,
|
||||
"completed_jobs": 9800,
|
||||
"failed_jobs": 50,
|
||||
"average_completion_time": 120.5,
|
||||
"total_volume": "1500.50",
|
||||
"active_miners": 500
|
||||
}
|
||||
```
|
||||
|
||||
### Get Miner Stats
|
||||
```http
|
||||
GET /v1/miners/{miner_id}/stats
|
||||
```
|
||||
|
||||
Retrieve statistics for a specific miner.
|
||||
|
||||
**Response:**
|
||||
```json
|
||||
{
|
||||
"miner_id": "miner_1234567890",
|
||||
"reputation": 4.8,
|
||||
"total_jobs": 500,
|
||||
"success_rate": 0.98,
|
||||
"average_completion_time": 115.2,
|
||||
"total_earned": "125.50",
|
||||
"active_since": "2024-01-01T00:00:00Z"
|
||||
}
|
||||
```
|
||||
|
||||
## Health
|
||||
|
||||
### Health Check
|
||||
```http
|
||||
GET /v1/health
|
||||
```
|
||||
|
||||
Check the health status of the coordinator service.
|
||||
|
||||
**Response:**
|
||||
```json
|
||||
{
|
||||
"status": "ok",
|
||||
"version": "1.0.0",
|
||||
"environment": "production",
|
||||
"timestamp": "2024-01-01T12:00:00Z",
|
||||
"services": {
|
||||
"database": "healthy",
|
||||
"blockchain": "healthy",
|
||||
"marketplace": "healthy"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## WebSocket API
|
||||
|
||||
### Real-time Updates
|
||||
```
|
||||
WSS /ws
|
||||
```
|
||||
|
||||
Connect to receive real-time updates about jobs and marketplace events.
|
||||
|
||||
**Message Types:**
|
||||
- `job_update`: Job status changes
|
||||
- `marketplace_update`: New offers or transactions
|
||||
- `receipt_created`: New receipts generated
|
||||
|
||||
**Example Message:**
|
||||
```json
|
||||
{
|
||||
"type": "job_update",
|
||||
"data": {
|
||||
"job_id": "job_1234567890",
|
||||
"status": "completed",
|
||||
"timestamp": "2024-01-01T12:04:00Z"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Error Codes
|
||||
|
||||
| Code | Description | HTTP Status |
|
||||
|------|-------------|-------------|
|
||||
| `INVALID_JOB_TYPE` | Unsupported job type | 400 |
|
||||
| `INSUFFICIENT_BALANCE` | Not enough funds in wallet | 402 |
|
||||
| `JOB_NOT_FOUND` | Job does not exist | 404 |
|
||||
| `JOB_ALREADY_COMPLETED` | Cannot modify completed job | 409 |
|
||||
| `OFFER_NOT_AVAILABLE` | Offer is no longer available | 410 |
|
||||
| `RATE_LIMIT_EXCEEDED` | Too many requests | 429 |
|
||||
| `INTERNAL_ERROR` | Server error | 500 |
|
||||
|
||||
## SDK Examples
|
||||
|
||||
### Python
|
||||
```python
|
||||
from aitbc import AITBCClient
|
||||
|
||||
client = AITBCClient(api_key="your_key")
|
||||
|
||||
# Create a job
|
||||
job = client.jobs.create({
|
||||
"name": "my-job",
|
||||
"type": "ai-inference",
|
||||
...
|
||||
})
|
||||
|
||||
# Get results
|
||||
results = client.jobs.get_results(job["job_id"])
|
||||
```
|
||||
|
||||
### JavaScript
|
||||
```javascript
|
||||
import { AITBCClient } from '@aitbc/client';
|
||||
|
||||
const client = new AITBCClient({ apiKey: 'your_key' });
|
||||
|
||||
// Create a job
|
||||
const job = await client.jobs.create({
|
||||
name: 'my-job',
|
||||
type: 'ai-inference',
|
||||
...
|
||||
});
|
||||
|
||||
// Get results
|
||||
const results = await client.jobs.getResults(job.jobId);
|
||||
```
|
||||
|
||||
## Services
|
||||
|
||||
### Whisper Transcription
|
||||
```http
|
||||
POST /v1/services/whisper/transcribe
|
||||
```
|
||||
|
||||
Transcribe audio file using Whisper.
|
||||
|
||||
**Request Body:**
|
||||
```json
|
||||
{
|
||||
"audio_url": "https://example.com/audio.mp3",
|
||||
"model": "base",
|
||||
"language": "en",
|
||||
"task": "transcribe"
|
||||
}
|
||||
```
|
||||
|
||||
### Stable Diffusion Generation
|
||||
```http
|
||||
POST /v1/services/stable-diffusion/generate
|
||||
```
|
||||
|
||||
Generate images from text prompts.
|
||||
|
||||
**Request Body:**
|
||||
```json
|
||||
{
|
||||
"prompt": "A beautiful sunset over mountains",
|
||||
"model": "stable-diffusion-1.5",
|
||||
"size": "1024x1024",
|
||||
"num_images": 1,
|
||||
"steps": 20
|
||||
}
|
||||
```
|
||||
|
||||
### LLM Inference
|
||||
```http
|
||||
POST /v1/services/llm/inference
|
||||
```
|
||||
|
||||
Run inference on language models.
|
||||
|
||||
**Request Body:**
|
||||
```json
|
||||
{
|
||||
"model": "llama-7b",
|
||||
"prompt": "Explain quantum computing",
|
||||
"max_tokens": 256,
|
||||
"temperature": 0.7
|
||||
}
|
||||
```
|
||||
|
||||
### Video Transcoding
|
||||
```http
|
||||
POST /v1/services/ffmpeg/transcode
|
||||
```
|
||||
|
||||
Transcode video files.
|
||||
|
||||
**Request Body:**
|
||||
```json
|
||||
{
|
||||
"input_url": "https://example.com/video.mp4",
|
||||
"output_format": "mp4",
|
||||
"codec": "h264",
|
||||
"resolution": "1920x1080"
|
||||
}
|
||||
```
|
||||
|
||||
### 3D Rendering
|
||||
```http
|
||||
POST /v1/services/blender/render
|
||||
```
|
||||
|
||||
Render 3D scenes with Blender.
|
||||
|
||||
**Request Body:**
|
||||
```json
|
||||
{
|
||||
"blend_file_url": "https://example.com/scene.blend",
|
||||
"engine": "cycles",
|
||||
"resolution_x": 1920,
|
||||
"resolution_y": 1080,
|
||||
"samples": 128
|
||||
}
|
||||
```
|
||||
|
||||
## Service Registry
|
||||
|
||||
### List All Services
|
||||
```http
|
||||
GET /v1/registry/services
|
||||
```
|
||||
|
||||
List all available GPU services with optional filtering.
|
||||
|
||||
**Query Parameters:**
|
||||
- `category` (optional): Filter by service category
|
||||
- `search` (optional): Search by name, description, or tags
|
||||
|
||||
### Get Service Definition
|
||||
```http
|
||||
GET /v1/registry/services/{service_id}
|
||||
```
|
||||
|
||||
Get detailed definition for a specific service.
|
||||
|
||||
### Get Service Schema
|
||||
```http
|
||||
GET /v1/registry/services/{service_id}/schema
|
||||
```
|
||||
|
||||
Get JSON schema for service input parameters.
|
||||
|
||||
### Get Service Requirements
|
||||
```http
|
||||
GET /v1/registry/services/{service_id}/requirements
|
||||
```
|
||||
|
||||
Get hardware requirements for a service.
|
||||
|
||||
### Validate Service Request
|
||||
```http
|
||||
POST /v1/registry/services/validate
|
||||
```
|
||||
|
||||
Validate a service request against the service schema.
|
||||
|
||||
**Request Body:**
|
||||
```json
|
||||
{
|
||||
"service_id": "llm_inference",
|
||||
"request_data": {
|
||||
"model": "llama-7b",
|
||||
"prompt": "Hello world",
|
||||
"max_tokens": 256
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
**Response:**
|
||||
```json
|
||||
{
|
||||
"valid": true,
|
||||
"errors": [],
|
||||
"warnings": []
|
||||
}
|
||||
```
|
||||
79
docs/developer/api/api/coordinator/openapi.md
Normal file
79
docs/developer/api/api/coordinator/openapi.md
Normal file
@@ -0,0 +1,79 @@
|
||||
---
|
||||
title: OpenAPI Specification
|
||||
description: Complete OpenAPI specification for the Coordinator API
|
||||
---
|
||||
|
||||
# OpenAPI Specification
|
||||
|
||||
The complete OpenAPI 3.0 specification for the AITBC Coordinator API is available below.
|
||||
|
||||
## Interactive Documentation
|
||||
|
||||
- [Swagger UI](https://api.aitbc.io/docs) - Interactive API explorer
|
||||
- [ReDoc](https://api.aitbc.io/redoc) - Alternative documentation view
|
||||
|
||||
## Download Specification
|
||||
|
||||
- [JSON Format](openapi.json) - Raw OpenAPI JSON
|
||||
- [YAML Format](openapi.yaml) - OpenAPI YAML format
|
||||
|
||||
## Key Endpoints
|
||||
|
||||
### Jobs
|
||||
- `POST /v1/jobs` - Create a new job
|
||||
- `GET /v1/jobs/{job_id}` - Get job details
|
||||
- `GET /v1/jobs` - List jobs
|
||||
- `DELETE /v1/jobs/{job_id}` - Cancel job
|
||||
- `GET /v1/jobs/{job_id}/results` - Get job results
|
||||
|
||||
### Marketplace
|
||||
- `POST /v1/marketplace/offers` - Create offer
|
||||
- `GET /v1/marketplace/offers` - List offers
|
||||
- `POST /v1/marketplace/offers/{offer_id}/accept` - Accept offer
|
||||
|
||||
### Receipts
|
||||
- `GET /v1/receipts/{job_id}` - Get receipt
|
||||
- `POST /v1/receipts/verify` - Verify receipt
|
||||
|
||||
### Analytics
|
||||
- `GET /v1/marketplace/stats` - Get marketplace statistics
|
||||
- `GET /v1/miners/{miner_id}/stats` - Get miner statistics
|
||||
|
||||
## Authentication
|
||||
|
||||
All endpoints require authentication via the `X-API-Key` header.
|
||||
|
||||
## Rate Limits
|
||||
|
||||
API requests are rate-limited based on your subscription plan.
|
||||
|
||||
## WebSocket API
|
||||
|
||||
Real-time updates available at:
|
||||
- WebSocket: `wss://api.aitbc.io/ws`
|
||||
- Message types: job_update, marketplace_update, receipt_created
|
||||
|
||||
## Code Generation
|
||||
|
||||
Use the OpenAPI spec to generate client libraries:
|
||||
|
||||
```bash
|
||||
# OpenAPI Generator
|
||||
openapi-generator-cli generate -i openapi.json -g python -o ./client/
|
||||
|
||||
# Or use the online generator at https://openapi-generator.tech/
|
||||
```
|
||||
|
||||
## SDK Integration
|
||||
|
||||
The OpenAPI spec is integrated into our official SDKs:
|
||||
- [Python SDK](../../developer-guide/sdks/python.md)
|
||||
- [JavaScript SDK](../../developer-guide/sdks/javascript.md)
|
||||
|
||||
## Support
|
||||
|
||||
For API support:
|
||||
- 📖 [API Documentation](endpoints.md)
|
||||
- 🐛 [Report Issues](https://github.com/aitbc/issues)
|
||||
- 💬 [Discord](https://discord.gg/aitbc)
|
||||
- 📧 [api-support@aitbc.io](mailto:api-support@aitbc.io)
|
||||
140
docs/developer/api/api/coordinator/overview.md
Normal file
140
docs/developer/api/api/coordinator/overview.md
Normal file
@@ -0,0 +1,140 @@
|
||||
---
|
||||
title: Coordinator API Overview
|
||||
description: Introduction to the AITBC Coordinator API
|
||||
---
|
||||
|
||||
# Coordinator API Overview
|
||||
|
||||
The Coordinator API is the central service of the AITBC platform, responsible for job management, marketplace operations, and coordination between various components.
|
||||
|
||||
## Base URL
|
||||
|
||||
```
|
||||
Production: https://api.aitbc.io
|
||||
Staging: https://staging-api.aitbc.io
|
||||
Development: http://localhost:8011
|
||||
```
|
||||
|
||||
## Authentication
|
||||
|
||||
All API endpoints require authentication using an API key. Include the API key in the request header:
|
||||
|
||||
```http
|
||||
X-API-Key: your_api_key_here
|
||||
```
|
||||
|
||||
Get your API key from the [AITBC Dashboard](https://dashboard.aitbc.io).
|
||||
|
||||
## Core Concepts
|
||||
|
||||
### Jobs
|
||||
Jobs are the primary unit of work in AITBC. They represent AI computations that need to be executed.
|
||||
|
||||
```json
|
||||
{
|
||||
"job_id": "job_1234567890",
|
||||
"type": "ai-inference",
|
||||
"status": "running",
|
||||
"created_at": "2024-01-01T12:00:00Z",
|
||||
"estimated_completion": "2024-01-01T12:05:00Z"
|
||||
}
|
||||
```
|
||||
|
||||
### Marketplace
|
||||
The marketplace connects job creators with miners who can execute the jobs.
|
||||
|
||||
```json
|
||||
{
|
||||
"offer_id": "offer_1234567890",
|
||||
"job_type": "image-classification",
|
||||
"price": "0.001",
|
||||
"miner_id": "miner_1234567890"
|
||||
}
|
||||
```
|
||||
|
||||
### Receipts
|
||||
Receipts provide cryptographic proof of job execution and results.
|
||||
|
||||
```json
|
||||
{
|
||||
"receipt_id": "receipt_1234567890",
|
||||
"job_id": "job_1234567890",
|
||||
"signature": {
|
||||
"sig": "base64_signature",
|
||||
"public_key": "base64_public_key"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Rate Limits
|
||||
|
||||
API requests are rate-limited to ensure fair usage:
|
||||
|
||||
| Plan | Requests per minute | Burst |
|
||||
|------|---------------------|-------|
|
||||
| Free | 60 | 10 |
|
||||
| Pro | 600 | 100 |
|
||||
| Enterprise | 6000 | 1000 |
|
||||
|
||||
## Error Handling
|
||||
|
||||
The API uses standard HTTP status codes and returns detailed error messages:
|
||||
|
||||
```json
|
||||
{
|
||||
"error": {
|
||||
"code": "INVALID_API_KEY",
|
||||
"message": "The provided API key is invalid",
|
||||
"details": {
|
||||
"request_id": "req_1234567890"
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Common error codes:
|
||||
- `400 Bad Request` - Invalid request parameters
|
||||
- `401 Unauthorized` - Invalid or missing API key
|
||||
- `403 Forbidden` - Insufficient permissions
|
||||
- `404 Not Found` - Resource not found
|
||||
- `429 Too Many Requests` - Rate limit exceeded
|
||||
- `500 Internal Server Error` - Server error
|
||||
|
||||
## SDK Support
|
||||
|
||||
Official SDKs are available for:
|
||||
- [Python](../../developer-guide/sdks/python.md)
|
||||
- [JavaScript/TypeScript](../../developer-guide/sdks/javascript.md)
|
||||
|
||||
## WebSocket API
|
||||
|
||||
Real-time updates are available through WebSocket connections:
|
||||
|
||||
```javascript
|
||||
const ws = new WebSocket('wss://api.aitbc.io/ws');
|
||||
|
||||
ws.onmessage = (event) => {
|
||||
const data = JSON.parse(event.data);
|
||||
console.log('Job update:', data);
|
||||
};
|
||||
```
|
||||
|
||||
## OpenAPI Specification
|
||||
|
||||
The complete OpenAPI 3.0 specification is available:
|
||||
- [View in Swagger UI](https://api.aitbc.io/docs)
|
||||
- [Download JSON](openapi.md)
|
||||
|
||||
## Getting Started
|
||||
|
||||
1. [Get an API key](https://dashboard.aitbc.io/api-keys)
|
||||
2. [Review authentication](authentication.md)
|
||||
3. [Explore endpoints](endpoints.md)
|
||||
4. [Check examples](../../developer-guide/examples.md)
|
||||
|
||||
## Support
|
||||
|
||||
- 📖 [Documentation](../../)
|
||||
- 💬 [Discord](https://discord.gg/aitbc)
|
||||
- 🐛 [Report Issues](https://github.com/aitbc/issues)
|
||||
- 📧 [api-support@aitbc.io](mailto:api-support@aitbc.io)
|
||||
99
docs/developer/contributing.md
Normal file
99
docs/developer/contributing.md
Normal file
@@ -0,0 +1,99 @@
|
||||
---
|
||||
title: Contributing
|
||||
description: How to contribute to the AITBC project
|
||||
---
|
||||
|
||||
# Contributing to AITBC
|
||||
|
||||
We welcome contributions from the community! This guide will help you get started.
|
||||
|
||||
## Ways to Contribute
|
||||
|
||||
### Code Contributions
|
||||
- Fix bugs
|
||||
- Add features
|
||||
- Improve performance
|
||||
- Write tests
|
||||
|
||||
### Documentation
|
||||
- Improve docs
|
||||
- Add examples
|
||||
- Translate content
|
||||
- Fix typos
|
||||
|
||||
### Community
|
||||
- Answer questions
|
||||
- Report issues
|
||||
- Share feedback
|
||||
- Organize events
|
||||
|
||||
## Getting Started
|
||||
|
||||
### 1. Fork Repository
|
||||
```bash
|
||||
git clone https://github.com/your-username/aitbc.git
|
||||
cd aitbc
|
||||
```
|
||||
|
||||
### 2. Setup Development Environment
|
||||
```bash
|
||||
# Install dependencies
|
||||
pip install -r requirements-dev.txt
|
||||
|
||||
# Run tests
|
||||
pytest
|
||||
|
||||
# Start development server
|
||||
aitbc dev start
|
||||
```
|
||||
|
||||
### 3. Create Branch
|
||||
```bash
|
||||
git checkout -b feature/your-feature-name
|
||||
```
|
||||
|
||||
## Development Workflow
|
||||
|
||||
### Code Style
|
||||
- Follow PEP 8 for Python
|
||||
- Use ESLint for JavaScript
|
||||
- Write clear commit messages
|
||||
- Add tests for new features
|
||||
|
||||
### Testing
|
||||
```bash
|
||||
# Run all tests
|
||||
pytest
|
||||
|
||||
# Run specific test
|
||||
pytest tests/test_jobs.py
|
||||
|
||||
# Check coverage
|
||||
pytest --cov=aitbc
|
||||
```
|
||||
|
||||
### Submitting Changes
|
||||
1. Push to your fork
|
||||
2. Create pull request
|
||||
3. Wait for review
|
||||
4. Address feedback
|
||||
5. Merge!
|
||||
|
||||
## Reporting Issues
|
||||
|
||||
- Use GitHub Issues
|
||||
- Provide clear description
|
||||
- Include reproduction steps
|
||||
- Add relevant logs
|
||||
|
||||
## Code of Conduct
|
||||
|
||||
Please read and follow our [Code of Conduct](https://github.com/aitbc/blob/main/CODE_OF_CONDUCT.md).
|
||||
|
||||
## Getting Help
|
||||
|
||||
- Discord: https://discord.gg/aitbc
|
||||
- Email: dev@aitbc.io
|
||||
- Documentation: https://docs.aitbc.io
|
||||
|
||||
Thank you for contributing! 🎉
|
||||
131
docs/developer/examples.md
Normal file
131
docs/developer/examples.md
Normal file
@@ -0,0 +1,131 @@
|
||||
---
|
||||
title: Code Examples
|
||||
description: Practical examples for building on AITBC
|
||||
---
|
||||
|
||||
# Code Examples
|
||||
|
||||
This section provides practical examples for common tasks on the AITBC platform.
|
||||
|
||||
## Python Examples
|
||||
|
||||
### Basic Job Submission
|
||||
```python
|
||||
from aitbc import AITBCClient
|
||||
|
||||
client = AITBCClient(api_key="your_key")
|
||||
|
||||
job = client.jobs.create({
|
||||
"name": "image-classification",
|
||||
"type": "ai-inference",
|
||||
"model": {
|
||||
"type": "python",
|
||||
"entrypoint": "model.py",
|
||||
"requirements": ["torch", "pillow"]
|
||||
}
|
||||
})
|
||||
|
||||
result = client.jobs.wait_for_completion(job["job_id"])
|
||||
```
|
||||
|
||||
### Batch Job Processing
|
||||
```python
|
||||
import asyncio
|
||||
from aitbc import AsyncAITBCClient
|
||||
|
||||
async def process_images(image_paths):
|
||||
client = AsyncAITBCClient(api_key="your_key")
|
||||
|
||||
tasks = []
|
||||
for path in image_paths:
|
||||
job = await client.jobs.create({
|
||||
"name": f"process-{path}",
|
||||
"type": "image-analysis"
|
||||
})
|
||||
tasks.append(client.jobs.wait_for_completion(job["job_id"]))
|
||||
|
||||
results = await asyncio.gather(*tasks)
|
||||
return results
|
||||
```
|
||||
|
||||
## JavaScript Examples
|
||||
|
||||
### React Component
|
||||
```jsx
|
||||
import React, { useState, useEffect } from 'react';
|
||||
import { AITBCClient } from '@aitbc/client';
|
||||
|
||||
function JobList() {
|
||||
const [jobs, setJobs] = useState([]);
|
||||
const client = new AITBCClient({ apiKey: 'your_key' });
|
||||
|
||||
useEffect(() => {
|
||||
async function fetchJobs() {
|
||||
const jobList = await client.jobs.list();
|
||||
setJobs(jobList);
|
||||
}
|
||||
fetchJobs();
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<div>
|
||||
{jobs.map(job => (
|
||||
<div key={job.jobId}>
|
||||
<h3>{job.name}</h3>
|
||||
<p>Status: {job.status}</p>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
```
|
||||
|
||||
### WebSocket Integration
|
||||
```javascript
|
||||
const client = new AITBCClient({ apiKey: 'your_key' });
|
||||
const ws = client.websocket.connect();
|
||||
|
||||
ws.on('jobUpdate', (data) => {
|
||||
console.log(`Job ${data.jobId} updated to ${data.status}`);
|
||||
});
|
||||
|
||||
ws.subscribe('jobs');
|
||||
ws.start();
|
||||
```
|
||||
|
||||
## CLI Examples
|
||||
|
||||
### Job Management
|
||||
```bash
|
||||
# Create job from file
|
||||
aitbc job create job.yaml
|
||||
|
||||
# List all jobs
|
||||
aitbc job list --status running
|
||||
|
||||
# Monitor job progress
|
||||
aitbc job watch <job_id>
|
||||
|
||||
# Download results
|
||||
aitbc job download <job_id> --output ./results/
|
||||
```
|
||||
|
||||
### Marketplace Operations
|
||||
```bash
|
||||
# List available offers
|
||||
aitbc marketplace list --type image-classification
|
||||
|
||||
# Create offer as miner
|
||||
aitbc marketplace create-offer offer.yaml
|
||||
|
||||
# Accept offer
|
||||
aitbc marketplace accept <offer_id> --job-id <job_id>
|
||||
```
|
||||
|
||||
## Complete Examples
|
||||
|
||||
Find full working examples in our GitHub repositories:
|
||||
- [Python SDK Examples](https://github.com/aitbc/python-sdk/tree/main/examples)
|
||||
- [JavaScript SDK Examples](https://github.com/aitbc/js-sdk/tree/main/examples)
|
||||
- [CLI Examples](https://github.com/aitbc/cli/tree/main/examples)
|
||||
- [Smart Contract Examples](https://github.com/aitbc/contracts/tree/main/examples)
|
||||
46
docs/developer/index.md
Normal file
46
docs/developer/index.md
Normal file
@@ -0,0 +1,46 @@
|
||||
# AITBC Developer Documentation
|
||||
|
||||
Welcome to the AITBC developer documentation. This section contains resources for building on AITBC.
|
||||
|
||||
## Getting Started
|
||||
|
||||
- [Overview](overview.md) - Developer platform overview
|
||||
- [Setup](setup.md) - Development environment setup
|
||||
- [Contributing](contributing.md) - How to contribute to AITBC
|
||||
|
||||
## API Documentation
|
||||
|
||||
- [API Overview](api/overview.md) - REST API introduction
|
||||
- [Authentication](api/authentication.md) - API authentication guide
|
||||
- [Endpoints](api/endpoints.md) - Available API endpoints
|
||||
- [OpenAPI Spec](api/openapi.md) - OpenAPI specification
|
||||
|
||||
## SDKs
|
||||
|
||||
- [Python SDK](sdks/python.md) - Python SDK documentation
|
||||
- [JavaScript SDK](sdks/javascript.md) - JavaScript SDK documentation
|
||||
|
||||
## Tutorials & Examples
|
||||
|
||||
- [Examples](examples.md) - Code examples and tutorials
|
||||
- [API Authentication](api-authentication.md) - Authentication examples
|
||||
|
||||
## Architecture
|
||||
|
||||
- [Architecture Guide](../reference/architecture/) - System architecture documentation
|
||||
- [Design Patterns](../reference/architecture/) - Common patterns and best practices
|
||||
|
||||
## Testing
|
||||
|
||||
- [Testing Guide](testing.md) - How to test your AITBC applications
|
||||
- [Test Examples](../examples/) - Test code examples
|
||||
|
||||
## Deployment
|
||||
|
||||
- [Deployment Guide](../operator/deployment/) - How to deploy AITBC applications
|
||||
- [CI/CD](../operator/deployment/) - Continuous integration and deployment
|
||||
|
||||
## Reference
|
||||
|
||||
- [Glossary](../reference/glossary.md) - Terms and definitions
|
||||
- [FAQ](../user-guide/faq.md) - Frequently asked questions
|
||||
269
docs/developer/overview.md
Normal file
269
docs/developer/overview.md
Normal file
@@ -0,0 +1,269 @@
|
||||
---
|
||||
title: Developer Overview
|
||||
description: Introduction to developing on the AITBC platform
|
||||
---
|
||||
|
||||
# Developer Overview
|
||||
|
||||
Welcome to the AITBC developer documentation! This guide will help you understand how to build applications and services on the AITBC blockchain platform.
|
||||
|
||||
## What You Can Build on AITBC
|
||||
|
||||
### AI/ML Applications
|
||||
- **Inference Services**: Deploy and monetize AI models
|
||||
- **Training Services**: Offer distributed model training
|
||||
- **Data Processing**: Build data pipelines with verifiable computation
|
||||
|
||||
### DeFi Applications
|
||||
- **Prediction Markets**: Create markets for AI predictions
|
||||
- **Computational Derivatives**: Financial products based on AI outcomes
|
||||
- **Staking Pools**: Earn rewards by providing compute resources
|
||||
|
||||
### NFT & Gaming
|
||||
- **Generative Art**: Create AI-powered NFT generators
|
||||
- **Dynamic NFTs**: NFTs that evolve based on AI computations
|
||||
- **AI Gaming**: Games with AI-driven mechanics
|
||||
|
||||
### Infrastructure Tools
|
||||
- **Oracles**: Bridge real-world data to blockchain
|
||||
- **Monitoring Tools**: Track network performance
|
||||
- **Development Tools**: SDKs, frameworks, and utilities
|
||||
|
||||
## Architecture Overview
|
||||
|
||||
```mermaid
|
||||
graph TB
|
||||
subgraph "Developer Tools"
|
||||
A[Python SDK] --> E[Coordinator API]
|
||||
B[JS SDK] --> E
|
||||
C[CLI Tools] --> E
|
||||
D[Smart Contracts] --> F[Blockchain]
|
||||
end
|
||||
|
||||
subgraph "AITBC Platform"
|
||||
E --> G[Marketplace]
|
||||
F --> H[Miners/Validators]
|
||||
G --> I[Job Execution]
|
||||
end
|
||||
|
||||
subgraph "External Services"
|
||||
J[AI Models] --> I
|
||||
K[Storage] --> I
|
||||
L[Oracles] --> F
|
||||
end
|
||||
```
|
||||
|
||||
## Key Concepts
|
||||
|
||||
### Jobs
|
||||
Jobs are the fundamental unit of computation on AITBC. They represent AI tasks that need to be executed by miners.
|
||||
|
||||
### Smart Contracts
|
||||
AITBC uses smart contracts for:
|
||||
- Marketplace operations
|
||||
- Payment processing
|
||||
- Dispute resolution
|
||||
- Governance
|
||||
|
||||
### Proofs & Receipts
|
||||
All computations generate cryptographic proofs:
|
||||
- **Execution Proofs**: Verify correct computation
|
||||
- **Receipts**: Proof of job completion
|
||||
- **Attestations**: Multiple validator signatures
|
||||
|
||||
### Tokens & Economics
|
||||
- **AITBC Token**: Native utility token
|
||||
- **Job Payments**: Pay for computation
|
||||
- **Staking**: Secure the network
|
||||
- **Rewards**: Earn for providing services
|
||||
|
||||
## Development Stack
|
||||
|
||||
### Core Technologies
|
||||
- **Blockchain**: Custom PoS consensus
|
||||
- **Smart Contracts**: Solidity-compatible
|
||||
- **APIs**: RESTful with OpenAPI specs
|
||||
- **WebSockets**: Real-time updates
|
||||
|
||||
### Languages & Frameworks
|
||||
- **Python**: Primary SDK and ML support
|
||||
- **JavaScript/TypeScript**: Web and Node.js support
|
||||
- **Rust**: High-performance components
|
||||
- **Go**: Infrastructure services
|
||||
|
||||
### Tools & Libraries
|
||||
- **Docker**: Containerization
|
||||
- **Kubernetes**: Orchestration
|
||||
- **Prometheus**: Monitoring
|
||||
- **Grafana**: Visualization
|
||||
|
||||
## Getting Started
|
||||
|
||||
### 1. Set Up Development Environment
|
||||
|
||||
```bash
|
||||
# Install AITBC CLI
|
||||
pip install aitbc-cli
|
||||
|
||||
# Initialize project
|
||||
aitbc init my-project
|
||||
cd my-project
|
||||
|
||||
# Start local development
|
||||
aitbc dev start
|
||||
```
|
||||
|
||||
### 2. Choose Your Path
|
||||
|
||||
#### AI/ML Developer
|
||||
- Focus on model integration
|
||||
- Learn about job specifications
|
||||
- Understand proof generation
|
||||
|
||||
#### DApp Developer
|
||||
- Study smart contract patterns
|
||||
- Master the SDKs
|
||||
- Build user interfaces
|
||||
|
||||
#### Infrastructure Developer
|
||||
- Run a node or miner
|
||||
- Build tools and utilities
|
||||
- Contribute to core protocol
|
||||
|
||||
### 3. Build Your First Application
|
||||
|
||||
Choose a tutorial based on your interest:
|
||||
|
||||
- [AI Inference Service](../../tutorials/building-dapp.md)
|
||||
- [Marketplace Bot](../../tutorials/integration-examples.md)
|
||||
- [Mining Operation](../../tutorials/mining-setup.md)
|
||||
|
||||
## Developer Resources
|
||||
|
||||
### Documentation
|
||||
- [API Reference](../api/)
|
||||
- [SDK Guides](sdks/)
|
||||
- [Examples](examples.md)
|
||||
- [Best Practices](best-practices.md)
|
||||
|
||||
### Tools
|
||||
- [AITBC CLI](tools/cli.md)
|
||||
- [IDE Plugins](tools/ide-plugins.md)
|
||||
- [Testing Framework](tools/testing.md)
|
||||
|
||||
### Community
|
||||
- [Discord](https://discord.gg/aitbc)
|
||||
- [GitHub Discussions](https://github.com/aitbc/discussions)
|
||||
- [Stack Overflow](https://stackoverflow.com/questions/tagged/aitbc)
|
||||
|
||||
## Development Workflow
|
||||
|
||||
### 1. Local Development
|
||||
```bash
|
||||
# Start local testnet
|
||||
aitbc dev start
|
||||
|
||||
# Run tests
|
||||
aitbc test
|
||||
|
||||
# Deploy locally
|
||||
aitbc deploy --local
|
||||
```
|
||||
|
||||
### 2. Testnet Deployment
|
||||
```bash
|
||||
# Configure for testnet
|
||||
aitbc config set network testnet
|
||||
|
||||
# Deploy to testnet
|
||||
aitbc deploy --testnet
|
||||
|
||||
# Verify deployment
|
||||
aitbc status
|
||||
```
|
||||
|
||||
### 3. Production Deployment
|
||||
```bash
|
||||
# Configure for mainnet
|
||||
aitbc config set network mainnet
|
||||
|
||||
# Deploy to production
|
||||
aitbc deploy --mainnet
|
||||
|
||||
# Monitor deployment
|
||||
aitbc monitor
|
||||
```
|
||||
|
||||
## Security Considerations
|
||||
|
||||
### Smart Contract Security
|
||||
- Follow established patterns
|
||||
- Use audited libraries
|
||||
- Test thoroughly
|
||||
- Consider formal verification
|
||||
|
||||
### API Security
|
||||
- Use API keys properly
|
||||
- Implement rate limiting
|
||||
- Validate inputs
|
||||
- Use HTTPS everywhere
|
||||
|
||||
### Key Management
|
||||
- Never commit private keys
|
||||
- Use hardware wallets
|
||||
- Implement multi-sig
|
||||
- Regular key rotation
|
||||
|
||||
## Performance Optimization
|
||||
|
||||
### Job Optimization
|
||||
- Minimize computation overhead
|
||||
- Use efficient data formats
|
||||
- Batch operations when possible
|
||||
- Profile and benchmark
|
||||
|
||||
### Cost Optimization
|
||||
- Optimize resource usage
|
||||
- Use spot instances when possible
|
||||
- Implement caching
|
||||
- Monitor spending
|
||||
|
||||
## Contributing to AITBC
|
||||
|
||||
We welcome contributions! Areas where you can help:
|
||||
|
||||
### Core Protocol
|
||||
- Consensus improvements
|
||||
- New cryptographic primitives
|
||||
- Performance optimizations
|
||||
- Bug fixes
|
||||
|
||||
### Developer Tools
|
||||
- SDK improvements
|
||||
- New language support
|
||||
- Better documentation
|
||||
- Tooling enhancements
|
||||
|
||||
### Ecosystem
|
||||
- Sample applications
|
||||
- Tutorials and guides
|
||||
- Community support
|
||||
- Integration examples
|
||||
|
||||
See our [Contributing Guide](contributing.md) for details.
|
||||
|
||||
## Support
|
||||
|
||||
- 📖 [Documentation](../)
|
||||
- 💬 [Discord](https://discord.gg/aitbc)
|
||||
- 🐛 [Issue Tracker](https://github.com/aitbc/issues)
|
||||
- 📧 [dev-support@aitbc.io](mailto:dev-support@aitbc.io)
|
||||
|
||||
## Next Steps
|
||||
|
||||
1. [Set up your environment](setup.md)
|
||||
2. [Learn about authentication](api-authentication.md)
|
||||
3. [Choose an SDK](sdks/)
|
||||
4. [Build your first app](../../tutorials/)
|
||||
|
||||
Happy building! 🚀
|
||||
279
docs/developer/sdks/javascript.md
Normal file
279
docs/developer/sdks/javascript.md
Normal file
@@ -0,0 +1,279 @@
|
||||
---
|
||||
title: JavaScript SDK
|
||||
description: JavaScript/TypeScript SDK for AITBC platform integration
|
||||
---
|
||||
|
||||
# JavaScript SDK
|
||||
|
||||
The AITBC JavaScript SDK provides a convenient way to interact with the AITBC platform from JavaScript and TypeScript applications.
|
||||
|
||||
## Installation
|
||||
|
||||
```bash
|
||||
# npm
|
||||
npm install @aitbc/client
|
||||
|
||||
# yarn
|
||||
yarn add @aitbc/client
|
||||
|
||||
# pnpm
|
||||
pnpm add @aitbc/client
|
||||
```
|
||||
|
||||
## Quick Start
|
||||
|
||||
```javascript
|
||||
import { AITBCClient } from '@aitbc/client';
|
||||
|
||||
// Initialize the client
|
||||
const client = new AITBCClient({
|
||||
apiKey: 'your_api_key_here',
|
||||
baseUrl: 'https://api.aitbc.io'
|
||||
});
|
||||
|
||||
// Create a job
|
||||
const job = await client.jobs.create({
|
||||
name: 'image-classification',
|
||||
type: 'ai-inference',
|
||||
model: {
|
||||
type: 'python',
|
||||
entrypoint: 'model.js'
|
||||
}
|
||||
});
|
||||
|
||||
console.log('Job created:', job.jobId);
|
||||
```
|
||||
|
||||
## Configuration
|
||||
|
||||
### Environment Variables
|
||||
```bash
|
||||
AITBC_API_KEY=your_api_key
|
||||
AITBC_BASE_URL=https://api.aitbc.io
|
||||
AITBC_NETWORK=mainnet
|
||||
```
|
||||
|
||||
### Code Configuration
|
||||
```javascript
|
||||
const client = new AITBCClient({
|
||||
apiKey: process.env.AITBC_API_KEY,
|
||||
baseUrl: process.env.AITBC_BASE_URL,
|
||||
timeout: 30000,
|
||||
retries: 3
|
||||
});
|
||||
```
|
||||
|
||||
## Jobs API
|
||||
|
||||
### Create a Job
|
||||
```javascript
|
||||
const job = await client.jobs.create({
|
||||
name: 'my-ai-job',
|
||||
type: 'ai-inference',
|
||||
model: {
|
||||
type: 'javascript',
|
||||
entrypoint: 'model.js',
|
||||
dependencies: ['@tensorflow/tfjs']
|
||||
},
|
||||
input: {
|
||||
type: 'image',
|
||||
format: 'jpeg'
|
||||
},
|
||||
output: {
|
||||
type: 'json'
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
### Monitor Job Progress
|
||||
```javascript
|
||||
// Get job status
|
||||
const status = await client.jobs.getStatus(job.jobId);
|
||||
console.log('Status:', status.status);
|
||||
|
||||
// Stream updates
|
||||
client.jobs.onUpdate(job.jobId, (update) => {
|
||||
console.log('Update:', update);
|
||||
});
|
||||
|
||||
// Wait for completion
|
||||
const result = await client.jobs.waitForCompletion(job.jobId, {
|
||||
timeout: 300000,
|
||||
pollInterval: 5000
|
||||
});
|
||||
```
|
||||
|
||||
## Marketplace API
|
||||
|
||||
### List Offers
|
||||
```javascript
|
||||
const offers = await client.marketplace.listOffers({
|
||||
jobType: 'image-classification',
|
||||
maxPrice: '0.01'
|
||||
});
|
||||
|
||||
offers.forEach(offer => {
|
||||
console.log(`Offer: ${offer.offerId}, Price: ${offer.price}`);
|
||||
});
|
||||
```
|
||||
|
||||
### Accept Offer
|
||||
```javascript
|
||||
const transaction = await client.marketplace.acceptOffer({
|
||||
offerId: 'offer_123',
|
||||
jobId: 'job_456',
|
||||
bidPrice: '0.001'
|
||||
});
|
||||
```
|
||||
|
||||
## Wallet API
|
||||
|
||||
### Wallet Operations
|
||||
```javascript
|
||||
// Get balance
|
||||
const balance = await client.wallet.getBalance();
|
||||
console.log('Balance:', balance);
|
||||
|
||||
// Send tokens
|
||||
const tx = await client.wallet.send({
|
||||
to: '0x123...',
|
||||
amount: '1.0',
|
||||
token: 'AITBC'
|
||||
});
|
||||
|
||||
// Stake tokens
|
||||
await client.wallet.stake({
|
||||
amount: '100.0'
|
||||
});
|
||||
```
|
||||
|
||||
## WebSocket API
|
||||
|
||||
### Real-time Updates
|
||||
```javascript
|
||||
// Connect to WebSocket
|
||||
const ws = client.websocket.connect();
|
||||
|
||||
// Subscribe to events
|
||||
ws.subscribe('jobs', { jobId: 'job_123' });
|
||||
ws.subscribe('marketplace');
|
||||
|
||||
// Handle events
|
||||
ws.on('jobUpdate', (data) => {
|
||||
console.log('Job updated:', data);
|
||||
});
|
||||
|
||||
ws.on('marketplaceUpdate', (data) => {
|
||||
console.log('Marketplace updated:', data);
|
||||
});
|
||||
|
||||
// Start listening
|
||||
ws.start();
|
||||
```
|
||||
|
||||
## TypeScript Support
|
||||
|
||||
The SDK is fully typed for TypeScript:
|
||||
|
||||
```typescript
|
||||
import { AITBCClient, Job, JobStatus } from '@aitbc/client';
|
||||
|
||||
const client: AITBCClient = new AITBCClient({
|
||||
apiKey: 'your_key'
|
||||
});
|
||||
|
||||
const job: Job = await client.jobs.create({
|
||||
name: 'typed-job',
|
||||
type: 'ai-inference'
|
||||
});
|
||||
|
||||
const status: JobStatus = await client.jobs.getStatus(job.jobId);
|
||||
```
|
||||
|
||||
## Error Handling
|
||||
|
||||
```javascript
|
||||
import {
|
||||
AITBCError,
|
||||
APIError,
|
||||
AuthenticationError,
|
||||
NotFoundError,
|
||||
RateLimitError
|
||||
} from '@aitbc/client';
|
||||
|
||||
try {
|
||||
const job = await client.jobs.create({});
|
||||
} catch (error) {
|
||||
if (error instanceof AuthenticationError) {
|
||||
console.error('Invalid API key');
|
||||
} else if (error instanceof RateLimitError) {
|
||||
console.error(`Rate limited. Retry in ${error.retryAfter}ms`);
|
||||
} else if (error instanceof APIError) {
|
||||
console.error(`API error: ${error.message}`);
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## React Integration
|
||||
|
||||
```jsx
|
||||
import React, { useState, useEffect } from 'react';
|
||||
import { AITBCClient } from '@aitbc/client';
|
||||
|
||||
function JobComponent() {
|
||||
const [jobs, setJobs] = useState([]);
|
||||
const client = new AITBCClient({ apiKey: 'your_key' });
|
||||
|
||||
useEffect(() => {
|
||||
async function fetchJobs() {
|
||||
const jobList = await client.jobs.list();
|
||||
setJobs(jobList);
|
||||
}
|
||||
fetchJobs();
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<div>
|
||||
{jobs.map(job => (
|
||||
<div key={job.jobId}>{job.name}</div>
|
||||
))}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
```
|
||||
|
||||
## Node.js Integration
|
||||
|
||||
```javascript
|
||||
const express = require('express');
|
||||
const { AITBCClient } = require('@aitbc/client');
|
||||
|
||||
const app = express();
|
||||
const client = new AITBCClient({ apiKey: process.env.API_KEY });
|
||||
|
||||
app.post('/jobs', async (req, res) => {
|
||||
try {
|
||||
const job = await client.jobs.create(req.body);
|
||||
res.json(job);
|
||||
} catch (error) {
|
||||
res.status(500).json({ error: error.message });
|
||||
}
|
||||
});
|
||||
|
||||
app.listen(3000);
|
||||
```
|
||||
|
||||
## Examples
|
||||
|
||||
Check out the [examples directory](https://github.com/aitbc/js-sdk/tree/main/examples) for complete working examples:
|
||||
|
||||
- [Basic Job Submission](https://github.com/aitbc/js-sdk/blob/main/examples/basic-job.js)
|
||||
- [React Integration](https://github.com/aitbc/js-sdk/blob/main/examples/react-app/)
|
||||
- [WebSocket Streaming](https://github.com/aitbc/js-sdk/blob/main/examples/websocket.js)
|
||||
|
||||
## Support
|
||||
|
||||
- 📖 [Documentation](../../)
|
||||
- 🐛 [Issue Tracker](https://github.com/aitbc/js-sdk/issues)
|
||||
- 💬 [Discord](https://discord.gg/aitbc)
|
||||
- 📧 [js-sdk@aitbc.io](mailto:js-sdk@aitbc.io)
|
||||
494
docs/developer/sdks/python.md
Normal file
494
docs/developer/sdks/python.md
Normal file
@@ -0,0 +1,494 @@
|
||||
---
|
||||
title: Python SDK
|
||||
description: Python SDK for AITBC platform integration
|
||||
---
|
||||
|
||||
# Python SDK
|
||||
|
||||
The AITBC Python SDK provides a convenient way to interact with the AITBC platform from Python applications. It includes support for job management, marketplace operations, wallet management, and more.
|
||||
|
||||
## Installation
|
||||
|
||||
```bash
|
||||
# Install from PyPI
|
||||
pip install aitbc
|
||||
|
||||
# Or install from source
|
||||
git clone https://github.com/aitbc/python-sdk.git
|
||||
cd python-sdk
|
||||
pip install -e .
|
||||
```
|
||||
|
||||
## Quick Start
|
||||
|
||||
```python
|
||||
from aitbc import AITBCClient
|
||||
|
||||
# Initialize the client
|
||||
client = AITBCClient(
|
||||
api_key="your_api_key_here",
|
||||
base_url="https://api.aitbc.io" # or http://localhost:8011 for dev
|
||||
)
|
||||
|
||||
# Create a job
|
||||
job = client.jobs.create({
|
||||
"name": "image-classification",
|
||||
"type": "ai-inference",
|
||||
"model": {
|
||||
"type": "python",
|
||||
"entrypoint": "model.py"
|
||||
}
|
||||
})
|
||||
|
||||
# Wait for completion
|
||||
result = client.jobs.wait_for_completion(job["job_id"])
|
||||
print(f"Result: {result}")
|
||||
```
|
||||
|
||||
## Configuration
|
||||
|
||||
### Environment Variables
|
||||
```bash
|
||||
export AITBC_API_KEY="your_api_key"
|
||||
export AITBC_BASE_URL="https://api.aitbc.io"
|
||||
export AITBC_NETWORK="mainnet" # or testnet
|
||||
```
|
||||
|
||||
### Code Configuration
|
||||
```python
|
||||
from aitbc import AITBCClient, Config
|
||||
|
||||
# Using Config object
|
||||
config = Config(
|
||||
api_key="your_api_key",
|
||||
base_url="https://api.aitbc.io",
|
||||
timeout=30,
|
||||
retries=3
|
||||
)
|
||||
|
||||
client = AITBCClient(config=config)
|
||||
```
|
||||
|
||||
## Jobs API
|
||||
|
||||
### Create a Job
|
||||
|
||||
```python
|
||||
# Basic job creation
|
||||
job = client.jobs.create({
|
||||
"name": "my-ai-job",
|
||||
"type": "ai-inference",
|
||||
"model": {
|
||||
"type": "python",
|
||||
"entrypoint": "model.py",
|
||||
"requirements": ["numpy", "torch"]
|
||||
},
|
||||
"input": {
|
||||
"type": "image",
|
||||
"format": "jpeg"
|
||||
},
|
||||
"output": {
|
||||
"type": "json"
|
||||
},
|
||||
"resources": {
|
||||
"cpu": "1000m",
|
||||
"memory": "2Gi"
|
||||
},
|
||||
"pricing": {
|
||||
"max_cost": "0.10"
|
||||
}
|
||||
})
|
||||
|
||||
print(f"Job created: {job['job_id']}")
|
||||
```
|
||||
|
||||
### Upload Job Data
|
||||
|
||||
```python
|
||||
# Upload input files
|
||||
with open("input.jpg", "rb") as f:
|
||||
client.jobs.upload_input(job["job_id"], f, "image.jpg")
|
||||
|
||||
# Or upload multiple files
|
||||
files = [
|
||||
("image1.jpg", open("image1.jpg", "rb")),
|
||||
("image2.jpg", open("image2.jpg", "rb"))
|
||||
]
|
||||
client.jobs.upload_inputs(job["job_id"], files)
|
||||
```
|
||||
|
||||
### Monitor Job Progress
|
||||
|
||||
```python
|
||||
# Get job status
|
||||
status = client.jobs.get_status(job["job_id"])
|
||||
print(f"Status: {status['status']}")
|
||||
|
||||
# Stream updates
|
||||
for update in client.jobs.stream_updates(job["job_id"]):
|
||||
print(f"Update: {update}")
|
||||
|
||||
# Wait for completion with timeout
|
||||
result = client.jobs.wait_for_completion(
|
||||
job["job_id"],
|
||||
timeout=300, # 5 minutes
|
||||
poll_interval=5
|
||||
)
|
||||
```
|
||||
|
||||
### Get Results
|
||||
|
||||
```python
|
||||
# Get job results
|
||||
results = client.jobs.get_results(job["job_id"])
|
||||
print(f"Results: {results}")
|
||||
|
||||
# Download output files
|
||||
client.jobs.download_output(job["job_id"], "output/")
|
||||
client.jobs.download_outputs(job["job_id"], "outputs/") # All files
|
||||
```
|
||||
|
||||
## Marketplace API
|
||||
|
||||
### List Available Offers
|
||||
|
||||
```python
|
||||
# List all offers
|
||||
offers = client.marketplace.list_offers()
|
||||
|
||||
# Filter by job type
|
||||
offers = client.marketplace.list_offers(
|
||||
job_type="image-classification",
|
||||
max_price="0.01"
|
||||
)
|
||||
|
||||
for offer in offers:
|
||||
print(f"Offer: {offer['offer_id']}, Price: {offer['price']}")
|
||||
```
|
||||
|
||||
### Create and Manage Offers
|
||||
|
||||
```python
|
||||
# Create an offer (as a miner)
|
||||
offer = client.marketplace.create_offer({
|
||||
"job_type": "image-classification",
|
||||
"price": "0.001",
|
||||
"max_jobs": 10,
|
||||
"requirements": {
|
||||
"min_gpu_memory": "4Gi"
|
||||
}
|
||||
})
|
||||
|
||||
# Update offer
|
||||
client.marketplace.update_offer(
|
||||
offer["offer_id"],
|
||||
price="0.002"
|
||||
)
|
||||
|
||||
# Cancel offer
|
||||
client.marketplace.cancel_offer(offer["offer_id"])
|
||||
```
|
||||
|
||||
### Accept Offers
|
||||
|
||||
```python
|
||||
# Accept an offer for your job
|
||||
transaction = client.marketplace.accept_offer(
|
||||
offer_id="offer_123",
|
||||
job_id="job_456",
|
||||
bid_price="0.001"
|
||||
)
|
||||
|
||||
print(f"Transaction: {transaction['transaction_id']}")
|
||||
```
|
||||
|
||||
## Wallet API
|
||||
|
||||
### Wallet Management
|
||||
|
||||
```python
|
||||
# Create a new wallet
|
||||
wallet = client.wallet.create()
|
||||
print(f"Address: {wallet['address']}")
|
||||
|
||||
# Import existing wallet
|
||||
wallet = client.wallet.import_private_key("your_private_key")
|
||||
|
||||
# Get wallet info
|
||||
balance = client.wallet.get_balance()
|
||||
address = client.wallet.get_address()
|
||||
```
|
||||
|
||||
### Transactions
|
||||
|
||||
```python
|
||||
# Send tokens
|
||||
tx = client.wallet.send(
|
||||
to="0x123...",
|
||||
amount="1.0",
|
||||
token="AITBC"
|
||||
)
|
||||
|
||||
# Stake tokens
|
||||
client.wallet.stake(amount="100.0")
|
||||
|
||||
# Unstake tokens
|
||||
client.wallet.unstake(amount="50.0")
|
||||
|
||||
# Get transaction history
|
||||
history = client.wallet.get_transactions(limit=50)
|
||||
```
|
||||
|
||||
## Receipts API
|
||||
|
||||
### Verify Receipts
|
||||
|
||||
```python
|
||||
# Get a receipt
|
||||
receipt = client.receipts.get(job_id="job_123")
|
||||
|
||||
# Verify a receipt
|
||||
verification = client.receipts.verify(receipt)
|
||||
print(f"Valid: {verification['valid']}")
|
||||
|
||||
# Verify with local verification
|
||||
from aitbc.crypto import verify_receipt
|
||||
|
||||
is_valid = verify_receipt(receipt)
|
||||
```
|
||||
|
||||
### Stream Receipts
|
||||
|
||||
```python
|
||||
# Stream new receipts
|
||||
for receipt in client.receipts.stream():
|
||||
print(f"New receipt: {receipt['receipt_id']}")
|
||||
```
|
||||
|
||||
## WebSocket API
|
||||
|
||||
### Real-time Updates
|
||||
|
||||
```python
|
||||
# Connect to WebSocket
|
||||
ws = client.websocket.connect()
|
||||
|
||||
# Subscribe to job updates
|
||||
ws.subscribe("jobs", job_id="job_123")
|
||||
|
||||
# Subscribe to marketplace updates
|
||||
ws.subscribe("marketplace")
|
||||
|
||||
# Handle messages
|
||||
@ws.on_message
|
||||
def handle_message(message):
|
||||
print(f"Received: {message}")
|
||||
|
||||
# Start listening
|
||||
ws.listen()
|
||||
```
|
||||
|
||||
### Advanced WebSocket Usage
|
||||
|
||||
```python
|
||||
# Custom event handlers
|
||||
ws = client.websocket.connect()
|
||||
|
||||
@ws.on_job_update
|
||||
def on_job_update(job_id, status):
|
||||
print(f"Job {job_id} status: {status}")
|
||||
|
||||
@ws.on_marketplace_update
|
||||
def on_marketplace_update(update_type, data):
|
||||
print(f"Marketplace {update_type}: {data}")
|
||||
|
||||
# Run with context manager
|
||||
with client.websocket.connect() as ws:
|
||||
ws.subscribe("jobs")
|
||||
ws.listen(timeout=60)
|
||||
```
|
||||
|
||||
## Error Handling
|
||||
|
||||
```python
|
||||
from aitbc.exceptions import (
|
||||
AITBCError,
|
||||
APIError,
|
||||
AuthenticationError,
|
||||
NotFoundError,
|
||||
RateLimitError
|
||||
)
|
||||
|
||||
try:
|
||||
job = client.jobs.create({...})
|
||||
except AuthenticationError:
|
||||
print("Invalid API key")
|
||||
except RateLimitError as e:
|
||||
print(f"Rate limited. Retry in {e.retry_after} seconds")
|
||||
except APIError as e:
|
||||
print(f"API error: {e.message}")
|
||||
except AITBCError as e:
|
||||
print(f"AITBC error: {e}")
|
||||
```
|
||||
|
||||
## Advanced Usage
|
||||
|
||||
### Custom HTTP Client
|
||||
|
||||
```python
|
||||
import requests
|
||||
from aitbc import AITBCClient
|
||||
|
||||
# Use custom session
|
||||
session = requests.Session()
|
||||
session.headers.update({"User-Agent": "MyApp/1.0"})
|
||||
|
||||
client = AITBCClient(
|
||||
api_key="your_key",
|
||||
session=session
|
||||
)
|
||||
```
|
||||
|
||||
### Async Support
|
||||
|
||||
```python
|
||||
import asyncio
|
||||
from aitbc import AsyncAITBCClient
|
||||
|
||||
async def main():
|
||||
client = AsyncAITBCClient(api_key="your_key")
|
||||
|
||||
# Create job
|
||||
job = await client.jobs.create({...})
|
||||
|
||||
# Wait for completion
|
||||
result = await client.jobs.wait_for_completion(job["job_id"])
|
||||
|
||||
print(f"Result: {result}")
|
||||
|
||||
asyncio.run(main())
|
||||
```
|
||||
|
||||
### Batch Operations
|
||||
|
||||
```python
|
||||
# Create multiple jobs
|
||||
jobs = [
|
||||
{"name": f"job-{i}", "type": "ai-inference"}
|
||||
for i in range(10)
|
||||
]
|
||||
|
||||
created_jobs = client.jobs.create_batch(jobs)
|
||||
|
||||
# Get status of multiple jobs
|
||||
statuses = client.jobs.get_status_batch([
|
||||
job["job_id"] for job in created_jobs
|
||||
])
|
||||
```
|
||||
|
||||
## Testing
|
||||
|
||||
### Mock Client for Testing
|
||||
|
||||
```python
|
||||
from aitbc.testing import MockAITBCClient
|
||||
|
||||
# Use mock client for tests
|
||||
client = MockAITBCClient()
|
||||
|
||||
# Configure responses
|
||||
client.jobs.set_response("create", {"job_id": "test_job"})
|
||||
|
||||
# Test your code
|
||||
job = client.jobs.create({...})
|
||||
assert job["job_id"] == "test_job"
|
||||
```
|
||||
|
||||
### Integration Tests
|
||||
|
||||
```python
|
||||
import pytest
|
||||
from aitbc import AITBCClient
|
||||
|
||||
@pytest.fixture
|
||||
def client():
|
||||
return AITBCClient(
|
||||
api_key="test_key",
|
||||
base_url="http://localhost:8011"
|
||||
)
|
||||
|
||||
def test_job_creation(client):
|
||||
job = client.jobs.create({
|
||||
"name": "test-job",
|
||||
"type": "ai-inference"
|
||||
})
|
||||
assert "job_id" in job
|
||||
```
|
||||
|
||||
## Best Practices
|
||||
|
||||
### 1. Configuration Management
|
||||
```python
|
||||
# Use environment variables
|
||||
import os
|
||||
from aitbc import AITBCClient
|
||||
|
||||
client = AITBCClient(
|
||||
api_key=os.getenv("AITBC_API_KEY"),
|
||||
base_url=os.getenv("AITBC_BASE_URL", "https://api.aitbc.io")
|
||||
)
|
||||
```
|
||||
|
||||
### 2. Error Handling
|
||||
```python
|
||||
# Always handle potential errors
|
||||
try:
|
||||
result = client.jobs.get_results(job_id)
|
||||
except NotFoundError:
|
||||
print("Job not found")
|
||||
except APIError as e:
|
||||
print(f"API error: {e}")
|
||||
```
|
||||
|
||||
### 3. Resource Management
|
||||
```python
|
||||
# Use context managers for resources
|
||||
with client.jobs.upload_context(job_id) as ctx:
|
||||
ctx.upload_file("model.py")
|
||||
ctx.upload_file("requirements.txt")
|
||||
```
|
||||
|
||||
### 4. Performance
|
||||
```python
|
||||
# Use async for concurrent operations
|
||||
async def process_jobs(job_ids):
|
||||
client = AsyncAITBCClient(api_key="your_key")
|
||||
|
||||
tasks = [
|
||||
client.jobs.get_results(job_id)
|
||||
for job_id in job_ids
|
||||
]
|
||||
|
||||
results = await asyncio.gather(*tasks)
|
||||
return results
|
||||
```
|
||||
|
||||
## Examples
|
||||
|
||||
Check out the [examples directory](https://github.com/aitbc/python-sdk/tree/main/examples) for complete working examples:
|
||||
|
||||
- [Basic Job Submission](https://github.com/aitbc/python-sdk/blob/main/examples/basic_job.py)
|
||||
- [Marketplace Bot](https://github.com/aitbc/python-sdk/blob/main/examples/marketplace_bot.py)
|
||||
- [Mining Operation](https://github.com/aitbc/python-sdk/blob/main/examples/mining.py)
|
||||
- [WebSocket Streaming](https://github.com/aitbc/python-sdk/blob/main/examples/websocket_streaming.py)
|
||||
|
||||
## Support
|
||||
|
||||
- 📖 [Documentation](../../)
|
||||
- 🐛 [Issue Tracker](https://github.com/aitbc/python-sdk/issues)
|
||||
- 💬 [Discord](https://discord.gg/aitbc)
|
||||
- 📧 [python-sdk@aitbc.io](mailto:python-sdk@aitbc.io)
|
||||
|
||||
## Changelog
|
||||
|
||||
See [CHANGELOG.md](https://github.com/aitbc/python-sdk/blob/main/CHANGELOG.md) for version history and updates.
|
||||
76
docs/developer/setup.md
Normal file
76
docs/developer/setup.md
Normal file
@@ -0,0 +1,76 @@
|
||||
---
|
||||
title: Development Setup
|
||||
description: Set up your development environment for AITBC
|
||||
---
|
||||
|
||||
# Development Setup
|
||||
|
||||
This guide helps you set up a development environment for building on AITBC.
|
||||
|
||||
## Prerequisites
|
||||
|
||||
- Python 3.8+
|
||||
- Git
|
||||
- Docker (optional)
|
||||
- Node.js 16+ (for frontend development)
|
||||
|
||||
## Local Development
|
||||
|
||||
### 1. Clone Repository
|
||||
```bash
|
||||
git clone https://github.com/aitbc/aitbc.git
|
||||
cd aitbc
|
||||
```
|
||||
|
||||
### 2. Install Dependencies
|
||||
```bash
|
||||
# Python dependencies
|
||||
pip install -r requirements.txt
|
||||
|
||||
# Development dependencies
|
||||
pip install -r requirements-dev.txt
|
||||
```
|
||||
|
||||
### 3. Start Services
|
||||
```bash
|
||||
# Using Docker Compose
|
||||
docker-compose -f docker-compose.dev.yml up -d
|
||||
|
||||
# Or start individually
|
||||
aitbc dev start
|
||||
```
|
||||
|
||||
### 4. Verify Setup
|
||||
```bash
|
||||
# Check services
|
||||
aitbc status
|
||||
|
||||
# Run tests
|
||||
pytest
|
||||
```
|
||||
|
||||
## IDE Setup
|
||||
|
||||
### VS Code
|
||||
Install extensions:
|
||||
- Python
|
||||
- Docker
|
||||
- GitLens
|
||||
|
||||
### PyCharm
|
||||
Configure Python interpreter and enable Docker integration.
|
||||
|
||||
## Environment Variables
|
||||
|
||||
Create `.env` file:
|
||||
```bash
|
||||
AITBC_API_KEY=your_dev_key
|
||||
AITBC_BASE_URL=http://localhost:8011
|
||||
AITBC_NETWORK=testnet
|
||||
```
|
||||
|
||||
## Next Steps
|
||||
|
||||
- [API Authentication](api-authentication.md)
|
||||
- [Python SDK](sdks/python.md)
|
||||
- [Examples](examples.md)
|
||||
Reference in New Issue
Block a user