Skip to main content

Getting started

Step 1: Choose and set up your environment

Mocra has a powerful RESTful HTTP API accessible at https://api.mocra.io/. You can use it to interact with Mocra if you prefer an HTTP interface or if your favorite programming language is not listed below.Using the HTTP API does not require installing anything as long as your language or environment can perform HTTP operations.
If you prefer an SDK, we provide a driver for JavaScript and TypeScript. To use the JavaScript SDK, install it with npm:
npm install @mocra/observe
TypeScript typings are included.
If you prefer an SDK, we provide a driver for Python. To use the Python SDK, install it with pip:
pip install mocra
The SDK requires Python 3.10 or higher.

Step 2: Get a Mocra API key

An API key is required to interact with Mocra. Currently, Mocra is in beta trial, so a limited number of API keys are being issued to selected customers. If you are interested in using Mocra, email contact@mocra.io to join our waitlist.

Step 3: Write your code

You can use the HTTP API from any environment that supports HTTP requests. Here is an example using cURL:
curl \
  -X POST \
  -H "Authorization: Bearer <YOUR API KEY>" \
  -H "Content-Type: application/json" \
  -H "Accept: application/json" \
  -d "{\
      \"videoUrl\": \"<YOUR VIDEO URL>\",\
      \"customCriteria\": [],\
      \"removeCriteria\": []\
  }"\
  https://api.mocra.io/observe
Import the required class from @mocra/observe and use it as in the example that follows:
import { VideoObservabilityApi } from "@mocra/observe";

const api = new VideoObservabilityApi("<YOUR API KEY>");
const result = await api.scoreVideo(
  "http://example.org/video.mp4",
  [
    {
      criterionName: "Blur",
      criterionDescription: "The video should not be blurry",
    },
  ],
  ["UNNATURAL PHYSICS"],
);
console.log(result.severity, result.criteria);
Import the required classes from mocra and use them as in the example that follows:
from mocra import VideoObservabilityApi, ExtraCriterion

api = VideoObservabilityApi("<YOUR API KEY>")
result = api.score_video(
    "http://example.org/video.mp4",
    extra_criteria=[
        ExtraCriterion(
            criterion_name="Blur",
            criterion_description="The video should not be blurry",
        ),
    ],
    ignore_criteria=["UNNATURAL PHYSICS"],
)
print(result.severity, result.criteria)

Next steps

Now that you’re set up, explore these key features:

JavaScript SDK

Reference documentation for the Mocra JavaScript SDK.

Python SDK

Reference documentation for the Mocra Python SDK.