javascriptnode.jskaltura

Kaltura listAction to return contextData as well


Is there a way when using listAction to get all media entries to also retrieve flavorAssets of those media items? Currently what I am doing is retrieving all media items first, then iterating over each one and using getContextData action on to get flavorAssets for each media entry, which is not very effective and can take a long time. My question is, is there a way to do a Kaltura.services.media.listAction(mediaFilter, pager) while also returning flavorAssets or contextData in this case for each item without the need to call for getContextData action on each media entry?


Solution

  • You can use response profiles to return both the entries and the flavor assets in a single request.

    Here's a raw request that will provide you with want you need, just append a KS:

    http://www.kaltura.com/api_v3/index.php?service=baseEntry&action=list&filter:objectType=KalturaBaseEntryFilter&filter:orderBy=-createdAt&format=1&responseProfile:objectType=KalturaDetachedResponseProfile&responseProfile:fields=id,name&responseProfile:type=1&responseProfile:relatedProfiles:0:objectType=KalturaDetachedResponseProfileArray&responseProfile:relatedProfiles:0:mappings:0:objectType=ResponseProfileMapping&responseProfile:relatedProfiles:0:mappings:0:parentProperty=id&responseProfile:relatedProfiles:0:mappings:0:filterProperty=entryIdEqual&responseProfile:relatedProfiles:0:name=flavorAsset&&responseProfile:relatedProfiles:0:filter:objectType=KalturaFlavorAssetFilter&ks=

    In a more human friendly format:

    service=baseEntry
    action=list
    format=1
    filter:objectType=KalturaBaseEntryFilter
    filter:orderBy=-createdAt
    responseProfile:objectType=KalturaDetachedResponseProfile
    responseProfile:fields=id,name
    responseProfile:type=1
    responseProfile:relatedProfiles:0:objectType=KalturaDetachedResponseProfileArray
    responseProfile:relatedProfiles:0:name=flavorAsset
    responseProfile:relatedProfiles:0:mappings:0:objectType=ResponseProfileMapping
    responseProfile:relatedProfiles:0:mappings:0:parentProperty=id
    responseProfile:relatedProfiles:0:mappings:0:filterProperty=entryIdEqual
    responseProfile:relatedProfiles:0:filter:objectType=KalturaFlavorAssetFilter
    

    I'm not sure if the JavaScript client library support response profiles, the TypeScript client library does support it.