{"id":13413,"library":"kaltura-typescript-client","title":"Kaltura TypeScript Client","description":"The `kaltura-typescript-client` is an auto-generated TypeScript client designed to provide a type-safe facade for the Kaltura server API. It offers strong typing for API actions, classes, and enums, streamlining development for Kaltura-powered applications. As of version 20.7.3, this library operates with a unique distribution model: it is generated directly from the `kaltura/clients-generator` PHP engine and is intended for direct consumption via a `.tar.gz` archive, rather than traditional publication to npmjs. This approach ensures a highly synchronized interface that reflects the latest API definitions. Developers are encouraged to monitor the changelog for updates. A key feature is its explicit support for bundle size optimization, which requires configuration with tools like `babel-plugin-import` to selectively include only the necessary types, preventing excessive application bundle sizes.","status":"active","version":"20.7.3","language":"javascript","source_language":"en","source_url":"https://github.com/kaltura/clients-generator","tags":["javascript","Kaltura"],"install":[{"cmd":"npm install kaltura-typescript-client","lang":"bash","label":"npm"},{"cmd":"yarn add kaltura-typescript-client","lang":"bash","label":"yarn"},{"cmd":"pnpm add kaltura-typescript-client","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Provides Node.js specific type definitions for TypeScript projects.","package":"@types/node","optional":true},{"reason":"TypeScript helper functions, commonly required for transpiled TypeScript output.","package":"tslib","optional":false},{"reason":"Provides `XMLHttpRequest` implementation for Node.js environments, which the client library uses internally.","package":"xhr2","optional":false},{"reason":"Often used for managing environment variables (like API credentials) in Node.js applications.","package":"dotenv","optional":true}],"imports":[{"note":"The primary class for interacting with the Kaltura API. ESM imports are the standard.","wrong":"const KalturaClient = require('kaltura-typescript-client')","symbol":"KalturaClient","correct":"import { KalturaClient } from 'kaltura-typescript-client'"},{"note":"Used to configure the client, including service URL and partner ID. It's a named export.","wrong":"import KalturaConfiguration from 'kaltura-typescript-client/KalturaConfiguration'","symbol":"KalturaConfiguration","correct":"import { KalturaConfiguration } from 'kaltura-typescript-client'"},{"note":"Individual API services (e.g., PartnerService, MediaService) are named exports from the root or can be imported directly if using babel-plugin-import. The README's babel config implies they can be loaded via `kaltura-typescript-client/api/types` if configured.","wrong":"import { PartnerService } from 'kaltura-typescript-client/api/services'","symbol":"PartnerService","correct":"import { PartnerService } from 'kaltura-typescript-client'"},{"note":"Specific types and enums are often nested in sub-paths like `api/types` or `api/types/enums`. This path is inferred from common usage patterns in similar generated clients.","wrong":"import { KalturaSessionType } from 'kaltura-typescript-client'","symbol":"KalturaSessionType","correct":"import { KalturaSessionType } from 'kaltura-typescript-client/api/types/KalturaSessionType'"}],"quickstart":{"code":"/*\n  IMPORTANT: This client is NOT published to npmjs.com. \n  You must first clone the generation repo, build, and install locally.\n  \n  1. Clone the generation repository:\n     git clone https://github.com/kaltura/KalturaGeneratedAPIClientsTypescript.git\n  2. Navigate into the cloned directory:\n     cd KalturaGeneratedAPIClientsTypescript\n  3. Install dependencies and transpile:\n     npm install\n     npm run deploy\n  4. Find the generated .tar.gz file (e.g., in `dist/`):\n     ls dist/*.tgz\n  5. In YOUR project, install the .tgz file:\n     npm install file:path/to/kaltura-typescript-client-vX.Y.Z-DATE.tgz\n  \n  Ensure you have `xhr2` and `dotenv` installed in your project:\n  npm install xhr2 dotenv @types/xhr2 --save-dev\n*/\n\nimport { KalturaClient, KalturaConfiguration, PartnerService, SessionStartAction, KalturaSessionType } from 'kaltura-typescript-client';\n// Required for Node.js environments as the client uses XMLHttpRequest internally\n// Must be set globally before client initialization\nglobal.XMLHttpRequest = require('xhr2');\n\n// Load environment variables (e.g., from a .env file)\nimport 'dotenv/config';\n\n// Define your Kaltura API credentials and configuration\nconst partnerId = parseInt(process.env.KALTURA_PARTNER_ID ?? '0', 10);\nconst adminSecret = process.env.KALTURA_ADMIN_SECRET ?? '';\nconst serviceUrl = process.env.KALTURA_SERVICE_URL ?? 'https://www.kaltura.com/api_v3';\n\nif (!partnerId || !adminSecret) {\n  console.error('KALTURA_PARTNER_ID and KALTURA_ADMIN_SECRET must be set in your environment variables.');\n  process.exit(1);\n}\n\nasync function initializeKalturaClient() {\n  const config = new KalturaConfiguration();\n  config.serviceUrl = serviceUrl;\n  config.partnerId = partnerId;\n\n  const client = new KalturaClient(config);\n\n  try {\n    // Start a session with the Kaltura API\n    const sessionStart = new SessionStartAction();\n    sessionStart.secret = adminSecret;\n    sessionStart.partnerId = partnerId;\n    sessionStart.type = KalturaSessionType.ADMIN;\n\n    const session = await client.request(sessionStart);\n\n    if (session && session.ks) {\n      client.set={'ks': session.ks};\n      console.log('Kaltura Session Started. KS:', session.ks);\n\n      // Example: Fetch partner details\n      const partnerService = new PartnerService(client);\n      const partner = await partnerService.get();\n      console.log('Fetched Partner Name:', partner.name);\n    } else {\n      console.error('Failed to start Kaltura session. No KS received.');\n    }\n  } catch (error) {\n    console.error('Error initializing Kaltura client or making API call:', error);\n  }\n}\n\ninitializeKalturaClient();","lang":"typescript","description":"Demonstrates the non-standard installation process and basic client initialization, session establishment, and a sample API call (fetching partner details) using environment variables for credentials in a Node.js environment."},"warnings":[{"fix":"Follow the 'Adding this library as a dependency to your project' instructions in the README, which involves cloning the generator repo, running `npm install`, `npm run deploy`, finding the `.tgz` file in `dist/`, and then running `npm install file:path/to/your-package.tgz` in your project.","message":"This library is not distributed via the public npm registry. It must be manually built from its source repository (`kaltura/KalturaGeneratedAPIClientsTypescript`) and installed as a local `.tar.gz` file in your project.","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"Integrate `babel-plugin-import` into your build process. Configure it to import from `kaltura-typescript-client/api/types` with specific options as described in the 'Using the library in production' section of the README.","message":"The library can lead to excessively large application bundles due to its thousands of auto-generated types if not properly optimized.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Install `xhr2` (`npm install xhr2 @types/xhr2 --save-dev`) and add `global.XMLHttpRequest = require('xhr2');` at the top of your application's entry file before any Kaltura client code.","message":"The library relies on `XMLHttpRequest` internally, which is a browser API. In Node.js environments, you must manually provide a polyfill like `xhr2` and assign it to `global.XMLHttpRequest`.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Review the AGPLv3 license terms and consult legal counsel if your project's licensing model has different requirements or if you plan to distribute your software.","message":"All code in this project is released under the AGPLv3 license, which has strong copyleft requirements. Ensure your project's licensing is compatible with AGPLv3.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"If you need to contribute changes, fork and submit PRs to the `kaltura/clients-generator` repository, which is the source of truth for the API client generation.","message":"Direct Pull Requests (PRs) to this client library's repository are generally discouraged. Changes should be made to the `kaltura/clients-generator` PHP engine repository, as this client is auto-generated.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"fix":"Install `babel-plugin-import` and configure it in your Babel setup with `libraryName: 'kaltura-typescript-client/api/types'`, `libraryDirectory: ''`, `camel2DashComponentName: false`, and `transformToDefaultImport: false` as specified in the README.","cause":"The application bundler is including all thousands of API types and classes from the library, instead of only those explicitly used.","error":"Notice! Your application bundle the whole package of kaltura-xxx-client (either rxjs/ngx/typescript), please refer to the library `readme.md` to reduce app bundle size."},{"fix":"Install the `xhr2` package (`npm install xhr2 @types/xhr2 --save-dev`) and add `global.XMLHttpRequest = require('xhr2');` at the beginning of your Node.js application's entry point before any Kaltura client code is executed.","cause":"The `kaltura-typescript-client` uses `XMLHttpRequest` internally, which is not natively available in Node.js environments.","error":"ReferenceError: XMLHttpRequest is not defined"},{"fix":"Ensure you have followed the manual installation steps precisely: build the `.tgz` file from the generation repo, copy it to a stable location, and install it in your project using `npm install file:./path/to/your/kaltura-typescript-client-vX.Y.Z-DATE.tgz`. Verify the path is correct.","cause":"The package was not installed correctly via the `file:` protocol, or the `.tgz` file path provided during installation was incorrect or has since been moved/deleted.","error":"Error: Cannot find module 'kaltura-typescript-client'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":"","cli_version":null}