{
  "reference_id": "sample_reference_id",
  "data": {
    "video_data": {
      "frames": [
        {
          "frame_id": "frame001",
          "src": "https://dummyimage.com/600x400/000/fff.jpg&text=Dummy+Image+1"
        },
        {
          "frame_id": "frame002",
          "src": "https://dummyimage.com/600x400/000/fff.jpg&text=Dummy+Image+2"
        }
      ]
    }
  },
  "tag": "track_bounding_boxes",
  "batch_id": "72c888f6-b365-4f27-ad57-d7841da2de0c"
}
{
  "data": {
    "job_id": "3f3e8675-ca69-46d7-aa34-96f90fcbb732",
    "reference_id": "001",
    "tag": "Sample-task"
  },
  "success": true
}
import requests
import json
"""
Details for creating JOBS,
project_id ->> ID of project in which job needed to be created
x_api_key ->> secret api key to create JOBS
tag ->> You can ask this from playment side
batch_id ->> The batch in which JOB needed to be created
"""
project_id = ''
x_api_key = ''
tag = ''
batch_id = ''
#method that can be used to call the job creation api
def Upload_jobs( DATA):
    base_url = f"https://api.playment.io/v0/projects/{project_id}/jobs"
    response = requests.post(base_url, headers={'x-api-key': x_api_key}, json=DATA)
    print(response.json())
    if response.status_code >= 500:
        raise Exception("Something wrong at Playment's end")
    if 400 <= response.status_code < 500:
        raise Exception("Something wrong!!")
    return response.json()
#method that can be used for batch creation
def create_batch(batch_name,batch_description):
    headers = {'x-api-key':x_api_key}
    url = 'https://api.playment.io/v1/project/{}/batch'.format(project_id)
    data = {"project_id":project_id,"label":batch_name,"name":batch_name,"description":batch_description}
    response = requests.post(url=url,headers=headers,json=data)
    print(response.json())
    if response.status_code >= 500:
        raise Exception("Something wrong at Playment's end")
    if 400 <= response.status_code < 500:
        raise Exception("Something wrong!!")
    return response.json()['data']['batch_id']
#list of frames in a single job
frames = [
    "https://example.com/image_url_1",
    "https://example.com/image_url_2"
]
video_data = {'frames' : []}
for frame_url in frames:
    frame_id = os.path.basename(os.path.normpath(frame_url))
    frame_obj = {'src':frame_url,'frame_id':frame_id}
    video_data['frames'].append(frame_obj)
#reference_id should be unique for each job
reference_id="job1"
job_data = {
            'reference_id':reference_id,
            'tag':api_tag,
            'data':{'video_data':video_data},
            'batch_id' : new_batch_id
            }
#helper method to print json data structure 
def to_dict(obj):
    return json.loads(
        json.dumps(obj, default=lambda o: getattr(o, '__dict__', str(o)))
    )
print(json.dumps(to_dict(job_data)))
response = Upload_jobs(DATA=job_data)
print(response.json())
{
    "data": {
        "project_id": "",
        "reference_id": "001",
        "job_id": "fde54589-ebty-48lp-677a-03a0428ca836",
        "batch_id": "b99d241a-bb80-ghyi-po90-c37d4fead593",
        "status": "completed",
        "tag": "sample_project",
        "priority_weight": 5,
        "result": "https://playment-data-uploads.s3.ap-south-1.amazonaws.com/sample-result.json"
    },
    "success": true
}
{
  "data": {
    "annotation_data": {
      "annotations": [
        {
          "_id": "9e28385a-6d49-4388-b2d2-f8165dc83b2a",
          "color": "rgb(150,207,29)",
          "state": "editable",
          "attributes": null,
          "label": "Driveable Free Space",
          "label_id": null,
          "type": "polygon",
          "source": "images",
          "grouping_config": null,
          "evaluations": null,
          "origin": null,
          "frames": {
            "bear_0000.png": {
              "_id": "290aab8e-efc1-43e1-bf48-490f97662b5a",
              "type": "polygon",
              "color": "rgb(150,207,29)",
              "keyFrame": false,
              "label": "Driveable Free Space",
              "origin": null,
              "attributes": {},
              "annotationQcEvals": {},
              "annotationQCEvaluations": null,
              "comments": [],
              "evaluations": {},
              "shapeEditable": false,
              "labelEditable": false,
              "showLabel": false,
              "points": {
                "p1": {
                  "x": 0.002799,
                  "y": 0.610394
                },
                "p10": {
                  "x": 0.029849,
                  "y": 0.765751
                },
                "p100": {
                  "x": 0.637642,
                  "y": 0.553655
                },
                "p101": {
                  "x": 0.663969,
                  "y": 0.560358
                },
                "p102": {
                  "x": 0.700188,
                  "y": 0.569034
                },
                "p103": {
                  "x": 0.78035,
                  "y": 0.58707
                }
              },
              "edges": {
                "e1": [
                  "p1",
                  "p2"
                ],
                "e10": [
                  "p10",
                  "p11"
                ],
                "e100": [
                  "p100",
                  "p101"
                ],
                "e101": [
                  "p101",
                  "p102"
                ],
                "e102": [
                  "p102",
                  "p103"
                ],
                "e103": [
                  "p103",
                  "p104"
                ]
              },
              "segments": []
            }
          }
        }
      ],
      "groups": null
    },
    "video_data": {
      "frames": [
        {
          "_id": "00000000-0000-0000-0000-000000000000",
          "frame_id": "bear_0000.png",
          "meta_data": null,
          "ref_id": "",
          "src": "http://dfnq1fss3rnqc.cloudfront.net/play/original/3e4379ec-2a5a-4d30-9772-c02d408b2fe9",
          "src_original": "https://playment-asmobi.s3.amazonaws.com/pilot_data/2D_animals/bear/bear_0000.png"
        },
        {
          "_id": "00000000-0000-0000-0000-000000000000",
          "frame_id": "bear_0001.png",
          "meta_data": null,
          "ref_id": "",
          "src": "http://dfnq1fss3rnqc.cloudfront.net/play/original/9b282fcc-f328-4f2b-88e9-f0efad08fd05",
          "src_original": "https://playment-asmobi.s3.amazonaws.com/pilot_data/2D_animals/bear/bear_0001.png"
        }
      ]
    }
  }
}

Result JSON Structure

Response KeyDescription
dataobject having annotation_data object and video_data
data.annotation_data.annotationsList of all the annotation tracks each having _id, label, frames and other attributes
data.annotation_data.annotations.[i]._idString The unique tracking ID for an instance of an object across the sequential data.
data.annotation_data.annotations.[i].framesA dictionary with the frame_id key and annotation details as the value
data.annotation_data.annotations.[i].frames.<frame_id>.pointsThe normalized coordinates dictionary of the points that correspond to the annotated line.
data.annotation_data.annotations.[i].frames.<frame_id>.edgesThis gives a list of pairs of points which correspond to the order in which the points are joined to make the final polygon.
data.annotation_data.annotations.[i].frames.<frame_id>._idString The unique ID for a frame instance of a tracker ie. an annotation
data.annotation_data.annotations.[i].frames.<frame_id>.attributesFrame level attribute dictionary for the given annotation
data.video_dataObject It is the input data, having list of frames
data.video_data.frames.[i].src_originalString source of input frame provided by client