Options
All
  • Public
  • Public/Protected
  • All
Menu

Unofficial VK Play Live API

This library is unofficial API (for https://vkplay.live/) and uses undocumented features, so there is no guarantee that it will be fully functional after some time.

It can be used in JavaScript/TypeScript projects.

Everything here is reverse engineered:

  • If I can do something in browser, then this MUST be available through an API
  • If I can do something anonymously (without account) then I don't need some_sort of API key or another type of access

Features

Installation

Right now library is not available in NPM, but will be in future after testing

So you can install it using local link to module:

# clone this repository
git clone https://github.com/Something-Went-Wrong-ORG/unofficial-vk-play-live-api.git
# go to js/ts library root
cd unofficial-vk-play-live-api
npm install
npm run build

Then link it to your project by adding new local dependency to your project package.json

{
  ...
  "dependencies": {
    ...
    "unofficial-vk-play-live-api": "file:../unofficial-vk-play-live-api"
  }
}

Documentation

You can find API documentation here: https://something-went-wrong-org.github.io/unofficial-vk-play-live-api/

Importing library

You can import the generated bundle to use the whole library generated by this starter:

import VKPLAPI from 'unofficial-vk-play-live-api';

Additionally, you can import the transpiled modules from dist/lib in case you have a modular library:

import something from 'unofficial-vk-play-live-api/dist/lib/something';

NPM scripts

  • npm t: Run test suite
  • npm start: Run npm run build in watch mode
  • npm run test:watch: Run test suite in interactive watch mode
  • npm run test:prod: Run linting and generate coverage
  • npm run build: Generate bundles and typings, create docs
  • npm run lint: Lints code
  • npm run commit: Commit using conventional commit style (husky will tell you to use it if you haven't :wink:)

Examples

Get Last Messages from Stream

// Import API
const VKPAPI = require('unofficial-vk-play-live-api');

try {
  // Create instance of Stream Manager
  const streamManager = VKPAPI.GetStreamManager('<channel_id>');
  // Get last messages from stream chat
  const messages = await streamManager.GetLastMessages(100);
} catch (error) {
  // Handle errors
  console.error(error);
}

Convert messages for your system

// Import API
const VKPAPI = require('unofficial-vk-play-live-api');

try {
  // Create instance of Stream Manager
  const streamManager = VKPAPI.GetStreamManager('<channel_id>');
  // Get last messages from stream chat
  const messages = await streamManager.GetLastMessages(100);

  // Convert messages
  const result = messages.data.map((message) => {
    const name = message.author.displayName;
    const time = message.createdAt * 1000;

    return {
      time,
      // Messages comes from VK Play Live comes as parts you can
      // convert it to something that can be more useful for your app
      message: message.data
        .map((messagePart) => {
          switch (messagePart.type) {
            case 'text':
              return messagePart.content[0];
            case 'smile':
              return `<img src="${messagePart.smallUrl}" />`;
            case 'mention':
              return `<strong>@${messagePart.displayName}</strong>`;
          }
        })
        .join(''),
      name,
      id: `${name}-${time}`
    };
  });
} catch (error) {
  console.error(error);
}

Get Metadata or Player Options from Stream Manager

const VKPAPI = require('unofficial-vk-play-live-api');

try {
  // Create instance of Stream Manager
  const streamManager = VKPAPI.GetStreamManager('<channel_id>');
  // Get stream metadata
  const metadata = await streamManager.GetMetadata();
  // Get player options
  const playerOptions = await streamManager.GetPlayerOptions();
} catch (error) {
  console.error(error);
}

Index

Variables

Const LIVE_SERVER_API_URL

LIVE_SERVER_API_URL: string = `${LIVE_SERVER_URL}/v1`

Const LIVE_SERVER_HOME_HOST

LIVE_SERVER_HOME_HOST: "https://vkplay.live" = "https://vkplay.live"

Const LIVE_SERVER_HOME_URL

LIVE_SERVER_HOME_URL: string = `${LIVE_SERVER_HOME_HOST}/`

Const LIVE_SERVER_URL

LIVE_SERVER_URL: "https://api.vkplay.live" = "https://api.vkplay.live"

Const USER_AGENTS

USER_AGENTS: string[] = ['Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36 RuxitSynthetic/1.0 v5984752886319290287 t7325514408114621287 ath5ee645e0 altpriv cvcv=2 smf=0','Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.99 Safari/537.36 RuxitSynthetic/1.0 v5277347273 t8984854527901076038 athfa3c3975 altpub cvcv=2 smf=0','Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.93 Safari/537.36 RuxitSynthetic/1.0 v3421343014903855844 t4171297756416412358 ath259cea6f altpriv cvcv=2 smf=0','Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.110 Safari/537.36 RuxitSynthetic/1.0 v2197586461287572997 t6651053852966445964 athe94ac249 altpriv cvcv=2 smf=0','Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.99 Safari/537.36 RuxitSynthetic/1.0 v4871161079369161779 t6454555150500562253 ath5ee645e0 altpriv cvcv=2 smf=0','Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.99 Safari/537.36 RuxitSynthetic/1.0 v16464110411 t6643906572558849902 athfa3c3975 altpub cvcv=2 smf=0','Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.99 Safari/537.36 RuxitSynthetic/1.0 v2507171974747346072 t5453667368085372556 ath5ee645e0 altpriv cvcv=2 smf=0','Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.99 Safari/537.36 RuxitSynthetic/1.0 v16464119827 t6643906572558849902 athfa3c3975 altpub cvcv=2 smf=0','Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.110 Safari/537.36 RuxitSynthetic/1.0 v6122573544871480936 t6759029105586231452 athe94ac249 altpriv cvcv=2 smf=0','Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36 RuxitSynthetic/1.0 v8197856685664031438 t6905711685490802112 ath5ee645e0 altpriv cvcv=2 smf=0']

Const WebSocket

WebSocket: any = require('ws')

Functions

Const ChatSubscribe

  • ChatSubscribe(connection: WebSocket, chatId: string): void

Const GetAdditionalHeaders

  • GetAdditionalHeaders(username: string): { Referer: string; User-Agent: string }
  • Parameters

    • username: string

    Returns { Referer: string; User-Agent: string }

    • Referer: string
    • User-Agent: string

Const GetAppConfig

  • GetAppConfig(username: string): Promise<AppConfig>

Const GetLastMessages

  • GetLastMessages(username: string, limit?: number): Promise<ChatResponse>

Const GetMetadata

Const GetPlayerOptions

  • GetPlayerOptions(username?: undefined | string, url?: undefined | string): Promise<PlayerOptions | undefined>

Const GetRandomUserAgent

  • GetRandomUserAgent(): string

Const OpenWebsocketConnection

  • OpenWebsocketConnection(username: string): Promise<WebSocket>

Const WebSocketAuth

  • WebSocketAuth(connection: WebSocket, token: string): void

timeout

  • timeout(ms: number): Promise<unknown>

Legend

  • Module
  • Object literal
  • Variable
  • Function
  • Function with type parameter
  • Index signature
  • Type alias
  • Type alias with type parameter
  • Enumeration
  • Enumeration member
  • Property
  • Method
  • Interface
  • Interface with type parameter
  • Constructor
  • Property
  • Method
  • Index signature
  • Class
  • Class with type parameter
  • Constructor
  • Property
  • Method
  • Accessor
  • Index signature
  • Inherited constructor
  • Inherited property
  • Inherited method
  • Inherited accessor
  • Protected property
  • Protected method
  • Protected accessor
  • Private property
  • Private method
  • Private accessor
  • Static property
  • Static method

Generated using TypeDoc