mercury-sdk-js

0.169.0 • Public • Published

Mercury Javascript SDK

This is an SDK that wraps calls to the Discovery APIs. The SDK exposes an object with classes that represent API groups. Each class will have a number of name-spaced methods that return promises with data from APIs in that group. Each class will also expose some common methods for hateoas support, using the auth tools against additional endpoints, and affiliate login/logut functionality. See the documentation below for a complete list of methods.

SDK Development

Requirements:

  • node and npm

Getting started:

  • clone the repo
  • run $ npm install
  • see package.json for a list of npm scripts

Adding SDK to your project

Requirements:

  • node and npm

Getting started:

  • install with npm - npm install @discodigital/mercury-sdk-js --save

Developing Locally:

If you'd like to use this package locally to make changes and use in your project, you can create a link through npm from the root of your project:

  • npm link ../path/to/mercury-sdk-js @discodigital/mercury-sdk-js@0.<version>.0

Note: If you are linking the mercury-sdk-js package into a react project and that react project is using react-hot loader, then you will need to explicitly tell it to ignore the mercury-sdk-js package when it does its transformation. You can do this in the webpack.config.js where you have defined the loader for react-hot. You'll need to add mercury-sdk-js to the exclude:

{
    test: /\.jsx?$/,
    loaders: ['react-hot', 'babel?cacheDirectory'], // support HMR
    exclude: [/node_modules/, /mercury-sdk-js/],
},

Base Class functionality

All of the API group classes are built on top of a base class that provides the shared functionality. The primary differences between API group classes are defined by their config sections, thus most of the functionality resides in the base class.

Constructor

new SDKBase(options, child)

Create a base class instance.

Parameters:

Name Type Description
`options` object (required) the options passed from the child class constructor.
Name Type Description
`apiBase` string (required) the base url of the api group you want to consume.
`clientId` string (required) the clientId issued to your app by the services team.
`authentication` 'anonymous' | 'affiliate' (optional) the authentication type you'll use for the class instance.
`anonymousProxy` string (optional) a local proxy for anonymous authentication, this lets the SDK avoid using iframes.
`affiliateProxy` string (optional) a local proxy for affiliate authentication, this lets the SDK avoid using iframes.
`loginStyle` 'window' | 'popup' | 'tab' (optional) whether affiliate auth should happen in a the same window, a popup or a new tab default is window
`code` string (optional) the code that is passed back from oauth re-direct
`version` string (optional) the api version you want to use, defaults to v1
`networksCode` string (optional) the id of the network or network group, used to trim the affiliate list down
`child` string (required) the child class name, used to reference the right config data.

Properties:

Name Type Description
`config` object the configuration options passed in
`auth` object an object that will hold the sdk instances auth token and metadata
`isAuthenticated` boolean a flag that represents the current auth state
`hateoas` object an object that holds several methods for following hateoas links

Methods

destroy()

Used by client apps to remove any listeners or maps that may prevent the instance from being garbage collected
Example

classInstance.destroy();

fetchWithAuth(url, options) → {Promise}

This exposes the internal fetchWithAuth method for client apps using the SDKBase it allows for add hoc calls to apis with auth support and could be useful for APIs that aren't included in the SDK yet
Parameters:

Name Type Description
`url` string (required) the url of the fetch request (same as in normal window.fetch)
`options` object (optional) the fetch options (same as in normal window.fetch)

Returns:
a Promise resolving with the json data from the api called, parsed to add HATEOS link functions
Example

classInstance.fetchWithAuth('https://my-dev-apis/v1/someendpoint', { method: 'GET' })
    .then(resp => {
        //your data is in resp.headers and resp.body
    });

getAffiliates() → {Promise}

Used by client apps to get a list of affiliates to choose from in affilate auth
Returns:
a Promise resolving with an array of affiliate objects
Example

classInstance.getAffiliates()
    .then(resp => {
        // affiliates list is in resp.body
    });

hateoas.fetch(linksArray, targetRel, parameters) → {Promise}

The hateoas.fetch function allows the client app to pass in a group of hateoas links and make a call to one of them by it's rel name
Parameters:

Name Type Description
`linksArray` array the hateoas links to use
`targetRel` string the rel of the link the app wants to call
`parameters` object the parameters to fill out the url template with and to add additional params to the querystring (or body if "POST") of the fetch call

Returns:
a call to the fetchWithAuth function provided
Example

const linksArray = [
    {
        rel: 'next',
        href: 'https://myapi.com/v1/something?offset=10&platform={platform}',
    },
];

classInstance.hateoas.fetchLink(linksArray, 'next', { platform: 'desktop' })
    .then(resp => {
        //your hateoas link data is in resp.body, there maybe be hateoas links in resp.headers
    });

hateoas.namedResource(configurationsParams, resourceName, resourceParams) → {Promise}

The hateoas.namedResource function will get the configuration for the app defined in the first argument and call one of it's links
Parameters:

Name Type Description
`configurationsParams` object the params used to call the configurations api
`resourceName` string the name of the link in the configuration you want to call
`resourceParams` object the object used in calling hateoas.fetch()

Returns:
a call to hateoas.fetch()
Example

classInstance.hateoas.namedResource({ id: 'dgo', key: 'test' }, 'featured', { platform: 'desktop' })
    .then(resp => {
        // your named resource data is in resp.body, there maybe be hateoas links in resp.headers
    });

logOff()

Used by client apps to log out of affiliate auth
Example

classInstance.logOff()
    .then(() => {
        // logoff is now complete
    });

setAffiliate(affiliateObject)

Used by client apps to initialize affiliate auth once an affiliate is chosen by the user
Parameters:

Name Type Description
`affiliateObject` object (required) the complete affiliate object that came from getAffiliates()

Example

classInstance.setAffiliate({ authClientId:"thr030", links:[], etc });

setAuth(authObj, affiliateLink)

Used by the classes or client applications
Parameters:

Name Type Description
`authObj` object (required) this should hold the data that comes from the oauth service, most importantly access_token
`affiliateLink` string (optional) the hateoas link for affiliate auth

Example

classInstance.setAuth({ access_token: '154345234523452345453425.452345243523.2345234' });

API Group: Discovery REST APIs

Constructor

new SDK.Drapi(options)

Create a Drapi class instance.

Parameters:

Name Type Description
`options` object (required) constructor options.
Name Type Description
`apiBase` string (required) the base url of the api group you want to consume.
`clientId` string (required) the clientId issued to your app by the services team.
`authentication` 'anonymous' | 'affiliate' (optional, defaults to anonymous) the authentication type you'll use for the class instance.
`anonymousProxy` string (optional) a local proxy for anonymous authentication, this lets the SDK avoid using iframes.
`loginStyle` 'window' | 'popup' | 'tab' (optional) whether affiliate auth should happen in a the same window, a popup or a new SDK.tab default is window
`version` string (optional) the api version you want to use, defaults to v1
`networksCode` string (optional) the id of the network or network group, used to trim the affiliate list down

Example

const classInstance = new SDK.Drapi({
  apiBase: ' https://api.discovery.com.qa-bsidelinger.i.dsc.tv',
  clientId: '12345234tsdfg43256',
});

Methods

Affiliates.find(parameters) → {Promise}

Find all Affiliates

Parameters:

Name Type Description
`parameters` object
Name Type Description
`type` string (optional) Filter
`name` string (optional) Filter (regex)
`platform` string (optional) Platform Name (e.g. desktop)
`networks.id` string (optional) Filter
`networks.code` string (optional) Filter
`sort` string (optional) Fields Supported: [rank, name]
`limit` integer (optional) Max Resource Count. *Page size
`offset` integer (optional) Resource index. *Zero-based
`fields` string (optional) Resource fields returned in API resource response
`xfields` string (optional) Resource fields excluded from API resource response
`xid` string (optional) Resource models excluded from API resource response based on content id
`embed` string (optional) Ability to expand referenced/embedded collection item types(e.g. API Collections: networks, show, genres, subgenres, season)

Example

classInstance.Affiliates.find()
    .then(resp => {
        // your data is in resp.headers and resp.body
    })
    .catch(err => {
        // error handling
    });

Affiliates.find(parameters) → {Promise}

Find one Affiliate

Parameters:

Name Type Description
`parameters` object
Name Type Description
`id` string (required) Affiliate ID
`fields` string (optional) Resource fields returned in API resource response
`xfields` string (optional) Resource fields excluded from API resource response
`embed` string (optional) Ability to expand referenced/embedded collection item types(e.g. API Collections: networks, show, genres, subgenres, season)

Example

classInstance.Affiliates.find({id: 'string'})
    .then(resp => {
        // your data is in resp.headers and resp.body
    })
    .catch(err => {
        // error handling
    });

Bios.find(parameters) → {Promise}

Find all Bios

Parameters:

Name Type Description
`parameters` object
Name Type Description
`name` string (optional) Filter (regex)
`slug` string (optional) Filter
`rank` string (optional) Filter
`show.id` string (optional) Filter
`sort` string (optional) Fields Supported: [name, slug, rank, show.id]
`limit` integer (optional) Max Resource Count. *Page size
`offset` integer (optional) Resource index. *Zero-based
`fields` string (optional) Resource fields returned in API resource response
`xfields` string (optional) Resource fields excluded from API resource response
`xid` string (optional) Resource models excluded from API resource response based on content id
`xslug` string (optional) Resource models excluded from API resource response based on content slug
`embed` string (optional) Ability to expand referenced/embedded collection item types(e.g. API Collections: networks, show, genres, subgenres, season)

Example

classInstance.Bios.find()
    .then(resp => {
        // your data is in resp.headers and resp.body
    })
    .catch(err => {
        // error handling
    });

Bios.find(parameters) → {Promise}

Find one Bio

Parameters:

Name Type Description
`parameters` object
Name Type Description
`id` string (required) Bio ID
`fields` string (optional) Resource fields returned in API resource response
`xfields` string (optional) Resource fields excluded from API resource response
`embed` string (optional) Ability to expand referenced/embedded collection item types(e.g. API Collections: networks, show, genres, subgenres, season)

Example

classInstance.Bios.find({id: 'string'})
    .then(resp => {
        // your data is in resp.headers and resp.body
    })
    .catch(err => {
        // error handling
    });

Collections.find(parameters) → {Promise}

Find all Collections

Parameters:

Name Type Description
`parameters` object
Name Type Description
`platform` string (required) Platform Name (e.g. desktop)
`type` string (required) Collection Type (all|network)
`slug` string (optional) Filter
`network.id` string (optional) Filter
`network.code` string (optional) Filter
`embed` string (optional) Ability to expand collection item types. Embedded Object Attributes of Video and Show API Collections(e.g. networks, show, genres, subgenres, season)
`limit` integer (optional) Max Resource Count. *Page size
`offset` integer (optional) Resource index. *Zero-based
`fields` string (optional) Resource fields returned in API resource response
`xfields` string (optional) Resource fields excluded from API resource response
`xid` string (optional) Resource models excluded from API resource response based on content id
`xslug` string (optional) Resource models excluded from API resource response based on content slug

Example

classInstance.Collections.find({platform: 'string', type: 'string'})
    .then(resp => {
        // your data is in resp.headers and resp.body
    })
    .catch(err => {
        // error handling
    });

Collections.find(parameters) → {Promise}

Find one Collection

Parameters:

Name Type Description
`parameters` object
Name Type Description
`id` string (required) Collection ID
`platform` string (optional) Platform Name (e.g. desktop) to filter resource Alternate Images, if applicable
`fields` string (optional) Resource fields returned in API resource response
`xfields` string (optional) Resource fields excluded from API resource response
`embed` string (optional) Ability to expand referenced/embedded collection item types(e.g. API Collections: networks, show, genres, subgenres, season)

Example

classInstance.Collections.find({id: 'string'})
    .then(resp => {
        // your data is in resp.headers and resp.body
    })
    .catch(err => {
        // error handling
    });

Configurations.find(parameters) → {Promise}

Find all Configurations

Parameters:

Name Type Description
`parameters` object
Name Type Description
`id` string (required) your apps ID
`key` string (required)

Example

classInstance.Configurations.find({ id: 'dgo', key: 'test' })
    .then(resp => {
        // use your data
    })
    .catch(err => {
        // error handling
    });

Curatedlists.find(parameters) → {Promise}

Find all Curatedlists

Parameters:

Name Type Description
`parameters` object
Name Type Description
`name` string (optional) Filter (regex)
`slug` string (optional) Filter
`sort` string (optional) Fields Supported: [name, slug]
`platform` string (optional) Platform Name (e.g. desktop) to filter resource Alternate Images, if applicable
`limit` integer (optional) Max Resource Count. *Page size
`offset` integer (optional) Resource index. *Zero-based
`fields` string (optional) Resource fields returned in API resource response
`xfields` string (optional) Resource fields excluded from API resource response
`xid` string (optional) Resource models excluded from API resource response based on content id
`xslug` string (optional) Resource models excluded from API resource response based on content slug
`embed` string (optional) Ability to expand referenced/embedded collection item types(e.g. API Collections: networks, show, genres, subgenres, season)

Example

classInstance.Curatedlists.find()
    .then(resp => {
        // your data is in resp.headers and resp.body
    })
    .catch(err => {
        // error handling
    });

Curatedlists.find(parameters) → {Promise}

Find one Curatedlist

Parameters:

Name Type Description
`parameters` object
Name Type Description
`id` string (required) Curatedlist ID
`platform` string (optional) Platform Name (e.g. desktop) to filter resource Alternate Images, if applicable
`fields` string (optional) Resource fields returned in API resource response
`xfields` string (optional) Resource fields excluded from API resource response
`embed` string (optional) Ability to expand referenced/embedded collection item types(e.g. API Collections: networks, show, genres, subgenres, season)

Example

classInstance.Curatedlists.find({id: 'string'})
    .then(resp => {
        // your data is in resp.headers and resp.body
    })
    .catch(err => {
        // error handling
    });

Featured.find(parameters) → {Promise}

Find all Featured

Parameters:

Name Type Description
`parameters` object
Name Type Description
`platform` string (required) Platform Name (e.g. desktop)
`type` string (required) Collection Type (all|network)
`network.id` string (optional) Filter
`network.code` string (optional) Filter
`embed` string (optional) Ability to expand collection item types. Embedded Object Attributes of Video and Show API Collections(e.g. networks, show, genres, subgenres, season)
`limit` integer (optional) Max Resource Count. *Page size
`offset` integer (optional) Resource index. *Zero-based
`fields` string (optional) Resource fields returned in API resource response
`xfields` string (optional) Resource fields excluded from API resource response

Example

classInstance.Featured.find({platform: 'string', type: 'string'})
    .then(resp => {
        // your data is in resp.headers and resp.body
    })
    .catch(err => {
        // error handling
    });

FeaturedPage.find(parameters) → {Promise}

Find all FeaturedPage

Parameters:

Name Type Description
`parameters` object
Name Type Description
`platform` string (required) Platform Name (e.g. desktop)
`type` string (required) Collection Type (all|network)
`network.id` string (optional) Filter
`network.code` string (optional) Filter
`embed` string (optional) Ability to expand collection item types. Embedded Object Attributes of Video and Show API Collections(e.g. networks, show, genres, subgenres, season)
`limit` integer (optional) Max Resource Count. *Page size
`offset` integer (optional) Resource index. *Zero-based
`fields` string (optional) Resource fields returned in API resource response
`xfields` string (optional) Resource fields excluded from API resource response

Example

classInstance.FeaturedPage.find({platform: 'string', type: 'string'})
    .then(resp => {
        // your data is in resp.headers and resp.body
    })
    .catch(err => {
        // error handling
    });

Genres.find(parameters) → {Promise}

Find all Genres

Parameters:

Name Type Description
`parameters` object
Name Type Description
`name` string (optional) Filter (regex)
`slug` string (optional) Filter
`networks.id` string (optional) Filter
`networks.code` string (optional) Filter
`sort` string (optional) Fields Supported: [name, slug]
`platform` string (optional) Platform Name (e.g. desktop) to filter resource Alternate Images, if applicable
`limit` integer (optional) Max Resource Count. *Page size
`offset` integer (optional) Resource index. *Zero-based
`fields` string (optional) Resource fields returned in API resource response
`xfields` string (optional) Resource fields excluded from API resource response
`xid` string (optional) Resource models excluded from API resource response based on content id
`xslug` string (optional) Resource models excluded from API resource response based on content slug
`embed` string (optional) Ability to expand referenced/embedded collection item types(e.g. API Collections: networks, show, genres, subgenres, season)

Example

classInstance.Genres.find()
    .then(resp => {
        // your data is in resp.headers and resp.body
    })
    .catch(err => {
        // error handling
    });

Genres.find(parameters) → {Promise}

Find one Genre

Parameters:

Name Type Description
`parameters` object
Name Type Description
`id` string (required) Genre ID
`platform` string (optional) Platform Name (e.g. desktop) to filter resource Alternate Images, if applicable
`fields` string (optional) Resource fields returned in API resource response
`xfields` string (optional) Resource fields excluded from API resource response
`embed` string (optional) Ability to expand referenced/embedded collection item types(e.g. API Collections: networks, show, genres, subgenres, season)

Example

classInstance.Genres.find({id: 'string'})
    .then(resp => {
        // your data is in resp.headers and resp.body
    })
    .catch(err => {
        // error handling
    });

Layouts.find(parameters) → {Promise}

Find all Layouts

Parameters:

Name Type Description
`parameters` object
Name Type Description
`platform` string (required) Platform Name (e.g. desktop)
`name` string (optional) Filter (regex)
`slug` string (optional) Filter
`type` string (optional) Filter
`networks.id` string (optional) Filter
`networks.code` string (optional) Filter
`show.slug` string (optional) Filter
`video.slug` string (optional) Filter
`livestream.slug` string (optional) Filter
`curatedlist.slug` string (optional) Filter
`collection.slug` string (optional) Filter
`sort` string (optional) Fields Supported: [name, slug, type, networks.id, networks.code]
`limit` integer (optional) Max Resource Count. *Page size
`offset` integer (optional) Resource index. *Zero-based
`fields` string (optional) Resource fields returned in API resource response
`xfields` string (optional) Resource fields excluded from API resource response
`embed` string (optional) Ability to expand referenced/embedded collection item types(e.g. API Collections: networks, show, genres, subgenres, season)

Example

classInstance.Layouts.find({platform: 'string'})
    .then(resp => {
        // your data is in resp.headers and resp.body
    })
    .catch(err => {
        // error handling
    });

Layouts.find(parameters) → {Promise}

Find one Layout

Parameters:

Name Type Description
`parameters` object
Name Type Description
`id` string (required) Layout ID
`platform` string (required) Platform Name (e.g. desktop)
`fields` string (optional) Resource fields returned in API resource response
`xfields` string (optional) Resource fields excluded from API resource response
`embed` string (optional) Ability to expand referenced/embedded collection item types(e.g. API Collections: networks, show, genres, subgenres, season)

Example

classInstance.Layouts.find({id: 'string', platform: 'string'})
    .then(resp => {
        // your data is in resp.headers and resp.body
    })
    .catch(err => {
        // error handling
    });

Livestreams.find(parameters) → {Promise}

Find one Livestream

Parameters:

Name Type Description
`parameters` object
Name Type Description
`id` string (required) Livestream ID
`fields` string (optional) Resource fields returned in API resource response
`xfields` string (optional) Resource fields excluded from API resource response
`embed` string (optional) Ability to expand referenced/embedded collection item types(e.g. API Collections: networks, show, genres, subgenres, season)

Example

classInstance.Livestreams.find({id: 'string'})
    .then(resp => {
        // your data is in resp.headers and resp.body
    })
    .catch(err => {
        // error handling
    });

Livestreams.find(parameters) → {Promise}

Find all Livestreams

Parameters:

Name Type Description
`parameters` object
Name Type Description
`authenticated` boolean (optional) Filter
`slug` string (optional) Filter
`networks.id` string (optional) Filter
`networks.code` string (optional) Filter
`sort` string (optional) Fields Supported: [slug, authenticated, rank, networks.id, networks.code]
`limit` integer (optional) Max Resource Count. *Page size
`offset` integer (optional) Resource index. *Zero-based
`fields` string (optional) Resource fields returned in API resource response
`xfields` string (optional) Resource fields excluded from API resource response
`xid` string (optional) Resource models excluded from API resource response based on content id
`xslug` string (optional) Resource models excluded from API resource response based on content slug
`embed` string (optional) Ability to expand referenced/embedded collection item types(e.g. API Collections: networks, show, genres, subgenres, season)

Example

classInstance.Livestreams.find()
    .then(resp => {
        // your data is in resp.headers and resp.body
    })
    .catch(err => {
        // error handling
    });

Menus.find(parameters) → {Promise}

Find all Menus

Parameters:

Name Type Description
`parameters` object
Name Type Description
`name` string (optional) Filter (regex)
`type` string (optional) Filter
`shows.id` string (optional) Filter
`networks.id` string (optional) Filter
`networks.code` string (optional) Filter
`sort` string (optional) Fields Supported: [name, type, networks.id, networks.code, shows.id]
`limit` integer (optional) Max Resource Count. *Page size
`offset` integer (optional) Resource index. *Zero-based
`fields` string (optional) Resource fields returned in API resource response
`xfields` string (optional) Resource fields excluded from API resource response
`xid` string (optional) Resource models excluded from API resource response based on content id
`embed` string (optional) Ability to expand referenced/embedded collection item types(e.g. API Collections: networks, show, genres, subgenres, season)

Example

classInstance.Menus.find()
    .then(resp => {
        // your data is in resp.headers and resp.body
    })
    .catch(err => {
        // error handling
    });

Menus.find(parameters) → {Promise}

Find one Menu

Parameters:

Name Type Description
`parameters` object
Name Type Description
`id` string (required) Menu ID
`fields` string (optional) Resource fields returned in API resource response
`xfields` string (optional) Resource fields excluded from API resource response
`embed` string (optional) Ability to expand referenced/embedded collection item types(e.g. API Collections: networks, show, genres, subgenres, season)

Example

classInstance.Menus.find({id: 'string'})
    .then(resp => {
        // your data is in resp.headers and resp.body
    })
    .catch(err => {
        // error handling
    });

Moreepisodes.find(parameters) → {Promise}

Find all Moreepisodes

Parameters:

Name Type Description
`parameters` object
Name Type Description
`platform` string (required) Platform Name (e.g. desktop)
`video.id` string (required) Filter
`curatedlist.id` string (optional) Filter
`networks.id` string (optional) Filter
`networks.code` string (optional) Filter
`embed` string (optional) Ability to expand collection item types. Embedded Object Attributes of Video API Collections(e.g. networks, genres, subgenres, seasons)
`limit` integer (optional) Max Resource Count. *Page size
`offset` integer (optional) Resource index. *Zero-based
`fields` string (optional) Resource fields returned in API resource response
`xfields` string (optional) Resource fields excluded from API resource response
`embed.limit` integer (optional) Max Embedded Resource Count(Videos|Shows). *Page size. Only applies to editorial collections leveraging queries.
`embed.offset` integer (optional) Embedded Resource index(Videos|Shows). *Zero-based. Only applies to editorial collections leveraging queries.

Example

classInstance.Moreepisodes.find({platform: 'string', video.id: 'string'})
    .then(resp => {
        // your data is in resp.headers and resp.body
    })
    .catch(err => {
        // error handling
    });

Moreshows.find(parameters) → {Promise}

Find all Moreshows

Parameters:

Name Type Description
`parameters` object
Name Type Description
`platform` string (required) Platform Name (e.g. desktop)
`show.id` string (required) Filter
`networks.id` string (optional) Filter
`networks.code` string (optional) Filter
`embed` string (optional) Ability to expand collection item types. Embedded Object Attributes of Show API Collections(e.g. networks, genres, subgenres)
`limit` integer (optional) Max Resource Count. *Page size
`offset` integer (optional) Resource index. *Zero-based
`fields` string (optional) Resource fields returned in API resource response
`xfields` string (optional) Resource fields excluded from API resource response
`embed.limit` integer (optional) Max Embedded Resource Count(Videos|Shows). *Page size. Only applies to editorial collections leveraging queries.
`embed.offset` integer (optional) Embedded Resource index(Videos|Shows). *Zero-based. Only applies to editorial collections leveraging queries.

Example

classInstance.Moreshows.find({platform: 'string', show.id: 'string'})
    .then(resp => {
        // your data is in resp.headers and resp.body
    })
    .catch(err => {
        // error handling
    });

Networks.find(parameters) → {Promise}

Find one Network

Parameters:

Name Type Description
`parameters` object
Name Type Description
`id` string (required) Network ID
`platform` string (optional) Platform Name (e.g. desktop) to filter resource Alternate Images, if applicable
`fields` string (optional) Resource fields returned in API resource response
`xfields` string (optional) Resource fields excluded from API resource response
`embed` string (optional) Ability to expand referenced/embedded collection item types(e.g. API Collections: networks, show, genres, subgenres, season)

Example

classInstance.Networks.find({id: 'string'})
    .then(resp => {
        // your data is in resp.headers and resp.body
    })
    .catch(err => {
        // error handling
    });

Networks.find(parameters) → {Promise}

Find all Networks

Parameters:

Name Type Description
`parameters` object
Name Type Description
`name` string (optional) Filter (regex)
`slug` string (optional) Filter
`code` string (optional) Filter
`sort` string (optional) Fields Supported: [name,slug,code,rank]
`platform` string (optional) Platform Name (e.g. desktop) to filter resource Alternate Images, if applicable
`limit` integer (optional) Max Resource Count. *Page size
`offset` integer (optional) Resource index. *Zero-based
`fields` string (optional) Resource fields returned in API resource response
`xfields` string (optional) Resource fields excluded from API resource response
`xid` string (optional) Resource models excluded from API resource response based on content id
`xslug` string (optional) Resource models excluded from API resource response based on content slug
`embed` string (optional) Ability to expand referenced/embedded collection item types(e.g. API Collections: networks, show, genres, subgenres, season)

Example

classInstance.Networks.find()
    .then(resp => {
        // your data is in resp.headers and resp.body
    })
    .catch(err => {
        // error handling
    });

Popular.find(parameters) → {Promise}

Find all Popular

Parameters:

Name Type Description
`parameters` object
Name Type Description
`platform` string (required) Platform Name (e.g. desktop)
`type` string (required) Collection Type (all|network)
`network.id` string (optional) Filter
`network.code` string (optional) Filter
`embed` string (optional) Ability to expand collection item types. Embedded Object Attributes of Video and Show API Collections(e.g. networks, show, genres, subgenres, season)
`limit` integer (optional) Max Resource Count. *Page size
`offset` integer (optional) Resource index. *Zero-based
`fields` string (optional) Resource fields returned in API resource response
`xfields` string (optional) Resource fields excluded from API resource response

Example

classInstance.Popular.find({platform: 'string', type: 'string'})
    .then(resp => {
        // your data is in resp.headers and resp.body
    })
    .catch(err => {
        // error handling
    });

Promos.find(parameters) → {Promise}

Find all Promos

Parameters:

Name Type Description
`parameters` object
Name Type Description
`name` string (optional) Filter (regex)
`type` string (optional) Filter
`sort` string (optional) Fields Supported: [name, type]
`limit` integer (optional) Max Resource Count. *Page size
`offset` integer (optional) Resource index. *Zero-based
`fields` string (optional) Resource fields returned in API resource response
`xfields` string (optional) Resource fields excluded from API resource response
`xid` string (optional) Resource models excluded from API resource response based on content id
`embed` string (optional) Ability to expand referenced/embedded collection item types(e.g. API Collections: networks, show, genres, subgenres, season)

Example

classInstance.Promos.find()
    .then(resp => {
        // your data is in resp.headers and resp.body
    })
    .catch(err => {
        // error handling
    });

Promos.find(parameters) → {Promise}

Find one Promo

Parameters:

Name Type Description
`parameters` object
Name Type Description
`id` string (required) Promo ID
`fields` string (optional) Resource fields returned in API resource response
`xfields` string (optional) Resource fields excluded from API resource response
`embed` string (optional) Ability to expand referenced/embedded collection item types(e.g. API Collections: networks, show, genres, subgenres, season)

Example

classInstance.Promos.find({id: 'string'})
    .then(resp => {
        // your data is in resp.headers and resp.body
    })
    .catch(err => {
        // error handling
    });

Recent.find(parameters) → {Promise}

Find all Recent

Parameters:

Name Type Description
`parameters` object
Name Type Description
`platform` string (required) Platform Name (e.g. desktop)
`type` string (required) Collection Type (all|network)
`network.id` string (optional) Filter
`network.code` string (optional) Filter
`embed` string (optional) Ability to expand collection item types. Embedded Object Attributes of Video and Show API Collections(e.g. networks, show, genres, subgenres, season)
`limit` integer (optional) Max Resource Count. *Page size
`offset` integer (optional) Resource index. *Zero-based
`fields` string (optional) Resource fields returned in API resource response
`xfields` string (optional) Resource fields excluded from API resource response
`embed.limit` integer (optional) Max Embedded Resource Count(Videos|Shows). *Page size. Only applies to editorial collections leveraging queries.
`embed.offset` integer (optional) Embedded Resource index(Videos|Shows). *Zero-based. Only applies to editorial collections leveraging queries.

Example

classInstance.Recent.find({platform: 'string', type: 'string'})
    .then(resp => {
        // your data is in resp.headers and resp.body
    })
    .catch(err => {
        // error handling
    });

Recommended.find(parameters) → {Promise}

Find all Recommended

Parameters:

Name Type Description
`parameters` object
Name Type Description
`platform` string (required) Platform Name (e.g. desktop)
`type` string (required) Collection Type (all|network)
`network.id` string (optional) Filter
`network.code` string (optional) Filter
`embed` string (optional) Ability to expand collection item types. Embedded Object Attributes of Video and Show API Collections(e.g. networks, show, genres, subgenres, season)
`limit` integer (optional) Max Resource Count. *Page size
`offset` integer (optional) Resource index. *Zero-based
`fields` string (optional) Resource fields returned in API resource response
`xfields` string (optional) Resource fields excluded from API resource response

Example

classInstance.Recommended.find({platform: 'string', type: 'string'})
    .then(resp => {
        // your data is in resp.headers and resp.body
    })
    .catch(err => {
        // error handling
    });

Search.find(parameters) → {Promise}

Find all Search

Parameters:

Name Type Description
`parameters` object
Name Type Description
`term` string (required) The search term to search for. This will match a partial search, e.g. searching 'Bear' will return entires containing 'Bear Grylls'.
`networks.code` string (optional) Filter results by pipe-delimited list of network codes
`limit` integer (optional) Max Resource Count. *Page size
`page` integer (optional) Page index. *Zero-based

Example

classInstance.Search.find({term: 'string'})
    .then(resp => {
        // your data is in resp.headers and resp.body
    })
    .catch(err => {
        // error handling
    });

Seasons.find(parameters) → {Promise}

Find all Seasons

Parameters:

Name Type Description
`parameters` object
Name Type Description
`show.id` string (optional) Filter
`number` integer (optional) Filter
`excludeEmptySeasons` boolean (optional) Filter
`sort` string (optional) Fields Supported: [show.id,number]
`platform` string (optional) Platform Name (e.g. desktop) to filter resource Alternate Images, if applicable
`limit` integer (optional) Max Resource Count. *Page size
`offset` integer (optional) Resource index. *Zero-based
`fields` string (optional) Resource fields returned in API resource response
`xfields` string (optional) Resource fields excluded from API resource response
`xid` string (optional) Resource models excluded from API resource response based on content id
`embed` string (optional) Ability to expand referenced/embedded collection item types(e.g. API Collections: networks, show, genres, subgenres, season)

Example

classInstance.Seasons.find()
    .then(resp => {
        // your data is in resp.headers and resp.body
    })
    .catch(err => {
        // error handling
    });

Seasons.find(parameters) → {Promise}

Find one Season

Parameters:

Name Type Description
`parameters` object
Name Type Description
`id` string (required) Season ID
`platform` string (optional) Platform Name (e.g. desktop) to filter resource Alternate Images, if applicable
`fields` string (optional) Resource fields returned in API resource response
`xfields` string (optional) Resource fields excluded from API resource response
`embed` string (optional) Ability to expand referenced/embedded collection item types(e.g. API Collections: networks, show, genres, subgenres, season)

Example

classInstance.Seasons.find({id: 'string'})
    .then(resp => {
        // your data is in resp.headers and resp.body
    })
    .catch(err => {
        // error handling
    });

ShowCounts.find(parameters) → {Promise}

Find all ShowCounts

Parameters:

Name Type Description
`parameters` object
Name Type Description
`networks.id` string (optional) Filter
`networks.code` string (optional) Filter

Example

classInstance.ShowCounts.find()
    .then(resp => {
        // your data is in resp.headers and resp.body
    })
    .catch(err => {
        // error handling
    });

ShowPage.find(parameters) → {Promise}

Find one ShowPag

Parameters:

Name Type Description
`parameters` object
Name Type Description
`id` string (required) Show ID
`platform` string (required) Platform Name (e.g. desktop)
`show.id` string (required) Filter
`networks.id` string (optional) Filter
`networks.code` string (optional) Filter
`fields` string (optional) Resource fields returned in API resource response
`xfields` string (optional) Resource fields excluded from API resource response
`embed` string (optional) Ability to expand referenced/embedded collection item types(e.g. API Collections: networks, show, genres, subgenres, season)

Example

classInstance.ShowPage.find({id: 'string', platform: 'string', show.id: 'string'})
    .then(resp => {
        // your data is in resp.headers and resp.body
    })
    .catch(err => {
        // error handling
    });

Shows.find(parameters) → {Promise}

Find all Shows

Parameters:

Name Type Description
`parameters` object
Name Type Description
`name` string (optional) Filter (regex)
`slug` string (optional) Filter
`type` string (optional) Filter
`networks.id` string (optional) Filter
`networks.code` string (optional) Filter
`genres.id` string (optional) Filter
`subgenres.id` string (optional) Filter
`status` string (optional) Filter
`sort` string (optional) Fields Supported: [networks.id, genres.id, subgenres.id, name, slug, video.airDate, video.episode.airDate, video.clip.airDate, video.preview.airDate, video.airDate.type(*)]
`platform` string (optional) Platform Name (e.g. desktop) to filter resource Alternate Images, if applicable
`limit` integer (optional) Max Resource Count. *Page size
`offset` integer (optional) Resource index. *Zero-based
`fields` string (optional) Resource fields returned in API resource response
`xfields` string (optional) Resource fields excluded from API resource response
`xid` string (optional) Resource models excluded from API resource response based on content id
`xslug` string (optional) Resource models excluded from API resource response based on content slug
`embed` string (optional) Ability to expand referenced/embedded collection item types(e.g. API Collections: networks, show, genres, subgenres, season)

Example

classInstance.Shows.find()
    .then(resp => {
        // your data is in resp.headers and resp.body
    })
    .catch(err => {
        // error handling
    });

Shows.find(parameters) → {Promise}

Find one Show

Parameters:

Name Type Description
`parameters` object
Name Type Description
`id` string (required) Show ID
`platform` string (optional) Platform Name (e.g. desktop) to filter resource Alternate Images, if applicable
`fields` string (optional) Resource fields returned in API resource response
`xfields` string (optional) Resource fields excluded from API resource response
`embed` string (optional) Ability to expand referenced/embedded collection item types(e.g. API Collections: networks, show, genres, subgenres, season)

Example

classInstance.Shows.find({id: 'string'})
    .then(resp => {
        // your data is in resp.headers and resp.body
    })
    .catch(err => {
        // error handling
    });

Shows.find(parameters) → {Promise}

Find one Show

Parameters:

Name Type Description
`parameters` object
Name Type Description
`id` string (required) Comma-delimited list of show ids
`platform` string (optional) Platform Name (e.g. desktop) to filter resource Alternate Images, if applicable
`limit` integer (optional) Max Resource Count. *Page size
`offset` integer (optional) Resource index. *Zero-based
`fields` string (optional) Resource fields returned in API resource response
`xfields` string (optional) Resource fields excluded from API resource response
`embed` string (optional) Ability to expand referenced/embedded collection item types(e.g. API Collections: networks, show, genres, subgenres, season)

Example

classInstance.Shows.find({id: 'string'})
    .then(resp => {
        // your data is in resp.headers and resp.body
    })
    .catch(err => {
        // error handling
    });

Streaming.find(parameters) → {Promise}

Find all Streaming

Parameters:

Name Type Description
`parameters` object
Name Type Description
`livestreamId` string (required) LiveStream ID

Example

classInstance.Streaming.find({livestreamId: 'string'})
    .then(resp => {
        // your data is in resp.headers and resp.body
    })
    .catch(err => {
        // error handling
    });

Streaming.find(parameters) → {Promise}

Find all Streaming

Parameters:

Name Type Description
`parameters` object
Name Type Description
`videoId` string (required) Video ID

Example

classInstance.Streaming.find({videoId: 'string'})
    .then(resp => {
        // your data is in resp.headers and resp.body
    })
    .catch(err => {
        // error handling
    });

Subgenres.find(parameters) → {Promise}

Find all Subgenres

Parameters:

Name Type Description
`parameters` object
Name Type Description
`name` string (optional) Filter (regex)
`genre.id` string (optional) Filter
`sort` string (optional) Fields Supported: [genre.id, name]
`limit` integer (optional) Max Resource Count. *Page size
`offset` integer (optional) Resource index. *Zero-based
`fields` string (optional) Resource fields returned in API resource response
`xfields` string (optional) Resource fields excluded from API resource response
`xid` string (optional) Resource models excluded from API resource response based on content id
`embed` string (optional) Ability to expand referenced/embedded collection item types(e.g. API Collections: networks, show, genres, subgenres, season)

Example

classInstance.Subgenres.find()
    .then(resp => {
        // your data is in resp.headers and resp.body
    })
    .catch(err => {
        // error handling
    });

Subgenres.find(parameters) → {Promise}

Find one Subgenre

Parameters:

Name Type Description
`parameters` object
Name Type Description
`id` string (required) Subgenres ID
`fields` string (optional) Resource fields returned in API resource response
`xfields` string (optional) Resource fields excluded from API resource response
`embed` string (optional) Ability to expand referenced/embedded collection item types(e.g. API Collections: networks, show, genres, subgenres, season)

Example

classInstance.Subgenres.find({id: 'string'})
    .then(resp => {
        // your data is in resp.headers and resp.body
    })
    .catch(err => {
        // error handling
    });

SupportPages.find(parameters) → {Promise}

Find all SupportPages

Parameters:

Name Type Description
`parameters` object
Name Type Description
`platform` string (required) Platform Name (e.g. desktop)
`type` string (optional) Type (e.g. privacy, faq, etc)
`networks.id` string (optional) Filter
`networks.code` string (optional) Filter
`xfields` string (optional) Resource fields excluded from API resource response
`limit` integer (optional) Max Resource Count. *Page size
`offset` integer (optional) Resource index. *Zero-based

Example

classInstance.SupportPages.find({platform: 'string'})
    .then(resp => {
        // your data is in resp.headers and resp.body
    })
    .catch(err => {
        // error handling
    });

Videos.find(parameters) → {Promise}

Find all Videos

Parameters:

Name Type Description
`parameters` object
Name Type Description
`name` string (optional) Filter (regex)
`slug` string (optional) Filter
`type` string (optional) Filter
`authenticated` boolean (optional) Filter
`airDate` string (optional) Filter
`show.id` string (optional) Filter
`networks.id` string (optional) Filter
`networks.code` string (optional) Filter
`genres.id` string (optional) Filter
`subgenres.id` string (optional) Filter
`season.id` string (optional) Filter
`season.number` integer (optional) Filter
`episodeNumber` integer (optional) Filter
`tags` string (optional) Filter (regex)
`sort` string (optional) Fields Supported: [slug, authenticated, type, airDate, show.id, networks.id, genres.id, subgenres.id, season.id, season.number, episodeNumber]
`platform` string (optional) Platform Name (e.g. desktop) to filter resource Alternate Images, if applicable
`limit` integer (optional) Max Resource Count. *Page size
`offset` integer (optional) Resource index. *Zero-based
`fields` string (optional) Resource fields returned in API resource response
`xfields` string (optional) Resource fields excluded from API resource response
`xid` string (optional) Resource models excluded from API resource response based on content id
`xslug` string (optional) Resource models excluded from API resource response based on content slug
`embed` string (optional) Ability to expand referenced/embedded collection item types(e.g. API Collections: networks, show, genres, subgenres, season)

Example

classInstance.Videos.find()
    .then(resp => {
        // your data is in resp.headers and resp.body
    })
    .catch(err => {
        // error handling
    });

Videos.find(parameters) → {Promise}

Find one Video

Parameters:

Name Type Description
`parameters` object
Name Type Description
`id` string (required) Comma-delimited list of video ids
`platform` string (optional) Platform Name (e.g. desktop) to filter resource Alternate Images, if applicable
`limit` integer (optional) Max Resource Count. *Page size
`offset` integer (optional) Resource index. *Zero-based
`fields` string (optional) Resource fields returned in API resource response
`xfields` string (optional) Resource fields excluded from API resource response
`embed` string (optional) Ability to expand referenced/embedded collection item types(e.g. API Collections: networks, show, genres, subgenres, season)

Example

classInstance.Videos.find({id: 'string'})
    .then(resp => {
        // your data is in resp.headers and resp.body
    })
    .catch(err => {
        // error handling
    });

Videos.find(parameters) → {Promise}

Find one Video

Parameters:

Name Type Description
`parameters` object
Name Type Description
`id` string (required) Video ID
`platform` string (optional) Platform Name (e.g. desktop) to filter resource Alternate Images, if applicable
`fields` string (optional) Resource fields returned in API resource response
`xfields` string (optional) Resource fields excluded from API resource response
`embed` string (optional) Ability to expand referenced/embedded collection item types(e.g. API Collections: networks, show, genres, subgenres, season)

Example

classInstance.Videos.find({id: 'string'})
    .then(resp => {
        // your data is in resp.headers and resp.body
    })
    .catch(err => {
        // error handling
    });

WelcomePages.find(parameters) → {Promise}

Find all WelcomePages

Parameters:

Name Type Description
`parameters` object
Name Type Description
`platform` string (required) Platform Name (e.g. desktop)
`networks.id` string (optional) Filter
`networks.code` string (optional) Filter
`limit` integer (optional) Max Resource Count. *Page size
`offset` integer (optional) Resource index. *Zero-based
`fields` string (optional) Resource fields returned in API resource response
`xfields` string (optional) Resource fields excluded from API resource response

Example

classInstance.WelcomePages.find({platform: 'string'})
    .then(resp => {
        // your data is in resp.headers and resp.body
    })
    .catch(err => {
        // error handling
    }); 

Readme

Keywords

none

Package Sidebar

Install

npm i mercury-sdk-js

Weekly Downloads

2

Version

0.169.0

License

MIT

Unpacked Size

242 kB

Total Files

35

Last publish

Collaborators

  • discodigital