Entwickler » Bots Long Poll API
Bots Long Poll API
1. Connecting Bots Long Poll API
    1.1. Configuration via API
2. Data Format
    2.1. Event Types
3. SDK Compatibility

Bots Long Poll API allows you to work with community events in real time. Unlike the Callback API, we will not send you notification for each event, instead the queue of events will be stored on the VK side. In contrast to User Long Poll, the Bots Long Poll API works with community events.

To use the Bots Long Poll API, go to the "Manage community" → "API usage" → "Bots Long Poll API" tab and select "Enabled".
1. Connecting Bots Long Poll API
Before connecting to the Long Poll server, you will need to acquire the session data (server, key, ts) using the groups.getLongPollServer method.

Afterwards, leave this kind of request:
{$server}?act=a_check&key={$key}&ts={$ts}&wait=25


Following parameters are used in the request:
  • key — session secret key;
  • server — the server address where you need to send the request;
  • ts — the number of the last event from which you want to receive data;
  • wait — the waiting period (as most proxy servers terminate the connection after 30 seconds, we recommend indicating wait = 25). Maximum: 90.

For the first request within a session, values for the server, key and ts parameters are to be received by the groups.getLongPollServer method. For next requests, use the same server and key values and a new value for ts that will be sent to you in a request from the Long Poll server.

You can choose the events that you want to track in "Manage community" → "API Usage" → "Bots Long Poll API" → "Event types" tab. A complete list of events can be found on this page.

1.1. Configuration via API
You also can manage Bots Long Poll API settings of your community using API methods:
2. Data Format
When an event happens you get a JSON object in following format:
{"type": <event type>, "object": <object that has triggered the event>, "group_id": <group ID, where the event occurred>}

For example:
{"type": "group_join", "object": {"user_id": 1, "join_type" : "approved"}, "group_id": 1}


2.1. Event Types
Objects structure in the object field depends on notification type. All event types and corresponding objects supported by Bots Long Poll API are described on this page. They are identical to the events in the Callback API.
3. SDK Compatibility
You can work with Bots Long Poll API using our SDK:

By continuing to browse, you consent to our use of cookies. You can read our Cookie Policy here.