Overview
This API processes egocentric video: video filmed by a camera that a person wears, from that person's point of view.
You send links to your videos in a batch. Each video becomes one job. The service downloads the video, processes it and keeps a result file for you to download.
What a job makes
| Output | What it is | How you ask for it |
|---|---|---|
pii_blur | The video with personal data blurred, such as faces and license plates, and a mask for each frame. | Always made. |
depth | A depth picture for every frame: how far each point of the scene is from the camera along its optical axis, in millimetres. The frames page says more. | Send "depth": true. |
trajectory | The pose of the camera, its position and direction in the scene, for every frame. | Send "trajectory": true, together with "depth": true. |
Depth and trajectory need more facts about each video. Depth needs the lens values of its camera. Trajectory also needs IMU data and the height of the person who wears the camera. The input contract lists them. The frames page describes the file a job delivers.
Base URL
Every path on these pages is relative to this base URL:
https://batch.micro-agi.com/v1/egocentric
The API accepts HTTPS only. A request in clear text gets 403 https_required. The API revokes an API key that such a request carried in its Authorization header or in its URL. Replace any key that you sent in clear text.
Authentication
Every request carries an API key in the Authorization header, in the form Authorization: Bearer <key>.
- An owner of your organisation creates and revokes keys on the API keys page of the panel.
- The panel shows a new key only once. Store it in a safe place when you create it.
- Every key of an organisation has the same rights.
- A revoked key stops working at once.
- A missing, malformed, unknown or revoked key gets 401
authentication_error. - Never put a key in the query string. With a valid key in the
Authorizationheader, such a request gets 400 with the paramquery. Without one, it gets 401authentication_error.
Routes
| Method | Path | What it does |
|---|---|---|
| POST | /batches | Submit a batch of videos. |
| GET | /batches | List your batches. |
| GET | /batches/{batch_id} | Read one batch. |
| GET | /batches/{batch_id}/jobs | List the jobs of one batch, in input order. |
| POST | /batches/{batch_id}/cancel | Cancel the jobs of a batch that have not started. |
| GET | /jobs | List your jobs. |
| GET | /jobs/{job_id} | Read one job. |
| GET | /jobs/{job_id}/result | Read the result of a completed job. |
| DELETE | /jobs/{job_id}/result | Delete the result of a finished job. |
| GET | /jobs/{job_id}/files/{file_id} | Get a download link for one result file. |
The outputs page describes every object these routes return. The errors page lists every error.
Requests and answers
- Every answer is JSON, with
Content-Type: application/json; charset=utf-8andCache-Control: no-store. - Every answer carries an
X-Request-Idheader. Keep it with your logs: it names the request. The API ignores anX-Request-Idthat you send. - Ids are lower-case UUIDs. A path with an upper-case or malformed id gets 404.
- Paths match exactly. A path with a trailing slash gets 404.
- HEAD and OPTIONS get 405.
- The API sends no CORS headers, so a web page in a browser cannot call it. Call the API from your own server.
- In a query string, send
+as%2B.
Quickstart
These steps submit one video, wait for its job, and download the result file. They use curl in a shell.
- Create an API key on the API keys page and put it in a shell variable.
- Write the batch to a file.
- Submit the batch.
- Poll the job until it has finished.
- Read the job's result.
- Get a download link for the result file.
- Download the file.
Step 1: the key
export API_KEY="your key from the panel"
Step 2: the batch
Save this as batch.json. Replace the link with an https link to your own video. The service downloads the video from this link.
{
"inputs": [
{
"type": "video_url",
"video_url": { "url": "https://videos.example.com/kitchen.mp4" },
"filename": "kitchen.mp4"
}
]
}
Step 3: submit
Each new batch needs a new Idempotency-Key. This command makes one and keeps it in a shell variable:
export BATCH_KEY="$(uuidgen)"
Then submit the batch:
curl -sS -X POST "https://batch.micro-agi.com/v1/egocentric/batches" \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: $BATCH_KEY" \
--data-binary @batch.json
The answer is 202 with the batch. Its id is the batch id. Its jobs list holds one object with an id for each input, in input order. Put the first job id in a shell variable:
export JOB_ID="the id from jobs in the answer"
If the answer does not arrive, send the same request again with the same $BATCH_KEY. You then get the same batch, not a second one. Before you submit another batch, make a new key with the export line above.
Step 4: poll the job
curl -sS -X GET "https://batch.micro-agi.com/v1/egocentric/jobs/$JOB_ID" \
-H "Authorization: Bearer $API_KEY"
Repeat this request until status is completed or failed. Wait between the requests: each one counts toward your organisation's read limit. A failed job holds an error that says why it failed.
Step 5: read the result
curl -sS -X GET "https://batch.micro-agi.com/v1/egocentric/jobs/$JOB_ID/result" \
-H "Authorization: Bearer $API_KEY"
The result lists the job's files. Put the id and the name of the file in shell variables:
export FILE_ID="the id of the file in the result"
export FILE_NAME="the name of the file in the result"
Step 6: get a download link
curl -sS -X GET "https://batch.micro-agi.com/v1/egocentric/jobs/$JOB_ID/files/$FILE_ID" \
-H "Authorization: Bearer $API_KEY"
The answer is JSON with a url. The link works for 900 seconds (15 minutes). Put it in a shell variable:
export DOWNLOAD_URL="the url from the answer"
Step 7: download
curl -sS -o "$FILE_NAME" "$DOWNLOAD_URL"
shasum -a 256 "$FILE_NAME"
Do not send your API key to the download link: the link carries its own signature. The printed SHA-256 must equal the file's sha256 in the result.
Next steps
- Input contract: every field of a batch and its rules.
- Outputs: batches, jobs, results, files and lists.
- Frames: the topics, units and coordinate frames of the delivered file.
- Camera profiles: lens values for depth and trajectory.
- IMU data: the IMU formats and how their clock meets the video.
- Limits: rates, sizes, credits and how long results are kept.
- Errors: every status and code, and when to retry.
- OpenAPI file: the routes and objects of the API as an OpenAPI file.