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

Media - Retrieve

  • Dark
    Light

Article summary

Retrieve Media

Uploaded media objects can be retrieved with a valid Cogniac media ID.

Retrieve Media

GET /1/media/{media_id}
Host: https://api.cogniac.io

curl -X GET https://api.cogniac.io/1/media/QBCYGH2LACG4IDFQLRXJVIE1BWWH \
-H "Authorization: Bearer abcdefg.hijklmnop.qrstuvwxyz" \
-H "Content-Type: application/json" \
| json_pp

import requests
import json

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


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

if response.status_code == 200:
    # Parse the content as JSON and print it with indentation for better readability
    formatted_json = json.dumps(response.json(), indent=2)
    print(formatted_json)
else:
    print(f"Error: {response.status_code}")
    print(response.content)

{
   "author" : null,
   "author_profile_url" : null,
   "bits_per_pixel" : 8,
   "created_at" : 1685743262.85621,
   "domain_unit" : "a8c5fe5560cbf5f1e2b75c0f56de24e2",
   "duration" : null,
   "external_media_id" : null,
   "filename" : "0cd64e65454e1a53.jpg",
   "fps" : null,
   "frame" : null,
   "frame_durations" : [],
   "frame_preview_map" : {},
   "image_height" : 980,
   "image_width" : 1024,
   "license" : null,
   "md5" : "a8c5fe5560cbf5f1e2b75c0f56de24e2",
   "media_format" : "JPEG",
   "media_id" : "QBCYGH2LACG4IDFQLRXJVIE1BWWH",
   "media_src" : "web_app",
   "media_timestamp" : 1675980277.382,
   "media_url" : "https://api.cogniac.io/1/media/download/QBCYGH2LACG4IDFQLRXJVIE1BWWH/QBCYGH2LACG4IDFQLRXJVIE1BWWH",
   "meta_tags" : null,
   "network_camera_id" : null,
   "num_channels" : 3,
   "num_frames" : null,
   "original_landing_url" : null,
   "original_url" : null,
   "parent_media_id" : null,
   "parent_media_ids" : [],
   "preview_url" : null,
   "resize_urls" : {
      "454" : "https://api.cogniac.io/1/media/download/QBCYGH2LACG4IDFQLRXJVIE1BWWH/QBCYGH2LACG4IDFQLRXJVIE1BWWH_max_454"
   },
   "sequence_ix" : null,
   "set_assignment" : "training",
   "size" : 602741,
   "source_url" : null,
   "status" : "success",
   "tenant_id" : "abcdefghijk",
   "time_base" : null,
   "title" : null,
   "trigger_id" : null,
   "uploaded_by_user" : "test@cogniac.co",
   "video" : false,
   "video_context" : null
}


Was this article helpful?