Technical reference
Queries & tag operations
Query saved annotations and recorded per-frame data with SQL, then use the matching clip IDs for tagging or export.
Available query views
run_query(project_id, sql) reads saved annotations and recorded data. It does not inspect the video or infer new labels. Each view joins on clip_id. Per-frame columns depend on the imported data; inspect the available fields before writing a telemetry query.
| View | Fields |
|---|---|
| episodes | clip_id, name, source, episode_index, fps, duration_s, frame_count, tasks |
| spans | clip_id, track, label, t0, t1, revision |
| events | clip_id, track, label, t, revision |
| scalars | clip_id, track, t, value, revision |
| frames | clip_id plus recorded per-frame fields, such as timestamp, observation.state, and action |
Find episodes with a saved presence label
This query assumes a reviewed span track named object_presence whose positive label is exactly “red cup visible”. Replace the track and label with the values actually saved in your project. DISTINCT returns one row per matching episode, even if it has several matching intervals.
SELECT DISTINCT e.clip_id, e.name
FROM episodes AS e
JOIN spans AS s ON s.clip_id = e.clip_id
WHERE s.track = 'object_presence'
AND s.label = 'red cup visible'
ORDER BY e.nameReturn matching action intervals
Return clip_id, t0, and t1 when you need evidence windows for review or trimming. This example finds “grasp” spans longer than two seconds on a track named Subtasks. Track names, label spelling, and case must match the stored values.
SELECT clip_id, t0, t1, t1 - t0 AS duration_s
FROM spans
WHERE track = 'Subtasks'
AND label = 'grasp'
AND t1 - t0 > 2
ORDER BY clip_id, t0Combine conditions on the same episode
Use EXISTS to require two labels on the same episode. This example selects recordings containing a visible red cup and a failed grasp anywhere in that episode. It does not require those intervals to overlap.
SELECT e.clip_id, e.name
FROM episodes AS e
WHERE EXISTS (
SELECT 1 FROM spans AS s
WHERE s.clip_id = e.clip_id
AND s.track = 'object_presence'
AND s.label = 'red cup visible'
)
AND EXISTS (
SELECT 1 FROM spans AS s
WHERE s.clip_id = e.clip_id
AND s.track = 'grasp_outcome'
AND s.label = 'failed grasp'
)Filter a measurement or recorded channel
Scalar tracks contain timestamped measurements. This example selects clips whose saved mean_brightness samples fall below 30. The threshold is an example in grayscale units, not a universal dark-video criterion. Validate thresholds on your own footage.
SELECT clip_id, MIN(value) AS minimum_brightness
FROM scalars
WHERE track = 'mean_brightness'
GROUP BY clip_id
HAVING MIN(value) < 30Tag query results
A result with a clip_id column also returns matching clip IDs for follow-up operations. Pass those IDs to update_video_tags to add or remove labels, up to 1,000 IDs per call. Preserve the exact selection and report missing or unowned IDs as skipped.
# Tool-call examples for your agent, not a standalone Python script.
update_video_tags(
clip_ids=["CLIP_ID"],
add=["contains-red-cup", "needs-review"],
)
# After review, preserve the content tag and replace the queue tag.
update_video_tags(
clip_ids=["CLIP_ID"],
remove=["needs-review"],
add=["reviewed"],
)Return a filtered project link
Use get_project_link with the chosen tag so the dashboard opens with that filter already applied. Multiple tags match any listed tag. For an AND selection, compute the intersection first and save a dedicated tag if you need a single reusable filtered link.
get_project_link(
project_id="PROJECT_ID",
tags=["contains-red-cup"],
)Coverage, pagination, and pending results
Queries return at most 10,000 rows. If truncated is true, narrow the query or aggregate it rather than treating the returned rows as the full selection. A query that is still running returns a job ID; poll get_job with kind="query" at least five seconds apart. Use the returned export_version when recording which annotation snapshot informed a result.
