v1.0

API Reference

The PyExec REST API lets you submit Python execution tasks, upload files, and retrieve results programmatically. All endpoints return JSON and require authentication.

Authentication

All API requests must include your API key in the Authorization header:

Authorization: Bearer YOUR_API_KEY

Generate API keys from your dashboard settings. Rate limits vary by plan: Free (100 req/day), Pro (10K req/day), Business (unlimited).

Base URL

https://api.pyexec.io/v1

Quick Start

cURL

curl -X POST https://api.pyexec.io/v1/jobs \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "prompt": "Analyze the CSV file and return top 10 rows by revenue",
    "title": "Revenue Analysis"
  }'

Python

import requests

API_KEY = "pyex_your_key_here"
BASE_URL = "https://api.pyexec.io/v1"

headers = {"Authorization": f"Bearer {API_KEY}", "Content-Type": "application/json"}

# Submit a job
resp = requests.post(f"{BASE_URL}/jobs", headers=headers, json={
    "prompt": "Calculate the mean, median, and std for all numeric columns"
})
job = resp.json()
print(f"Job submitted: {job['id']}")

# Poll for result
import time
while True:
    status = requests.get(f"{BASE_URL}/jobs/{job['id']}", headers=headers).json()
    if status["status"] in ("completed", "failed"):
        print(status.get("result") or status.get("error_message"))
        break
    time.sleep(2)

Endpoints

Submit a new Python execution task. The AI will generate and execute the appropriate code.

Request Body

{
  "prompt": "Analyze the attached CSV and return summary statistics",
  "title": "Sales Data Analysis",  // optional
  "priority": 5                     // optional, 1-10
}

Response

{
  "id": "a1b2c3d4-...",
  "status": "pending",
  "title": "Sales Data Analysis",
  "created_at": "2024-01-15T10:30:00Z"
}

Status Codes

CodeMeaning
200OK — Request succeeded
201Created — Resource created
400Bad Request — Invalid input
401Unauthorized — Invalid or missing API key
403Forbidden — Insufficient permissions
404Not Found — Resource not found
429Too Many Requests — Rate limit exceeded
500Internal Server Error — Server error