Phylax API
Version 1. Send a photo of a shot target; get back every shot and bullseye as JSON.
Authentication
To get a free trial key, email longrangelabworks@gmail.com with your name and what you are building. Every request carries your API key in the Authorization header:
Authorization: Bearer phx_xxxxxxxx_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Keep the key on your own server. If you put it inside a mobile app, anyone can extract it and use your quota. The recommended setup is: your app sends the photo to your backend, and your backend calls Phylax.
Analyse a photo
POST /v1/analyze
Send the photo as the raw request body (Content-Type: image/jpeg or image/png), or as a multipart/form-data field named photo. Send the original camera file: the server applies the EXIF orientation. Up to 40 MB and 30 megapixels.
Query parameters
| Name | Values | Meaning |
|---|---|---|
model | medium (default) | Optional. The model that analyses the photo. Medium is the current model; more may be offered later. |
shots_per_bullseye | 1 to 50, optional | If you know how many shots were fired at each bullseye, pass it. Phylax then returns that many shots per bullseye where it can, marking any it is unsure of. |
Example
curl -X POST "https://phylaxvision.com/v1/analyze?model=medium" \
-H "Authorization: Bearer $PHYLAX_API_KEY" \
-H "Content-Type: image/jpeg" \
--data-binary @target.jpg
More languages, and the batch version, are under Code examples.
Response
{
"api_version": "1",
"request_id": "8f0c...",
"model": "medium",
"width": 3024, "height": 4032,
"hole_width_px": 41.5,
"shots": [ {"x": 1510.2, "y": 1987.4, "confidence": "high", "group": 0, "flag": ""}, ... ],
"bullseyes": [ {"id": 0, "x": 1502.0, "y": 1990.5, "kind": "crosshair", "r": 120.3}, ... ],
"groups": [ {"id": 0, "shots": 5}, ... ],
"outline": [212.0, 340.5, 2810.0, 3702.0],
"low_resolution": false,
"quota": {"month": "2026-12", "used": 132, "limit": 1000}
}
| Field | Meaning |
|---|---|
width, height | Size of the photo after EXIF rotation. All coordinates are pixels of this upright image, origin top left. |
shots[] | One entry per shot: center x, y; confidence = "high", "medium" or "low"; group = id of the nearest bullseye, or null; flag = "", "unsure" (worth a second look) or "added_for_count" (added only to reach shots_per_bullseye). |
bullseyes[] | Aim points, numbered in rows from top to bottom and left to right: center x, y; kind = "dot" or "crosshair"; r = approximate radius in pixels. |
groups[] | Number of shots assigned to each bullseye. |
hole_width_px | Typical width of one hole in this photo, in pixels. Useful for converting to inches or millimetres if you know the caliber. |
outline | Box around the target sheet [left, top, right, bottom], or null. |
low_resolution | True if holes are under about 25 pixels wide. Results are less reliable; ask the user for a closer photo. |
A good pattern for apps: show shots that have a flag in a different color and let the user confirm or remove them.
Batches (many photos)
For more than a few photos, use a batch. You upload photos one request at a time (each upload returns at once), Phylax analyses them in the background, and you collect results as each one finishes. Your app or backend can queue photos offline and send them later.
POST /v1/batcheswith optionalmodelandshots_per_bullseye(same meaning as above, for every photo in the batch). Returnsbatch_id.POST /v1/batches/{batch_id}/photos?ref=<your id>with the photo as the body (raw or multipart, as above).refis your own name for the photo: 1 to 64 letters, digits,.,_or-. Returns202with aphoto_id.GET /v1/batches/{batch_id}returns the batch with every photo'sstatus(queued,processing,done,failed) and, when done, itsresultin the same format as/v1/analyze.completeis true when every photo is done or failed. Poll every 5 to 10 seconds.GET /v1/batches/{batch_id}/photos/{photo_id}returns one photo.
Resuming after a dropped connection: send the same photo again with the same ref. If Phylax already has it, you get 200 with "duplicate": true and the existing photo; it is not analysed or billed twice. A photo that failed can be sent again under the same ref.
| Batch limit | Value |
|---|---|
| Photos per batch | 500 (start a new batch for more) |
| Photos waiting per key | 25. Beyond that, uploads get 429 queue_full with Retry-After; upload more as results arrive. |
| Open batches per key | 50 |
| How long results are kept | 24 hours after the batch's last activity, then deleted. Photos themselves are deleted as soon as they are analysed. |
| Billing | One photo from your quota per analysed photo. Failed and duplicate uploads are free. |
Batch results are held in memory. In the rare case of a service restart, a batch can return 404 batch_not_found; create a new batch and upload the photos that had no result.
Code examples
Keep the API key on your server, never in the app itself.
Python (single photo and batch)
import os, time, requests
HOST = "https://phylaxvision.com"
AUTH = {"Authorization": f"Bearer {os.environ['PHYLAX_API_KEY']}"}
def analyze(path, **params):
with open(path, "rb") as f:
r = requests.post(f"{HOST}/v1/analyze", params=params, timeout=120,
headers={**AUTH, "Content-Type": "image/jpeg"}, data=f.read())
r.raise_for_status()
return r.json()
def analyze_batch(paths, **params):
batch = requests.post(f"{HOST}/v1/batches", params=params, headers=AUTH, timeout=30).json()
bid = batch["batch_id"]
for path in paths:
ref = os.path.basename(path).replace(" ", "_")[:64]
while True:
with open(path, "rb") as f:
r = requests.post(f"{HOST}/v1/batches/{bid}/photos", params={"ref": ref},
headers={**AUTH, "Content-Type": "image/jpeg"}, data=f.read(), timeout=120)
if r.status_code != 429:
break
time.sleep(int(r.headers.get("Retry-After", "10")))
r.raise_for_status()
while True:
b = requests.get(f"{HOST}/v1/batches/{bid}", headers=AUTH, timeout=30).json()
if b["complete"]:
return {p["ref"]: p["result"] or p["error"] for p in b["photos"]}
time.sleep(5)
result = analyze("target.jpg", shots_per_bullseye=5)
for s in result["shots"]:
print(s["x"], s["y"], s["group"], s["confidence"])
JavaScript (Node 18+)
import { readFile } from "node:fs/promises";
const HOST = "https://phylaxvision.com";
const AUTH = { Authorization: `Bearer ${process.env.PHYLAX_API_KEY}` };
async function analyze(path, params = {}) {
const r = await fetch(`${HOST}/v1/analyze?` + new URLSearchParams(params), {
method: "POST", headers: { ...AUTH, "Content-Type": "image/jpeg" }, body: await readFile(path),
});
if (!r.ok) throw new Error((await r.json()).error.message);
return r.json();
}
const result = await analyze("target.jpg", { model: "medium" });
console.log(result.shots.length, "shots,", result.bullseyes.length, "bullseyes");
Kotlin (OkHttp, on your backend)
val client = OkHttpClient.Builder().readTimeout(120, TimeUnit.SECONDS).build()
fun analyze(photo: File, apiKey: String): JSONObject {
val request = Request.Builder()
.url("https://phylaxvision.com/v1/analyze?model=medium")
.header("Authorization", "Bearer $apiKey")
.post(photo.asRequestBody("image/jpeg".toMediaType()))
.build()
client.newCall(request).execute().use { r ->
val body = JSONObject(r.body!!.string())
if (!r.isSuccessful) error(body.getJSONObject("error").getString("message"))
return body
}
}
Swift (URLSession, on your backend or via your server)
func analyze(photo: URL, apiKey: String) async throws -> [String: Any] {
var req = URLRequest(url: URL(string: "https://phylaxvision.com/v1/analyze?model=medium")!)
req.httpMethod = "POST"
req.timeoutInterval = 120
req.setValue("Bearer \(apiKey)", forHTTPHeaderField: "Authorization")
req.setValue("image/jpeg", forHTTPHeaderField: "Content-Type")
let (data, resp) = try await URLSession.shared.upload(for: req, fromFile: photo)
let json = try JSONSerialization.jsonObject(with: data) as? [String: Any] ?? [:]
guard (resp as? HTTPURLResponse)?.statusCode == 200 else {
throw NSError(domain: "Phylax", code: 1, userInfo: [NSLocalizedDescriptionKey:
(json["error"] as? [String: Any])?["message"] as? String ?? "Request failed"])
}
return json
}
curl: batch
B=$(curl -s -X POST "https://phylaxvision.com/v1/batches?shots_per_bullseye=5" \
-H "Authorization: Bearer $PHYLAX_API_KEY" | jq -r .batch_id)
for f in *.jpg; do
curl -s -X POST "https://phylaxvision.com/v1/batches/$B/photos?ref=${f%.jpg}" \
-H "Authorization: Bearer $PHYLAX_API_KEY" -H "Content-Type: image/jpeg" --data-binary @"$f"
done
curl -s "https://phylaxvision.com/v1/batches/$B" -H "Authorization: Bearer $PHYLAX_API_KEY" | jq '.counts, .complete'
Usage
GET /v1/usage returns this month's count, your limit and your rate limit.
Errors
Errors return JSON {"error": {"code": "...", "message": "..."}, "request_id": "..."}. Failed requests are not billed.
| HTTP | code | What to do |
|---|---|---|
| 400 | invalid_model, invalid_parameter, invalid_body, missing_ref, invalid_ref | Fix the request. |
| 404 | batch_not_found, photo_not_found | Check the id. Batches expire 24 hours after their last activity. |
| 409 | batch_full | Start a new batch. |
| 401 | invalid_api_key | Check the key. Revoked keys also return this. |
| 403 | key_expired | Email longrangelabworks@gmail.com to renew. |
| 413 | photo_too_large | Send at most 40 MB. |
| 422 | unreadable_photo | Not a JPEG or PNG, or over 30 megapixels. |
| 429 | rate_limited, too_many_concurrent, queue_full, too_many_batches, monthly_quota_exceeded | Wait (see Retry-After), send fewer photos at once (2 per key), or upgrade your plan. |
| 500, 503 | internal_error, busy | Retry after a few seconds with backoff. Quote the request_id if it persists. |
Limits
- Monthly photo quota and requests per minute depend on your plan; see the
X-RateLimit-*headers and/v1/usage. - At most 2 photos in progress per key. A photo takes a few seconds; very dense targets up to about 20 seconds. Use a timeout of at least 120 seconds.
Privacy and terms
Photos are analysed in memory and are not stored. Request logs keep only the time, a request id, your key id, the model, the photo size, the number of shots and bullseyes found, the processing time and the status. Use of the API is subject to the terms, which among other things forbid using the results to train other models.
Machine-readable description: /v1/openapi.json.