This library allows you to easily interact with Media Manager's External APIs.
First you must add the library code to the head
tag.
<script src="mediamanager-external-library-min.js"></script>
Each dependency listed here needs to be added before the Media Manager External Libarary script, like in the example above.
- Media Manager embed library*
- nanoajax
*The Media Manager embed library can be retrieved from this link https://{shortname}.getmediamanager.com/js/mm.embed.v1.min.js
, where {shortname}
is your Media Manager shortname.
This is the subdomain of your Media Manager dashboard URL: https://{shortname}.getmediamanager.com/
.
You will need to set your shortname, this can be done via the client
function.
mediamanager.external.client("{shortname}");
All API functions can be passed a onComplete
function.
function(json, code, request){
}
All responses will be returned as json
.
All responses will be returned in a paged format.
{
current_page: 1,
data: [...],
from: 1,
last_page: 1,
per_page: 24,
to: 5,
total: 5
}
Value for data
is an array
of all the api content. The functions outlined in this document will automatically return the data
.
You may wish to record analytics against your external template so that it appears under the SHOW template
. You can make sure this happens by using the mediamanager.external.embed()
function instead of mediamanager.embed()
.
This function embeds into an element with an id based on the given external template id if no element id is given.
mdiamanager.external.embed("{external_template_id}", "{element_id}"); //element_id is not required
If you do not embed this way, then all analytics will be recorded against the template you provided using mediamanager.template()
only.
<script src="https://{shortname}.getmediamanager.com/js/mm.embed.v1.min.js"></script>
Simply replace {shortname}
with your accounts shortname.
A list of the template APIs that can be used on the external API.
You can get the most viewed videos on template
mediamanager.external.template.getMostViewedVideos(template_id, onComplete, filters);
Params
template_id
: String- A Media Manager Template ID.
onComplete
: Function- Callback for when template videos were retrieved.
filters
: Object- Filters to apply to the API request.
This will return a recommendation based on another video.
mediamanager.external.template.recommendVideo(template_id, video_id, onComplete, filters);
Params
template_id
: String- A Media Manager Template ID.
video_id
: String- A Media Manager Video ID.
onComplete
: Function- Callback for when template videos were retrieved.
filters
: Object- Filters to apply to the API request.
Search videos on given template.
mediamanager.external.template.searchVideos(template_id, term, onComplete, filters);
Params
template_id
: String- A Media Manager Template ID.
term
: String | Array(String)- A string with the term by which to search.
- Or an array of strings, each with a term by which to search.
onComplete
: Function- Callback for when template videos were retrieved.
filters
: Object- Filters to apply to the API request.
Get all videos on a given template.
mediamanager.external.template.getVideos(template_id, onComplete, filters);
Params
template_id
: String- A Media Manager Template ID.
onComplete
: Function- Callback for when template videos were retrieved.
filters
: Object- Filters to apply to the API request.
Get all audios on a given template.
mediamanager.external.template.getAudios(template_id, onComplete, filters);
Params
template_id
: String- A Media Manager Template ID.
onComplete
: Function- Callback for when template videos were retrieved.
filters
: Object- Filters to apply to the API request.
The playlist APIs allow you to get content on a external template, but filter the content down by a playlist.
Get all audio on a given template and playlist.
mediamanager.external.playlist.getAudios(playlist_id, template_id, onComplete, filters);
Params
playlist_id
: String- A Media Manager Playlist ID.
template_id
: String- A Media Manager Template ID.
onComplete
: Function- Callback for when template videos were retrieved.
filters
: Object- Filters to apply to the API request.
Get all audios on a given template and playlist.
mediamanager.external.playlist.getVideos(playlist_id, template_id, onComplete, filters);
Params
playlist_id
: String- A Media Manager Playlist ID.
template_id
: String- A Media Manager Template ID.
onComplete
: Function- Callback for when template videos were retrieved.
filters
: Object- Filters to apply to the API request.
Get video on a given template and playlist.
mediamanager.external.playlist.getVideos(playlist_id, template_id, video_id, onComplete, filters);
Params
playlist_id
: String- A Media Manager Playlist ID.
template_id
: String- A Media Manager Template ID.
video_id
: String- A Media Manager Video ID.
onComplete
: Function- Callback for when template videos were retrieved.
filters
: Object- Filters to apply to the API request.
Get audio on a given template and playlist.
mediamanager.external.playlist.getAudio(playlist_id, template_id, audio_id, onComplete, filters);
Params
playlist_id
: String- A Media Manager Playlist ID.
template_id
: String- A Media Manager Template ID.
audio_id
: String- A Media Manager Audio ID.
onComplete
: Function- Callback for when template videos were retrieved.
filters
: Object- Filters to apply to the API request.
You can also add filters to the API calls by using the addFilter
function. This allows you to filter down your content further. The addFilter
function returns a new instance of the mediamanager.external object with the filterName and filterValue added to its globalFilters property.
mediamanager.external = mediamanager.external.addFilter(filterName, filterValue);
Params
filterName
: String- The key or name of a filter to apply.
filterValue
: String | Number- The value of a filter to apply.
Example
//CHANGE THE API TO RETURN 2 RESULTS PER PAGE.
mediamanager.external = mediamanager.external.addFilter("perPage", 2);
Invalid 'templateID'
An invalid templateID has been passed.
Template is not an external template
The template you have passed is not a "external template".
API Cannot be called from {domain}
External APIs can only be called from the registered domain of the external template.