Registry /
http-networking / kaltura-typescript-client
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslnode 18–226 runs
build_error
glibcnode 18–226 runs
build_error
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
KalturaClient
✓ import { KalturaClient } from 'kaltura-typescript-client'
✗ const KalturaClient = require('kaltura-typescript-client')
The primary class for interacting with the Kaltura API. ESM imports are the standard.
KalturaConfiguration
✓ import { KalturaConfiguration } from 'kaltura-typescript-client'
✗ import KalturaConfiguration from 'kaltura-typescript-client/KalturaConfiguration'
Used to configure the client, including service URL and partner ID. It's a named export.
PartnerService
✓ import { PartnerService } from 'kaltura-typescript-client'
✗ import { PartnerService } from 'kaltura-typescript-client/api/services'
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.
KalturaSessionType
✓ import { KalturaSessionType } from 'kaltura-typescript-client/api/types/KalturaSessionType'
✗ import { KalturaSessionType } from 'kaltura-typescript-client'
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.
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.
/*
IMPORTANT: This client is NOT published to npmjs.com.
You must first clone the generation repo, build, and install locally.
1. Clone the generation repository:
git clone https://github.com/kaltura/KalturaGeneratedAPIClientsTypescript.git
2. Navigate into the cloned directory:
cd KalturaGeneratedAPIClientsTypescript
3. Install dependencies and transpile:
npm install
npm run deploy
4. Find the generated .tar.gz file (e.g., in `dist/`):
ls dist/*.tgz
5. In YOUR project, install the .tgz file:
npm install file:path/to/kaltura-typescript-client-vX.Y.Z-DATE.tgz
Ensure you have `xhr2` and `dotenv` installed in your project:
npm install xhr2 dotenv @types/xhr2 --save-dev
*/
import { KalturaClient, KalturaConfiguration, PartnerService, SessionStartAction, KalturaSessionType } from 'kaltura-typescript-client';
// Required for Node.js environments as the client uses XMLHttpRequest internally
// Must be set globally before client initialization
global.XMLHttpRequest = require('xhr2');
// Load environment variables (e.g., from a .env file)
import 'dotenv/config';
// Define your Kaltura API credentials and configuration
const partnerId = parseInt(process.env.KALTURA_PARTNER_ID ?? '0', 10);
const adminSecret = process.env.KALTURA_ADMIN_SECRET ?? '';
const serviceUrl = process.env.KALTURA_SERVICE_URL ?? 'https://www.kaltura.com/api_v3';
if (!partnerId || !adminSecret) {
console.error('KALTURA_PARTNER_ID and KALTURA_ADMIN_SECRET must be set in your environment variables.');
process.exit(1);
}
async function initializeKalturaClient() {
const config = new KalturaConfiguration();
config.serviceUrl = serviceUrl;
config.partnerId = partnerId;
const client = new KalturaClient(config);
try {
// Start a session with the Kaltura API
const sessionStart = new SessionStartAction();
sessionStart.secret = adminSecret;
sessionStart.partnerId = partnerId;
sessionStart.type = KalturaSessionType.ADMIN;
const session = await client.request(sessionStart);
if (session && session.ks) {
client.set={'ks': session.ks};
console.log('Kaltura Session Started. KS:', session.ks);
// Example: Fetch partner details
const partnerService = new PartnerService(client);
const partner = await partnerService.get();
console.log('Fetched Partner Name:', partner.name);
} else {
console.error('Failed to start Kaltura session. No KS received.');
}
} catch (error) {
console.error('Error initializing Kaltura client or making API call:', error);
}
}
initializeKalturaClient();
Errors
Common errors & fixes
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.
The application bundler is including all thousands of API types and classes from the library, instead of only those explicitly used.
fixInstall `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.
ReferenceError: XMLHttpRequest is not defined
The `kaltura-typescript-client` uses `XMLHttpRequest` internally, which is not natively available in Node.js environments.
fixInstall 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. Error: Cannot find module 'kaltura-typescript-client'
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.
fixEnsure 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.
Audit
Dependencies
@types/nodeoptionalProvides Node.js specific type definitions for TypeScript projects.
tslibrequiredTypeScript helper functions, commonly required for transpiled TypeScript output.
xhr2requiredProvides `XMLHttpRequest` implementation for Node.js environments, which the client library uses internally.
dotenvoptionalOften used for managing environment variables (like API credentials) in Node.js applications.