API Reference

Complete reference for the AIToTest REST API

Authentication

API Keys

All API requests require authentication using an API key in the Authorization header:

curl -X POST https://api.aitotest.com/v1/tests \
  -H "Authorization: Bearer your_api_key" \
  -H "Content-Type: application/json" \
  -d '{"projectId": "123"}'

Test Generation

Generate Tests

Create test cases for your code:

POST /v1/tests/generate

{
  "projectId": "string",
  "files": [{
    "path": "string",
    "content": "string"
  }],
  "config": {
    "framework": "jest",
    "coverage": {
      "threshold": 80
    }
  }
}

Response:
{
  "testId": "string",
  "status": "pending",
  "files": [{
    "path": "string",
    "content": "string"
  }]
}

Test Execution

Run Tests

Execute generated test cases:

POST /v1/tests/run

{
  "testId": "string",
  "environment": {
    "nodeVersion": "16",
    "dependencies": {
      "jest": "^27.0.0"
    }
  }
}

Response:
{
  "runId": "string",
  "status": "running",
  "results": null
}

Results & Reports

Get Test Results

Retrieve test execution results:

GET /v1/tests/results/{runId}

Response:
{
  "runId": "string",
  "status": "completed",
  "results": {
    "passed": 10,
    "failed": 0,
    "coverage": {
      "statements": 85,
      "branches": 80,
      "functions": 90,
      "lines": 85
    }
  }
}

Project Management

Create Project

POST /v1/projects

{
  "name": "string",
  "repository": "string",
  "config": {
    "framework": "jest"
  }
}

Update Project

PUT /v1/projects/{projectId}

{
  "name": "string",
  "config": {
    "coverage": {
      "threshold": 90
    }
  }
}

Error Handling

Error Responses

Status CodeDescription
400Invalid request parameters
401Authentication failed
403Insufficient permissions
404Resource not found
429Rate limit exceeded

Rate Limits

Limits by Plan

PlanRequests/minDaily Limit
Free601,000
Pro30010,000
Enterprise1,000Unlimited

SDKs & Libraries

Node.js

npm install aitotest-sdk

const AIToTest = require('aitotest-sdk');
const client = new AIToTest('api_key');

Python

pip install aitotest

from aitotest import Client
client = Client('api_key')

Java

<dependency>
  <groupId>com.aitotest</groupId>
  <artifactId>sdk</artifactId>
  <version>1.0.0</version>
</dependency>