Last updated

getMedia()

Gets media data by slug or ID.

Signature

const response = await window.FairShareSDK.getMedia(identifier);

Parameters

ParameterTypeDescription
identifierstringMedia slug or ID

Returns

Promise<MediaResponse> — The response object containing metadata and media data.

Media Object:

PropertyTypeDescription
idnumberMedia ID
titlestringMedia title
descriptionstringMedia description
slugstringURL-friendly identifier
custom_slugbooleanWhether slug is custom
activebooleanWhether media is active
kindstringMedia kind (e.g., image, video)
media_typestringType of media (e.g., share)
media_formatstringFile format (e.g., png, mp4)
image_urlstringThumbnail/poster image URL
video_urlstringVideo URL (for video media)
pdf_urlstringPDF URL (for PDF media)
powerpoint_urlstringPowerPoint URL (for presentation media)
durationnumberDuration in seconds (for video)
comments_countnumberNumber of comments
subtitlesobjectSubtitle tracks by language
settingsobjectMedia settings (CTA, SEO)
enrollment_packsarrayArray of enrollment packs associated with the media
productsarrayArray of products attached to the media

Example

// Get media by slug
const response = await window.FairShareSDK.getMedia("welcome-video");

console.log('Title:', response.media.title);
console.log('Type:', response.media.media_type);
console.log('Thumbnail:', response.media.image_url);

// Access products
response.media.products.forEach(product => {
  console.log('Product:', product.title);
});