← Phylax

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

NameValuesMeaning
modelmedium (default)Optional. The model that analyses the photo. Medium is the current model; more may be offered later.
shots_per_bullseye1 to 50, optionalIf 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}
}
FieldMeaning
width, heightSize 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_pxTypical width of one hole in this photo, in pixels. Useful for converting to inches or millimetres if you know the caliber.
outlineBox around the target sheet [left, top, right, bottom], or null.
low_resolutionTrue 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.

  1. POST /v1/batches with optional model and shots_per_bullseye (same meaning as above, for every photo in the batch). Returns batch_id.
  2. POST /v1/batches/{batch_id}/photos?ref=<your id> with the photo as the body (raw or multipart, as above). ref is your own name for the photo: 1 to 64 letters, digits, ., _ or -. Returns 202 with a photo_id.
  3. GET /v1/batches/{batch_id} returns the batch with every photo's status (queued, processing, done, failed) and, when done, its result in the same format as /v1/analyze. complete is 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 limitValue
Photos per batch500 (start a new batch for more)
Photos waiting per key25. Beyond that, uploads get 429 queue_full with Retry-After; upload more as results arrive.
Open batches per key50
How long results are kept24 hours after the batch's last activity, then deleted. Photos themselves are deleted as soon as they are analysed.
BillingOne 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.

HTTPcodeWhat to do
400invalid_model, invalid_parameter, invalid_body, missing_ref, invalid_refFix the request.
404batch_not_found, photo_not_foundCheck the id. Batches expire 24 hours after their last activity.
409batch_fullStart a new batch.
401invalid_api_keyCheck the key. Revoked keys also return this.
403key_expiredEmail longrangelabworks@gmail.com to renew.
413photo_too_largeSend at most 40 MB.
422unreadable_photoNot a JPEG or PNG, or over 30 megapixels.
429rate_limited, too_many_concurrent, queue_full, too_many_batches, monthly_quota_exceededWait (see Retry-After), send fewer photos at once (2 per key), or upgrade your plan.
500, 503internal_error, busyRetry after a few seconds with backoff. Quote the request_id if it persists.

Limits

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.