This guide explains how to integrate the Titan SDK into your project using the Content Delivery Network (CDN) URL method. It’s an alternative to the NPM method. This approach is ideal for simple projects, quick prototypes, or environments that do not use a build system with npm (like Vite or Webpack).
For modern and robust applications, we recommend using the npm installation method, as it provides version management.

How to Use

CDN integration is straightforward and involves just two steps.
1

Add the Script to your HTML

To begin, add the following <script> tag inside the <head> tag of your main HTML file. Placing it in the <head> ensures the SDK is loaded before any of your own scripts are executed.
<script
src="https://sdk.titanos.tv/sdk/sdk.js"
type="text/javascript"
></script>
2

Access the Global TitanSDK Variable

After the script is loaded, it will create a global object named TitanSDK on the window object. You can access it directly in your JavaScript files to start using the SDK’s functionalities.
// The TitanSDK variable is now globally available
const titanSDK = TitanSDK;

console.log('Titan SDK has been loaded:', titanSDK);

Usage Example

Here is a practical example of how to fetch device information using the CDN method. Note that, just like the npm version, function calls are asynchronous.
document.addEventListener('DOMContentLoaded', async () => {
  try {
    // 1. Access the global variable
    const titanSDK = TitanSDK;

    // 2. Call the function to get device information
    const deviceInfo = await titanSDK.deviceInfo.getDeviceInfo();
    
    // 3. Log the information to the console
    console.log('TV Brand:', deviceInfo.Product.brand);
    console.log('Model Year:', deviceInfo.Product.year);

  } catch (error) {
    console.error('Failed to use the Titan SDK:', error);
  }
});

Next Steps