Use the official Mux TypeScript SDK (@mux/ts) to call the Mux API from Node.js, Deno, Bun, or edge runtimes. The SDK handles authentication and wraps each API endpoint in typed methods.
The Mux TypeScript SDK wraps the Mux REST API in typed methods you can call from TypeScript or JavaScript. It runs on Node.js, Deno, Bun, Cloudflare Workers, and Vercel Edge Runtime. You can create assets, manage live streams, and query Mux Data without manual HTTP requests.
Add a dependency on the @mux/ts package via npm or yarn.
npm install @mux/tsAlready using @mux/mux-node? It's the same SDK under its previous name, and existing installs keep working. We recommend switching to @mux/ts. If you're already on version 15, switching is a dependency and import rename. If you're on an earlier version, upgrade to 15 first; it includes breaking changes, covered in the migration guide.
To start, you'll need a Mux access token. Once you've got that, you're off to the races!
import Mux from '@mux/ts';
const mux = new Mux({
tokenId: process.env.MUX_TOKEN_ID,
tokenSecret: process.env.MUX_TOKEN_SECRET
});
const asset = await mux.video.assets.create({
input: [{ url: 'https://storage.googleapis.com/muxdemofiles/mux-video-intro.mp4' }],
playback_policy: ['public'],
});With no arguments, new Mux() reads MUX_TOKEN_ID and MUX_TOKEN_SECRET from the environment. How you provide them depends on where your code runs.
Node.js 20 or later is supported, with either ES modules or CommonJS:
import Mux from '@mux/ts';
const mux = new Mux();const Mux = require('@mux/ts');
const mux = new Mux();In Deno, import the package with an npm: specifier and run with --allow-env so the SDK can read your credentials, and --allow-net so it can reach the Mux API:
import Mux from 'npm:@mux/ts';
const mux = new Mux();Bun works the same way as Node.js. Install the package with bun add @mux/ts.
Cloudflare Workers expose secrets as bindings rather than environment variables, so pass them to the client explicitly:
import Mux from '@mux/ts';
export default {
async fetch(request, env) {
const mux = new Mux({ tokenId: env.MUX_TOKEN_ID, tokenSecret: env.MUX_TOKEN_SECRET });
const assets = await mux.video.assets.list();
return Response.json(assets.data);
},
};On Vercel Edge Runtime, process.env is available, so new Mux() works as it does in Node.js.
Check out the Mux TypeScript SDK docs for more information.