
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
This API for VK (Actually it mix of two APIs) that mostly adapted for bots, but can be used for anything
It written in TypeScript, but can be used in JS too. All examples in this readme written in TS.
.d.ts files for used APIs and this api can be found on github
For node imports will be converted like this:
import {name1, name2} from 'gt-vk-api';
->
var vk = require('gt-vk-api');
var name1 = vk.name1;
var name2 = vk.name2;
or just require and use vk.name1; vk.name2;
and
import Name = require('name');
->
var Name = require('name');
bot
in all examples is bot from vk-bot-api so you can also use all it features
Authentication:
With login & pass:
import {auth, Creditanials} from 'gt-vk-api';
const credentials: Credentials = {
client_id: 0,//Application ID
login: 'login|email|phone',
pass: 'password',
phone: 'phone',
scope: ['messages', 'photos', 'users', 'audio']
};
//Second argumet is prefix for bot command
auth(credentials, '!').then(bot => {
//You have access to api now
}).catch(e => {
//Authorization faild, e describes the error
});
With token:
import {authToken} from 'gt-vk-api';
import Bot = require('vk-bot-api');
//Second argumet is prefix for bot command
var bot: Bot = authToken('...token...', '!');
//You have access to api now
Api access:
import {$} from 'gt-vk-api';//$ can be replaced with 'callApi'
$('method.name', {
param1: 1,
parame2" 'foo'
}, bot /*Optional, if ommited last authenticated bot will be used*/).then(res => {
//res is 'response' param from json returned by vk
}.catch(e => {
//Error
});
Sending message:
By peer_id (User id || chat id + 2000000000 || -group id)
bot.sendMessage(peer_id, "message");
By message ('message.getById' or from frist arg in command (see below)):
import {reply} from 'gt-vk-api';
reply(msg, "message", bot /*Optional, if ommited last authenticated bot will be used*/);
Commands:
import {createCommand, Message} form 'gt-vk-api'
//Should be used after authentication
createCommand('commandName' (msg: Message, args: string[]) => {
//Perform command here
}
Regex can also be used:
import {createCommand, Message} form 'gt-vk-api'
//Should be used after authentication
createCommand('/commandNam.?/i' (msg: Message, args: string[]) => {
//Perform command here
}
FAQs
Unknown package
We found that gt-vk-api demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
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.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.