vk

v0.10.0
io.github.bulatko/vk Checked 9 hours ago Published 1 day ago

VK (VKontakte): read walls, users, communities and stats; publish, edit and comment on posts.

These tools were reported by the server itself during our smoke test (tools/list), not copied from the README.

vk_users_get Get user profiles

Look up VK users by numeric ID or short name (e.g. durov). Use this to resolve a name to an ID before calling other tools, or to check whether a profile is closed.

ParameterTypeDescription
fieldsstringProfile fields to return
user_idsstringComma-separated user IDs or screen names

vk_wall_get Read a wall

Read posts from a user or community wall, newest first. Pass domain for a short address (durov) or owner_id for a numeric one — negative for a community, positive for a person. Each post carries its likes, reposts, comments and views.

ParameterTypeDescription
countnumberNumber of posts (1-100)
domainstringShort address of user or community
filterstringFilter: all, owner, others, postponed, suggests
offsetnumberOffset for pagination
owner_idnumberWall owner ID (negative for community)

vk_wall_post Publish a post

Publish a post on a wall. Under a community token, leave owner_id out and the post goes on that community's wall. Otherwise, to post in a community, set owner_id to the community ID with a minus sign (-123) and from_group true, or it appears as your personal post on the community wall. Attach media with the attachment string that vk_photos_upload_wall returns. Returns the new post_id.

ParameterTypeDescription
message *stringPost text content
attachmentsstringComma-separated attachments (e.g. photo123_456,link)
community_idstringWhich of your communities acts, when VK_ACCESS_TOKEN holds tokens of several (ID or short name, e.g. 123 or apiclub; see vk_token_info). Leave out with a single token.
from_groupbooleanPost on behalf of community
guidstringUnique identifier to prevent duplicate posts
owner_idnumberWall owner: a community as a negative number (-123), a person as a positive one. Defaults to the token's own community under a community token, to the token owner otherwise.
publish_datenumberUnix timestamp for scheduled post (must be within 2 weeks)

vk_wall_create_comment Comment on a post

Add a comment to a post. owner_id is negative for a community. Returns the new comment_id.

ParameterTypeDescription
message *stringComment text
owner_id *numberWall owner: a community as a negative number (-123), a person as a positive one. Defaults to the token owner.
post_id *numberPost ID
community_idstringWhich of your communities acts, when VK_ACCESS_TOKEN holds tokens of several (ID or short name, e.g. 123 or apiclub; see vk_token_info). Leave out with a single token.

vk_wall_get_by_id Get specific posts

Fetch particular posts by their full IDs in {owner_id}_{post_id} form, e.g. -1_340393. Use it to re-read a post you already know about, such as one you just published.

ParameterTypeDescription
posts *stringComma-separated post IDs in format {owner_id}_{post_id} (e.g. -123_456)
fieldsstringAdditional profile fields to return

vk_wall_edit Edit a post

Replace the text or attachments of an existing post. owner_id is negative for a community. Editing overwrites the previous content, so pass the full new text rather than an addition.

ParameterTypeDescription
post_id *numberPost ID to edit
attachmentsstringComma-separated attachments
messagestringNew post text
owner_idnumberWall owner: a community as a negative number (-123), a person as a positive one. Defaults to the token owner.

vk_wall_delete Delete a post

Delete a post from a wall. owner_id is negative for a community. This cannot be undone.

ParameterTypeDescription
post_id *numberPost ID to delete
owner_idnumberWall owner: a community as a negative number (-123), a person as a positive one. Defaults to the token owner.

vk_photos_upload_wall Upload a photo for a post

Upload a photo so it can be attached to a post. Takes a URL or a local file path, runs VK's three-step upload, and returns an attachment string like photo-1_2 to pass to vk_wall_post or vk_wall_edit. group_id is positive here, without the minus sign. Needs a full user token: VK refuses a community token here (error 27), and has no other way for one to attach a photo to a post.

ParameterTypeDescription
image *stringImage URL (http/https) or absolute local file path
captionstringPhoto caption
group_idstringCommunity ID or its short name (e.g. apiclub). Positive and without the minus sign — the minus belongs to owner_id on a wall, not here.

vk_stories_post_photo Publish a photo story

Publish a photo story on VK (three-step upload: get upload server, upload the photo, save). Posts a personal story, or a community one when group_id is set.

ParameterTypeDescription
image *stringImage URL (http/https) or absolute local file path
add_to_newsbooleanAdd the story to the news feed (default true)
community_idstringWhich of your communities acts, when VK_ACCESS_TOKEN holds tokens of several (ID or short name, e.g. 123 or apiclub; see vk_token_info). Leave out with a single token.
group_idstringCommunity ID or its short name (e.g. apiclub) to post as. Positive and without the minus sign. Omit to post a personal story.
link_textstringLink button text
link_urlstringLink URL for the button (requires link_text)

vk_stories_post_video Publish a video story

Publish a video story on VK (three-step upload: get upload server, upload the video, save). Posts a personal story, or a community one when group_id is set.

ParameterTypeDescription
video *stringVideo URL (http/https) or absolute local file path
add_to_newsbooleanAdd the story to the news feed (default true)
community_idstringWhich of your communities acts, when VK_ACCESS_TOKEN holds tokens of several (ID or short name, e.g. 123 or apiclub; see vk_token_info). Leave out with a single token.
group_idstringCommunity ID or its short name (e.g. apiclub) to post as. Positive and without the minus sign. Omit to post a personal story.
link_textstringLink button text
link_urlstringLink URL for the button (requires link_text)

vk_messages_get_conversations List community conversations

List the conversations in your community's inbox, newest first, with the last message of each and the names of the people in them. Use filter "unread" to see what is waiting for a reply. Needs a community token with the messages right.

ParameterTypeDescription
community_idstringWhich of your communities acts, when VK_ACCESS_TOKEN holds tokens of several (ID or short name, e.g. 123 or apiclub; see vk_token_info). Leave out with a single token.
countnumberHow many to return (default 20, max 200)
filterstringWhich conversations: all (default), unread, important, or unanswered
offsetnumberOffset for pagination

vk_messages_get_history Read a conversation

Read the messages of one conversation in your community's inbox, newest first. peer_id is the person's user ID, as vk_messages_get_conversations shows it. Needs a community token with the messages right.

ParameterTypeDescription
peer_id *numberUser ID of the person the community is talking to
community_idstringWhich of your communities acts, when VK_ACCESS_TOKEN holds tokens of several (ID or short name, e.g. 123 or apiclub; see vk_token_info). Leave out with a single token.
countnumberHow many messages to return (default 20, max 200)
offsetnumberOffset for pagination

vk_messages_send Reply as the community

Send a message from your community to a person. VK only delivers to people who have written to the community or allowed it to message them. This reaches a real person: show the user the text before sending. Returns the new message_id.

ParameterTypeDescription
message *stringMessage text
peer_id *numberUser ID of the recipient
attachmentstringOptional media, e.g. photo-1_2 or doc-1_2, comma-separated
community_idstringWhich of your communities acts, when VK_ACCESS_TOKEN holds tokens of several (ID or short name, e.g. 123 or apiclub; see vk_token_info). Leave out with a single token.
reply_tonumberOptional ID of the message this answers, to quote it

vk_messages_mark_as_read Mark a conversation as read

Mark every message in one conversation of your community's inbox as read, e.g. after answering it.

ParameterTypeDescription
peer_id *numberUser ID of the person the community is talking to
community_idstringWhich of your communities acts, when VK_ACCESS_TOKEN holds tokens of several (ID or short name, e.g. 123 or apiclub; see vk_token_info). Leave out with a single token.

vk_events_listen Start watching the community

Start receiving what happens in your community as it happens: new comments with their text and ID (so you can answer them with vk_wall_create_comment), likes, new posts and reposts, people joining and leaving, messages. Turns on the community's Long Poll and the event types if they are off. VK keeps no history: only events from now on are seen, while this server runs. Read them with vk_events_get.

ParameterTypeDescription
community_idstringWhich of your communities acts, when VK_ACCESS_TOKEN holds tokens of several (ID or short name, e.g. 123 or apiclub; see vk_token_info). Leave out with a single token.
typesarrayEvent types to turn on. Default: wall_post_new, wall_repost, wall_reply_new, wall_reply_edit, wall_reply_delete, wall_reply_restore, like_add, like_remove, group_join, group_leave, message_new, messag…

vk_events_get Read community events

Read the community events received since vk_events_listen, oldest first. Pass the returned cursor as after next time to get only new ones. With wait (up to 25 seconds) it holds until something arrives — call it in a loop to follow the community, e.g. to answer each new comment.

ParameterTypeDescription
afternumberCursor from the previous call; events after it are returned (default: all received)
community_idstringWhich of your communities acts, when VK_ACCESS_TOKEN holds tokens of several (ID or short name, e.g. 123 or apiclub; see vk_token_info). Leave out with a single token.
limitnumberMost events to return (default 50, max 200)
typesarrayOnly these event types, e.g. ["wall_reply_new"]
waitnumberSeconds to wait for an event when there is none yet (0–25, default 0)

vk_groups_get_members List community members

List the members of a community. Returns bare user IDs unless you ask for fields, in which case it returns profiles. Many communities hide their member list, which comes back as an access error rather than an empty list.

ParameterTypeDescription
group_id *stringCommunity ID or its short name (e.g. apiclub). Positive and without the minus sign — the minus belongs to owner_id on a wall, not here.
countnumberNumber of members to return (max 1000)
fieldsstringAdditional profile fields to return (e.g. photo_200,online,sex,city)
filterstringFilter: managers, editors, mods, advertisers, friends, unsure
offsetnumberOffset for pagination
sortstringSort order: id_asc, id_desc, time_asc, time_desc

vk_groups_join Join a community

Join a community as the token owner, or send a join request if it is closed. group_id is positive here, without the minus sign.

ParameterTypeDescription
group_id *stringCommunity ID or its short name (e.g. apiclub). Positive and without the minus sign — the minus belongs to owner_id on a wall, not here.
not_surenumberFor events only: 1 — "maybe attending", 0 — confirmed

vk_groups_get List your communities

List the communities the token owner belongs to. Needs a user token — a community or service token cannot answer this.

ParameterTypeDescription
countnumberNumber of communities
fieldsstringCommunity fields
filterstringFilter by type
user_idnumberUser ID. Defaults to the token owner.

vk_groups_get_by_id Get community info

Look up communities by numeric ID or short name (e.g. apiclub). Use it to resolve a name to an ID, or to read the description, member count and type before deciding what to do with it.

ParameterTypeDescription
fieldsstringCommunity fields
group_idsstringComma-separated community IDs or short names (e.g. apiclub,vk). Positive and without the minus sign.

vk_friends_get List friends

List a user's friends. Returns bare IDs unless you ask for fields. Needs a user token, and only works for profiles that expose their friend list.

ParameterTypeDescription
countnumberNumber of friends
fieldsstringProfile fields
orderstring
user_idnumberUser ID. Defaults to the token owner.

vk_newsfeed_get Read your newsfeed

Read the token owner's own newsfeed. Needs a user token — this is the feed of the account the token belongs to, not a public one.

ParameterTypeDescription
countnumberNumber of items
filtersstringFilter by type: post, photo, video
start_fromstringPagination cursor

vk_stats_get Community statistics

Read a community's statistics by period: reach, visitors and activity. The token owner must be an administrator of that community, otherwise VK denies access.

ParameterTypeDescription
group_id *stringCommunity ID or its short name (e.g. apiclub). Positive and without the minus sign — the minus belongs to owner_id on a wall, not here.
intervalstring
intervals_countnumberNumber of intervals

vk_likes_get See who reacted

List the users who liked or reacted to an object — a post, comment, photo or video — with counts per reaction. owner_id is negative for a community; item_id is the post or object ID.

ParameterTypeDescription
item_id *numberObject ID
type *stringObject type
countnumberNumber of users to return (max 1000)
offsetnumberOffset for pagination
owner_idnumberOwner ID of the object (negative for community)
reaction_idnumberFilter by reaction: 0 — like ❤️, 1 — laugh 😂, 2 — wow 😮, 3 — admiration 🔥, 4 — angry 😡, 5 — sad 😢

vk_photos_get Get photos

List photos from an album. album_id accepts wall, profile or saved as well as a numeric album ID. owner_id is negative for a community.

ParameterTypeDescription
album_idstringAlbum ID or: wall, profile, saved
countnumberNumber of photos
owner_idnumberAlbum owner: negative for a community, positive for a person.

vk_token_info What the VK token can do

Say which VK token the server holds — a community token, a user token, a VK ID sign-in token or an app service key — which community it acts as and with which rights, which tools work with it, and for each tool that does not, what would make it work. Call it when unsure what you can do in VK, or before telling the user something cannot be done.