Getting Started
This tutorial walks you through sending your first video to the Gaard Vision API and retrieving the classification result. By the end, you will have a working API call you can adapt for your integration.
Prerequisites
Section titled “Prerequisites”- A Gaard account with API access
curlinstalled on your machine- A video file to classify (MP4 or MOV)
-
Get your API token
Section titled “Get your API token”Create an API token in the Gaard app at Settings > Platform > Integrations.
Once you have the token, export it as an environment variable so the commands in this tutorial can reference it:
terminal export API_KEY="your-api-token" -
Get a sample video
Section titled “Get a sample video”If you do not have a video file ready, download our sample clip or grab one from the VIRAT dataset.
Save the video file to your working directory. The examples below assume the file is named
video.mp4. -
Send a video for classification
Section titled “Send a video for classification”The classification endpoint accepts a
multipart/form-dataPOST request. You upload the video file as a form field using-F, not as a JSON payload.
Async mode (default)
Section titled “Async mode (default)”By default, classification runs asynchronously. The API accepts the video and returns an ID you use to poll for the result.
curl -X POST https://vision.gaard.ai/api/classify \ -H "Authorization: Bearer $API_KEY" \ -F "video=@video.mp4"The response contains the classification ID and a timestamp:
{ "id": "66436fc66d24ab9cf81140eb", "accepted_at": "2024-05-14T16:05:58.444Z"}Use the id value to retrieve the result:
curl https://vision.gaard.ai/api/result/66436fc66d24ab9cf81140eb \ -H "Authorization: Bearer $API_KEY"If the classification is still processing, poll this endpoint again after a few seconds until the result is available.
Sync mode
Section titled “Sync mode”If you prefer to wait for the result in a single request, add ?sync=true. The API blocks until classification is complete and returns the full result directly.
curl -X POST "https://vision.gaard.ai/api/classify?sync=true" \ -H "Authorization: Bearer $API_KEY" \ -F "video=@video.mp4"Add metadata (recommended)
Section titled “Add metadata (recommended)”With metadata, Gaard:
- links each result to a site and a camera, and creates them on first sight;
- applies that camera’s settings, such as exclusion zones;
- lets your team review, filter and report results by site and camera.
Give each site and camera a stable, unique match id and a readable name. Create a file named metadata.json:
{ "site": { "site_match_id": "acme-paris-warehouse", "name": "Paris warehouse" }, "camera": { "camera_match_id": "acme-paris-warehouse/dock-north", "name": "Dock north" }}Use the same match ids for the same camera on every request. If an id changes, Gaard creates a new site or camera, and the history of the old one is not moved.
Then include it in the request as a second form field:
curl -X POST https://vision.gaard.ai/api/classify \ -H "Authorization: Bearer $API_KEY" \ -F "video=@video.mp4" \ -F "metadata=@metadata.json"What’s next
Section titled “What’s next”Now that you have successfully classified a video, make sure your integration sends metadata with every request, then explore the rest of the API:
- Endpoints: full endpoint reference for classify, result, annotate, and delete
- Response structure: understand the fields in a classification response
- Classification result: result types, statuses, and detailed examples
- Metadata: all fields, how match ids link videos to sites and cameras, and how to move from
site_id/camera_id - Webhooks: receive async results via webhook instead of polling

