@vk-io/streaming

Separated module for receiving data with Streaming API

Usage no npm install needed!

<script type="module">
  import vkIoStreaming from 'https://cdn.skypack.dev/@vk-io/streaming';
</script>

README

VK-IO Streaming

NPM version Build Status NPM downloads Code quality

VK-IO Streaming API - Separated module for receiving data with Streaming API ⚙️

Installation

Node.js 12.0.0 or newer is required

Yarn

Recommended

yarn add @vk-io/streaming

NPM

npm i @vk-io/streaming

Example usage

import { VK } from 'vk-io';

import { StreamingAPI } from '@vk-io/streaming';

const vk = new VK({
    token: process.env.TOKEN
});

const streaming = new StreamingAPI({
    api: vk.api,
    updates: vk.updates
});

vk.updates.on('publication', (context) => {
    console.log('Streaming context', context);
});

async function run() {
    await streaming.startWebSocket();

    await streaming.addRule({
        tag: 'halloween',
        value: 'тыква'
    });
}

run().catch(console.error);