API docs

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

OutputWhat it isHow you ask for it
pii_blurThe video with personal data blurred, such as faces and license plates, and a mask for each frame.Always made.
depthA 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.
trajectoryThe 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>.

Routes

MethodPathWhat it does
POST/batchesSubmit a batch of videos.
GET/batchesList your batches.
GET/batches/{batch_id}Read one batch.
GET/batches/{batch_id}/jobsList the jobs of one batch, in input order.
POST/batches/{batch_id}/cancelCancel the jobs of a batch that have not started.
GET/jobsList your jobs.
GET/jobs/{job_id}Read one job.
GET/jobs/{job_id}/resultRead the result of a completed job.
DELETE/jobs/{job_id}/resultDelete 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

Quickstart

These steps submit one video, wait for its job, and download the result file. They use curl in a shell.

  1. Create an API key on the API keys page and put it in a shell variable.
  2. Write the batch to a file.
  3. Submit the batch.
  4. Poll the job until it has finished.
  5. Read the job's result.
  6. Get a download link for the result file.
  7. 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"
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