Socket
Socket
Sign inDemoInstall

node-ts-vk-api

Package Overview
Dependencies
10
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    node-ts-vk-api

## Basic Exaple


Version published
Weekly downloads
4
Maintainers
1
Install size
824 kB
Created
Weekly downloads
 

Readme

Source

Simple Vk api for typescript

Basic Exaple

import pkg from 'node-ts-vk-api';
const {Bot} = pkg;

const bot = new Bot({
    token: 'YOUR TOKEN HERE'
});

bot.api.method('messages.send', { message: 'Hello World!', peer_id: 1 /* your vk id */});

Uploading Photos for Message

import pkg from 'node-ts-vk-api';
const {Bot} = pkg;
import { createReadStream } from "fs";

const user_id = 1; // id where do you want to send message with photo

const bot = new Bot({
    token: 'YOUR TOKEN HERE'
});

async function main(){
    const { id } = await bot.api.upload(createReadStream('./image.png'), user_id); //creating fs reading stream and uploading image to vk server
    await bot.api.method('messages.send', { message: 'Hello World!', peer_id: user_id, atachement: `photo${user_id}_${id}`});
}
main();

FAQs

Last updated on 15 Aug 2020

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc