{"id":3853,"library":"vk-api","title":"vk-api Python Wrapper","description":"vk-api is a Python module designed for creating scripts and interacting with the VK (Vkontakte) social network's API. It provides a convenient wrapper around the VK API, simplifying authentication and method calls. The library is actively maintained, with frequent releases primarily addressing authentication stability and minor bug fixes.","status":"active","version":"11.10.0","language":"en","source_language":"en","source_url":"https://github.com/python273/vk_api","tags":["vk","social media","api wrapper","vkontakte"],"install":[{"cmd":"pip install vk_api","lang":"bash","label":"Install vk-api"}],"dependencies":[{"reason":"Used for making HTTP requests to the VK API.","package":"requests","optional":false}],"imports":[{"symbol":"VkApi","correct":"from vk_api import VkApi"},{"symbol":"VkLongPoll","correct":"from vk_api.longpoll import VkLongPoll"},{"symbol":"VkEventType","correct":"from vk_api.longpoll import VkEventType"},{"note":"A different, less popular library named 'vk' exists with a different API surface and import pattern. The correct import for this library is 'vk_api'.","wrong":"import vk","symbol":"vk_api","correct":"import vk_api"}],"quickstart":{"code":"import os\nimport vk_api\n\nlogin = os.environ.get('VK_LOGIN', '+71234567890') # Use environment variables for sensitive data\npassword = os.environ.get('VK_PASSWORD', 'your_password')\n\ntry:\n    vk_session = vk_api.VkApi(login, password)\n    vk_session.auth() # Authenticate with VK\n    \n    vk = vk_session.get_api() # Get the API object\n    \n    # Example: Post a message to the wall\n    # In a real application, ensure the user_id is correct and permissions are granted.\n    response = vk.wall.post(message='Hello from vk-api!')\n    print(f\"Post successful! Post ID: {response['post_id']}\")\n\nexcept vk_api.AuthError as error_msg:\n    print(f\"Authentication failed: {error_msg}\")\nexcept Exception as e:\n    print(f\"An error occurred: {e}\")","lang":"python","description":"This quickstart demonstrates how to authenticate with VK using phone number and password, then make a simple API call to post a message to the user's wall. It uses environment variables for credentials, which is a recommended practice for security. For production, consider using access tokens instead of direct password authentication."},"warnings":[{"fix":"Keep `vk-api` updated to the latest version. For more robust and secure applications, consider using VK access tokens obtained via OAuth flows rather than direct password authentication, especially for bots or long-running scripts. Implement `captcha_handler` and `auth_handler` for interactive authentication challenges.","message":"Direct authentication with phone number and password (`vk_api.VkApi(login, password).auth()`) is prone to frequent issues due to VK's evolving security measures, including 2FA, CAPTCHAs, and non-Latin password handling. It's often unstable across minor versions.","severity":"gotcha","affected_versions":"All versions, frequently patched in 11.9.x to 11.10.0."},{"fix":"Ensure `six` and `enum34` are explicitly installed in your environment if your code directly depends on them, or remove any implicit dependencies. `vk-api` itself no longer requires them.","message":"Dependencies `six` and `enum34` were removed. If your project implicitly relied on `vk-api` to pull these in, you might encounter `ModuleNotFoundError` if they are not otherwise present in your environment.","severity":"breaking","affected_versions":">=11.9.5"},{"fix":"Always store credentials securely using environment variables, configuration files, or a secrets management system. For long-term access, prefer using user or community access tokens obtained through OAuth, which can have specific scopes and be revoked if compromised.","message":"Using phone number and password directly in your code (especially in production environments or public repositories) is a security risk. It exposes sensitive user credentials.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Always use `import vk_api` and refer to the official documentation for the `vk-api` library (by `python273`). Double-check your `pip install` command to ensure you're installing `vk_api` and not `vk`.","message":"There is another Python library for VK API interaction named 'vk' (lowercase). Using `import vk` will import that library, which has a different API and documentation, leading to confusion and `AttributeError`s if you expect `vk-api`'s functionality.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-11T00:00:00.000Z","next_check":"2026-07-10T00:00:00.000Z"}