The PyExec REST API lets you submit Python execution tasks, upload files, and retrieve results programmatically. All endpoints return JSON and require authentication.
All API requests must include your API key in the Authorization header:
Authorization: Bearer YOUR_API_KEYGenerate API keys from your dashboard settings. Rate limits vary by plan: Free (100 req/day), Pro (10K req/day), Business (unlimited).
https://api.pyexec.io/v1cURL
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)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"
}| Code | Meaning |
|---|---|
200 | OK — Request succeeded |
201 | Created — Resource created |
400 | Bad Request — Invalid input |
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 |