Media - Subjects
  • 22 Dec 2023
  • 1 Minute to read
  • Dark
    Light

Media - Subjects

  • Dark
    Light

Article summary

Media Subjects

The media subjects endpoint will return all current subject-media associations for the given media item.

Get Media Subjects

GET /1/media/{media_id}/subjects
Host: https://api.cogniac.io
curl -X GET https://api.cogniac.io/1/media/QBCYGH2LACG4IDFQLRXJVIE1BWWH/subjects \
-H "Authorization: Bearer abcdefg.hijklmnop.qrstuvwxyz" 
| json_pp

import requests
import json
from pprint import pprint

url_prefix = 'https://api.cogniac.io'
api_version = "1"
media_id = '7GJW8T3VWS4XOU9MEW9IT6BYRGYR'
token = ''  # add your token here
headers = {'Authorization': f'Bearer {token}'} 

url = f'{url_prefix}/{api_version}/media/{media_id}/subjects'
response = requests.get(url, headers=headers)

res = requests.get(url, headers=headers)

if res.status_code == 200:
    response_data = json.loads(res.content)
    pprint(response_data)
else:
    print(f"Error: {res.status_code}, {res.text}")

{
  "data": [
    {
      "media": {
        "media_id": "7GJW8T3VWS4XOU9MEW9IT6BYRGYR",
        "media_resize_urls": {
          "454": "https://cogniac-media.s3.amazonaws.com/7GJW8T3VWS4XOU9MEW9IT6BYRGYR_max_454",
          "750": "https://cogniac-media.s3.amazonaws.com/7GJW8T3VWS4XOU9MEW9IT6BYRGYR_max_750"
        },
        "media_url": "https://cogniac-media.s3.amazonaws.com/7GJW8T3VWS4XOU9MEW9IT6BYRGYR",
        "resize_urls": {
          "454": "https://cogniac-media.s3.amazonaws.com/7GJW8T3VWS4XOU9MEW9IT6BYRGYR_max_454",
          "750": "https://cogniac-media.s3.amazonaws.com/7GJW8T3VWS4XOU9MEW9IT6BYRGYR_max_750"
        }
      },
      "subject": {
        "app_data": null,
        "app_data_type": null,
        "consensus": "True",
        "media_id": "7GJW8T3VWS4XOU9MEW9IT6BYRGYR",
        "probability": 0.999,
        "subject_uid": "cat_123",
        "timestamp": 1481809927.207236
      },
      "focus":{
        "box": {"x0": 50, "x1": 275, "y0": 634, "y1": 870}
      }
    },
    {
      "media": {
        "media_id": "7GJW8T3VWS4XOU9MEW9IT6BYRGYR",
        "media_resize_urls": {
          "454": "https://cogniac-media.s3.amazonaws.com/7GJW8T3VWS4XOU9MEW9IT6BYRGYR_max_454",
          "750": "https://cogniac-media.s3.amazonaws.com/7GJW8T3VWS4XOU9MEW9IT6BYRGYR_max_750"
        },
        "media_url": "https://cogniac-media.s3.amazonaws.com/7GJW8T3VWS4XOU9MEW9IT6BYRGYR",
        "resize_urls": {
          "454": "https://cogniac-media.s3.amazonaws.com/7GJW8T3VWS4XOU9MEW9IT6BYRGYR_max_454",
          "750": "https://cogniac-media.s3.amazonaws.com/7GJW8T3VWS4XOU9MEW9IT6BYRGYR_max_750"
        }
      },
      "subject": {
        "app_data": null,
        "app_data_type": null,
        "consensus": null,
        "media_id": "7GJW8T3VWS4XOU9MEW9IT6BYRGYR",
        "probability": 0.5,
        "subject_uid": "dog_123",
        "timestamp": 1481809927.464742
      },
      "focus":{
        "box": {"x0": 235, "x1": 450, "y0": 1115, "y1": 1260}
      }
    }
  ]
}


Was this article helpful?