Share on print
Share on facebook
Share on linkedin
Share on whatsapp
Share on email

Overview

The Card API is a JS module that must be included in the startup index.html file of the card template. It provides a set of methods and events to facilitate communication between the host and the card.

Card methods

These are card methods that developers can use to communicate with the card.

Method

Description

Return

subscribeModelUpdate(callback)

Subscribes to model update events by providing a callback

none

subscribeModeChange(callback)

Subscribes to mode update events by providing a callback

none

subscribeToMessages(callback)

Subscribes to all messages from parent window

none

getModel()

Returns the Card model

object

getConfig()

Returns the config object associated with the template. The config includes player properties that are passed at runtime.

object

getMode()

Returns the Card display mode (e.g. TV, Mobile)

string

isEditing()

Returns true or false depending on whether the card is being edited

boolean

getThemeProperty(propertyName)

Returns a theme property value (e.g. “default font”)

string

getModelProperty(propertyName)

Returns a specific model property by name

object

notifyOnLoad()

Raises an event to the host that the Card has loaded

none

notifyOnComplete()

Raises an event to the host that the Card has completed

none

notifyOnError()

Raises an event to the host that there was a problem loading or displaying the card

none

postMessage(message)

Raise post message to be use by all supported devices (default is window.postMessage)

none

subscribeToSchemaUpdate(callback)

Subscribes to schema update events by providing a callback

none

getSchema()

Returns the schema

object

isPreview()

Returns true or false depending on whether the card is in preview mode

boolean

getPlaybackContext()

Returns the current context of the card (editing, themeediting, screenshot, themescreenshot, device, preview, none)

string

Host methods

These are methods that are used from the card to interact with the host container.

Method

Description

Return

api.xhr(url, settings)

to make an XHR call

result of the XHR

api.httpRequest(url, settings)

to make an http request

result of API call

api.updateModelInput(input)

update the model(model.json)

none

api.updateModelCustomData(customData)

update the custom data section inside model.json

none

api.updateModelRuntimeConfiguration()

update the runtime config(model.json)

none

api.getPassports(criteria)

to retrieve passports available to the card

passport(paged result)

api.requestConstellationService(relativeURL, settings)

used to make calls to Appspace APIs

result of API call

api.requestCloudService(serviceName, relativeURL, settings)

used to make calls to Appspace Cloud service APIs

result of API call