Integrate PreTestAds into your workflow. All endpoints use your API key for authentication.
All API requests require a Bearer token. Pass your API key in the Authorization header:
Authorization: Bearer pta_your_api_keyheader
POST /api/v1/analyze
Upload a video file as multipart form data. Returns an analysis ID to poll for results.
curl -X POST https://pretestads.com/api/v1/analyze \
-H "Authorization: Bearer pta_your_api_key" \
-F "modality=video" \
-F "window_seconds=60" \
-F "file=@my_ad.mp4"curl
| Parameter | Type | Required | Description |
|---|---|---|---|
| modality | string | Yes | Must be video |
| window_seconds | int | Yes | Must be 60 |
| file | binary | Yes | Video file (MP4, MOV, AVI — max 500MB) |
GET /api/v1/analyze/{id}
Poll this endpoint until status is "complete" or "failed". Typically takes 60–90 seconds.
curl https://pretestads.com/api/v1/analyze/YOUR_ANALYSIS_ID \
-H "Authorization: Bearer pta_your_api_key"curl
{
"id": "uuid",
"status": "complete",
"score": 82,
"score_raw": 0.82,
"label": "strong",
"verdict": "Your ad outperforms the majority of TikTok top performers...",
"engagement_timeseries": [
{"second": 0.0, "activation": 0.61},
{"second": 1.0, "activation": 0.74},
...
],
"credits_remaining": 14
}json
pending — queuedprocessing — running the AdCortex™ engagement modelcomplete — done, results availablefailed — error, credit refundedGET /api/v1/analyze?page=1&limit=20
POST /api/v1/analyze/{id}/feedback
{"outcome": "converted"}json
GET /api/v1/credits
| Status | Error | Meaning |
|---|---|---|
| 401 | invalid_api_key | Missing or invalid API key |
| 402 | insufficient_credits | No credits remaining |
| 422 | validation_error | Bad parameters |
| 429 | rate_limited | 10 req/min exceeded |
| 500 | server_error | Internal error |
import requests
import time
API_KEY = "pta_your_api_key"
BASE = "https://pretestads.com/api/v1"
headers = {"Authorization": f"Bearer {API_KEY}"}
# Submit analysis
with open("my_ad.mp4", "rb") as f:
res = requests.post(f"{BASE}/analyze",
headers=headers,
files={"file": f},
data={"modality": "video", "window_seconds": 60})
analysis = res.json()
print(f"Submitted: {analysis['id']}")
# Poll for results
while True:
res = requests.get(f"{BASE}/analyze/{analysis['id']}", headers=headers)
result = res.json()
if result["status"] == "complete":
print(f"Score: {result['score']} ({result['label']})")
print(f"Verdict: {result['verdict']}")
break
elif result["status"] == "failed":
print("Analysis failed")
break
time.sleep(5)python
const API_KEY = "pta_your_api_key";
const BASE = "https://pretestads.com/api/v1";
const headers = { Authorization: `Bearer ${API_KEY}` };
// Submit video analysis
const form = new FormData();
form.append("modality", "video");
form.append("window_seconds", "60");
form.append("file", fileBlob, "my_ad.mp4");
const submitRes = await fetch(`${BASE}/analyze`, {
method: "POST",
headers,
body: form,
});
const { id } = await submitRes.json();
// Poll for results
const poll = async () => {
const res = await fetch(`${BASE}/analyze/${id}`, { headers });
const result = await res.json();
if (result.status === "complete") {
console.log(`Score: ${result.score} (${result.label})`);
return result;
}
if (result.status === "failed") throw new Error("Failed");
await new Promise(r => setTimeout(r, 5000));
return poll();
};
const result = await poll();javascript
API requests are limited to 10 requests per minute per API key. Exceeding this limit returns a 429 status with a Retry-After header.