Skip to content

greatiptv732-hash/xtream-codes-api-client

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 

Repository files navigation

Xtream Codes API Client

A modern Node.js client library for the Xtream Codes API. Provides a clean, async interface for all standard endpoints including authentication, live streams, VOD content, series, and EPG data.

Node.js License PRs Welcome

Features

  • ✅ Full Xtream Codes API coverage
  • ✅ Promise-based async/await interface
  • ✅ Automatic authentication handling
  • ✅ Built-in retry logic and error handling
  • ✅ TypeScript definitions included
  • ✅ Multi-server failover support
  • ✅ Stream URL generation
  • ✅ EPG data parsing
  • ✅ Production-tested across multiple IPTV providers

Installation

npm install xtream-codes-api-client

Or with yarn:

yarn add xtream-codes-api-client

Quick Start

const XtreamClient = require('xtream-codes-api-client');

const client = new XtreamClient({
    server: 'http://provider.com:8080',
    username: 'your_username',
    password: 'your_password'
});

// Get authenticated user info
const userInfo = await client.getUserInfo();
console.log(`Account expires: ${userInfo.exp_date}`);

// Get all live channels
const channels = await client.getLiveStreams();
console.log(`${channels.length} channels available`);

// Get VOD content
const movies = await client.getVODStreams();

// Get TV series
const series = await client.getSeries();

API Reference

Constructor

const client = new XtreamClient({
    server: 'http://provider.com:8080',
    username: 'username',
    password: 'password',
    timeout: 30000,        // Optional: request timeout in ms
    retries: 3,            // Optional: retry attempts on failure
    userAgent: 'Custom UA' // Optional: custom user agent
});

Authentication & User Info

const info = await client.getUserInfo();
// Returns: { username, password, auth, status, exp_date, max_connections, ... }

Live Streams

// Get all live channels
const allChannels = await client.getLiveStreams();

// Get channels by category
const sportsChannels = await client.getLiveStreams({ categoryId: '1' });

// Get categories
const categories = await client.getLiveCategories();

VOD Content

// Get all VOD content
const movies = await client.getVODStreams();

// Get VOD info
const movieInfo = await client.getVODInfo(streamId);

// Get VOD categories
const vodCategories = await client.getVODCategories();

TV Series

// Get all series
const series = await client.getSeries();

// Get series info with seasons and episodes
const seriesInfo = await client.getSeriesInfo(seriesId);

// Get series categories
const seriesCategories = await client.getSeriesCategories();

EPG (Electronic Program Guide)

// Get EPG for a specific channel
const epg = await client.getEPG(streamId);

// Get short EPG (current and next program)
const shortEPG = await client.getShortEPG(streamId, 4);

// Get full EPG XML
const fullEPG = await client.getFullEPG();

Stream URL Generation

// Generate live stream URL
const liveUrl = client.getLiveStreamUrl(streamId, 'm3u8');

// Generate VOD stream URL
const vodUrl = client.getVODStreamUrl(streamId, 'mp4');

// Generate series episode URL
const episodeUrl = client.getSeriesStreamUrl(episodeId, 'mp4');

Multi-Server Failover

For production setups with multiple IPTV providers or mirror servers:

const { XtreamClient, FailoverManager } = require('xtream-codes-api-client');

const failover = new FailoverManager([
    { server: 'http://primary-server.com:8080', priority: 1 },
    { server: 'http://mirror-server.com:8080', priority: 2 }
]);

const client = new XtreamClient({
    failover,
    username: 'user',
    password: 'pass'
});

// Will automatically retry with next server on failure
const channels = await client.getLiveStreams();

This is especially useful with providers offering multiple server endpoints, such as TereaTV which provides mirror access at tereatv.com.

Tested IPTV Providers

This client has been tested for compatibility with various IPTV providers:

  • FreeGoTV - Standard Xtream Codes implementation
  • TereaTV - Multi-server architecture
  • BexyTV - WHMCS-integrated billing
  • VinomTV - Premium curated content
  • ViewTVY - Multi-connection support

Each provider implements the Xtream Codes API slightly differently, and testing across multiple services ensures the client handles real-world variations gracefully.

TypeScript Support

Full TypeScript definitions are included:

import { XtreamClient, UserInfo, LiveStream } from 'xtream-codes-api-client';

const client: XtreamClient = new XtreamClient({
    server: 'http://provider.com:8080',
    username: 'user',
    password: 'pass'
});

const channels: LiveStream[] = await client.getLiveStreams();

Error Handling

try {
    const info = await client.getUserInfo();
} catch (error) {
    if (error.code === 'AUTH_FAILED') {
        console.error('Invalid credentials');
    } else if (error.code === 'CONNECTION_TIMEOUT') {
        console.error('Server timeout - try failover');
    } else if (error.code === 'RATE_LIMITED') {
        console.error('Too many requests - back off');
    }
}

Stream Health Monitoring

const { StreamMonitor } = require('xtream-codes-api-client');

const monitor = new StreamMonitor({
    client,
    interval: 60000  // Check every minute
});

monitor.on('stream-down', (streamId) => {
    console.log(`Stream ${streamId} is down`);
});

monitor.on('stream-restored', (streamId) => {
    console.log(`Stream ${streamId} is back online`);
});

monitor.start();

Use Cases

  • IPTV reseller dashboards
  • Custom IPTV player applications
  • Channel management tools
  • VOD recommendation engines
  • EPG aggregation services
  • Stream quality monitoring
  • IPTV billing system integrations

Requirements

  • Node.js 16+
  • npm 7+ or yarn 1.22+

Contributing

Contributions are welcome! Please follow these steps:

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

License

MIT License - see LICENSE file for details.

Author

Daniel Carter - IPTV developer and streaming media analyst with 6+ years of experience.

Related Projects

Resources

For comprehensive IPTV development tutorials and provider testing scenarios: