npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

stem-splitter-api

v1.0.1

Published

JavaScript/TypeScript SDK for Stem Splitter API - Easy audio stem separation

Downloads

16

Readme

Stem Splitter API - JavaScript/TypeScript SDK

Easy-to-use JavaScript/TypeScript SDK for the Stem Splitter API. Separate audio files into stems (vocals, drums, bass, etc.) with just a few lines of code.

Installation

npm install stem-splitter-api
# or
yarn add stem-splitter-api
# or
pnpm add stem-splitter-api

Quick Start

import { StemSplitterClient } from 'stem-splitter-api';
import fs from 'fs';

// Create client
const client = new StemSplitterClient({
  baseUrl: 'https://stem-splitter-api-production.up.railway.app'
});

// Separate audio file
const result = await client.separate('./audio.mp3', { stems: 2 });

// Save result
fs.writeFileSync('output.zip', result.data);
console.log(`Saved: ${result.filename}`);

API Reference

StemSplitterClient

Main client class for interacting with the Stem Splitter API.

Constructor

new StemSplitterClient(options?: StemSplitterOptions)

Options:

  • baseUrl (string, optional): API base URL (default: 'https://stem-splitter-api-production.up.railway.app')
  • timeout (number, optional): Request timeout in milliseconds (default: 300000 = 5 minutes)

Methods

separate(filePath, options?)

Separate an audio file from the file system.

Parameters:

  • filePath (string): Path to the audio file
  • options (object, optional):
    • stems (2 | 4 | 5): Number of stems (default: 2)

Returns: Promise<SeparationResult>

Example:

const result = await client.separate('./song.mp3', { stems: 4 });
separateFromBuffer(buffer, filename, options?)

Separate an audio file from a buffer.

Parameters:

  • buffer (Buffer): Audio file buffer
  • filename (string): Original filename
  • options (object, optional):
    • stems (2 | 4 | 5): Number of stems (default: 2)

Returns: Promise<SeparationResult>

Example:

const audioBuffer = fs.readFileSync('./song.mp3');
const result = await client.separateFromBuffer(audioBuffer, 'song.mp3', { stems: 2 });
healthCheck()

Check API health status.

Returns: Promise<HealthStatus>

Example:

const health = await client.healthCheck();
console.log(health.status); // "healthy"
console.log(health.disk_space_gb); // Available disk space
console.log(health.allowed_extensions); // [".flac", ".m4a", ".mp3", ...]
getInfo()

Get API information from root endpoint.

Returns: Promise<ApiInfo>

Example:

const info = await client.getInfo();
console.log(info.message); // "Stem Splitter API is running"
console.log(info.docs); // "/docs"

Examples

Node.js Example

import { StemSplitterClient } from 'stem-splitter-api';
import fs from 'fs';
import path from 'path';

async function main() {
  const client = new StemSplitterClient({
    baseUrl: 'https://stem-splitter-api-production.up.railway.app',
    timeout: 600000, // 10 minutes
  });

  try {
    // Check health
    const health = await client.healthCheck();
    console.log('API Status:', health.status);
    console.log('Max file size:', health.max_file_size_mb, 'MB');

    // Separate audio
    console.log('Separating audio...');
    const result = await client.separate('./input.mp3', { stems: 2 });

    // Save output
    const outputPath = path.join(__dirname, 'output.zip');
    fs.writeFileSync(outputPath, result.data);
    console.log(`Saved to: ${outputPath}`);
    console.log(`Request ID: ${result.requestId}`);
  } catch (error) {
    console.error('Error:', error.message);
  }
}

main();

Browser Example (with File Input)

import { StemSplitterClient } from 'stem-splitter-api';

const client = new StemSplitterClient({
  baseUrl: 'https://stem-splitter-api-production.up.railway.app',
});

async function handleFileUpload(file: File) {
  try {
    // Convert File to Buffer (in browser)
    const arrayBuffer = await file.arrayBuffer();
    const buffer = Buffer.from(arrayBuffer);

    // Separate audio
    const result = await client.separateFromBuffer(buffer, file.name, { stems: 2 });

    // Download result
    const blob = new Blob([result.data], { type: 'application/zip' });
    const url = URL.createObjectURL(blob);
    const a = document.createElement('a');
    a.href = url;
    a.download = result.filename;
    a.click();
    URL.revokeObjectURL(url);
  } catch (error) {
    console.error('Error:', error.message);
  }
}

Error Handling

try {
  const result = await client.separate('./audio.mp3', { stems: 2 });
  // Handle success
} catch (error) {
  if (error.message.includes('File too large')) {
    console.error('File exceeds maximum size limit');
  } else if (error.message.includes('Invalid file type')) {
    console.error('File type not supported');
  } else if (error.message.includes('timeout')) {
    console.error('Request timed out - file may be too large or processing too slow');
  } else {
    console.error('Unexpected error:', error.message);
  }
}

Supported Formats

  • MP3
  • WAV
  • OGG
  • FLAC
  • M4A

Stems Options

  • 2 stems: Vocals, Accompaniment
  • 4 stems: Vocals, Drums, Bass, Other
  • 5 stems: Vocals, Drums, Bass, Piano, Other

TypeScript Support

Full TypeScript definitions are included. The package exports all types:

import {
  StemSplitterClient,
  StemSplitterOptions,
  SeparationOptions,
  SeparationResult,
  HealthStatus,
  ApiInfo,
} from 'stem-splitter-api';

License

MIT

Support

For API documentation and support, visit the API docs at /docs endpoint.