![Maven Central Adds Sigstore Signature Validation](https://cdn.sanity.io/images/cgdhsj6q/production/7da3bc8a946cfb5df15d7fcf49767faedc72b483-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Maven Central Adds Sigstore Signature Validation
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.
Simple API wrapper for VK.com social network. Inspired by node-vk-sdk.
npm install vk-call
var vk = require('vk-call').vk;
config options:
token
— OAuth token for authorized requeststimeout
— request timeout in millisecondsversion
— API versionapi_url
— base url for api callsSingle api call, returns promise.
method
— method name, i.e. 'users.get'params
— method parameters, i.e. { id: 1 }
Example:
var vk = require('vk-call').vk;
var api = new vk({
token: "YOUR TOKEN HERE",
version: "5.50",
timeout: 10000
});
api.call("users.get", { user_ids: 1 })
.then(users => console.log(users));
Intitializes and returns Chain
object
This object is responsible for chaining api calls and batching them with the help of execute method. It allows you to legally get around some of request rate limits. However, remember that you can't chain more than 25 api calls.
It's better to create Chain
object via vk.chain
method.
api
— initialized instance of vkThis method is very similar to vk.call
, but used for chaining.
Returned promise will be resolved after successfull execute
call.
Promise will return value as if it is a single api call.
It means, that only data returned single for this request will be supplied.
You can't call Chain.append
after you called Chain.done
, you have to create new Chain
.
You must call this method, when you appended enough requests.
This method will return an array of results for chained methods in the same order in which you appended calls.
Empty chain will return Promise([])
.
Exmaple:
var vk = require('vk-call');
var api = new vk({
token: "YOUR TOKEN",
version: "5.50"
});
var chain = api.chain();
chain.append("users.get", { user_ids: 1 })
.then((users) => console.log(users));
chain.append("groups.getById", { group_ids: 1 })
.then(groups => console.log(groups));
chain.done()
.then((result) => {
var users = result[0];
var groups = result[1];
console.log(users, groups);
});
chain.append("users.get", { user_ids: 2 });
// Throws error, because chain ended after done
All errors are wrapped with VKError object wich you can request as:
var VKError = require('vk-call').errors.VKError;
There are two type of errors:
Most of error codes that can be returned by VK API are represented by constants:
var errors = require('vk-call').errors;
assert(errors.NOT_DOMAIN_ERROR === -1);
assert(errors.UKNOWN_ERROR === 1);
assert(errors.UNKNOWN_METHOD === 3);
This codes are stored in type
property of VKError
instance.
You can find the whole list of constants here.
There is also name
property, it can have two values:
var errors = require('vk-call').errors;
errors.NOT_DOMAIN_NAME
errors.DOMAIN_NAME
This property is handy for distinguishing API errors from any other failures.
Also there is an originalError
property were you can get the original error (json or Error object).
This library is mostly covered with tests. To run test, use npm test
command.
For developing, use npm test-watch
command.
We use mocha for testing. All test files are stored in test/**/*
.
Distributed under MIT LICENSE
FAQs
node API library for VK social network
The npm package vk-call receives a total of 0 weekly downloads. As such, vk-call popularity was classified as not popular.
We found that vk-call 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
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.
Security News
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Research
Security News
Socket researchers uncovered a backdoored typosquat of BoltDB in the Go ecosystem, exploiting Go Module Proxy caching to persist undetected for years.