Skip to main content

VK API for Python

Tests image image

VK is one of the major Russian-speaking social networks. PyVK is a no-nonsence boilerplate-free VK API library for Python. It can be used in server or client applications, scripts, or interactively for data retrieval and analysis, social media integration, automation, and fun.

Features

  • Authorisation: PyVK assists both client- and server-side authorisation. It ensures that your password is not stored anywhere in plain-text. It also supports 2FA and captcha/mobile phone login confirmation.
  • Error handling: PyVK wraps API errors into exceptions and can recover from certain kinds of those, such as expired autorisation, temporal ban, or captcha request.
  • Pagination: PyVK can join paginated API responses into a single result.
  • Media uploading: PyVK wraps it into a single method call and makes it easy to use those files as attachments to posts and messages.
  • Python 2 and 3 : PyVK is tested for CPython 2.7 and 3.5-3.8

Examples

>>> from pyvk import ClientAuth, p_docs, p_offline

>>> # Authorisation without tokens and stored passwords
>>> auth = ClientAuth(app_id=<...>, username=<...>, scope=p_docs | p_offline)
>>> auth.auth()
Password: <...>

>>> api = auth.api(version='5.21', lang='en')

>>> # Call API methods as if they were pythonic
>>> api.users.get(user_ids=[210700286], fields=['bdate'])
[{'id': 210700286,
  'first_name': 'Lindsey',
  'last_name': 'Stirling',
  'bdate': '21.9.1986'}]

>>> # Fetch all items from paginated API responses with a single call
>>> from pyvk.helpers import reqn
>>> reqn(api.users.getFollowers, n=1000, user_id=53083705)
{'count': 2255643,
 'items': [404278316,
           372620717,
           405001689,
           ...]}

>>> # Easy file uploading
>>> from pyvk.helpers.uploaders import WallPhotoUploader
>>> up = WallPhotoUploader(api)
>>> with open('cat.jpg', 'rb') as f:
>>>    attach = up.upload(f, attach=True)
>>>    api.wall.post(attachments=attach)

Installation

Stable versions can be installed using pip:

pip install pyvk

For development version:

pip install git+https://github.com/mkuznets/pyvk.git@master

Metadata

Release files for pyvk 0.2.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pyvk 0.2.3
File Size Uploaded
pyvk-0.2.3.tar.gz 15.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pyvk 0.2.3
File Interpreter ABI Platform
pyvk-0.2.3-py3-none-any.whl Python 3 none any Details

Total release size: 34.8 kB

Release files / pyvk-0.2.3.tar.gz

Download URL pyvk-0.2.3.tar.gz
Size 15.6 kB
Tags Source
SHA-256 checksum
How to use checksums
91ecdab61a4a28243d548da63ddfbd3cab714aadaa2f05c2a5a6ac5c63d16533
BLAKE2b-256 checksum
How to use checksums
ace9a556d00e2b913a96ab6066a01aaaa0b47ab065341467708a4d70e7cc90ca
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.12.1

Release files / pyvk-0.2.3-py3-none-any.whl

Download URL pyvk-0.2.3-py3-none-any.whl
Size 19.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d13de2fffe4daaea18413e4f3a4ec8a5c4ab3ac54c578b21c56ae9627766324f
BLAKE2b-256 checksum
How to use checksums
a3e1c20c134eb7c5dec7c9f479bd9431c74c548cec30f425701c0b70346b8a3f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.12.1

Release history Release notifications | RSS feed

This release

0.2.3 This release

2 release files

0.2.1

2 release files

0.1.2

1 release file

0.1.1

1 release file

0.1.0

1 release file

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page