Skip to main content

VK API for Python

Project description

PyVK implements a Python client for VK (major Russian social network.) It is

  • cross-platform: Supports both Python 2 and 3.

  • user-friendly: Robust authorisation. Error handling.

  • smart: Renews expired authorisation. Repeats failed requests. Delays too frequent requests.

  • configurable: Exposes parameters of HTTP requests, logging, user input, API version, error handling, and so on.

Usage

Authorisation

>>> from pyvk import API
>>> vk = API(api_id=<...>, username=<...>)
Password: <...>

Password is requested only for the first time: PyVK stores API token on disk and renews it automatically. Secret code, mobile phone, and captcha may also be requested during the initial authorisation.

One can also directly specify an API token obtained elsewhere:

>>> vk = API(token=<...>)

Method Calls

>>> vk.users.get(user_ids=['haroldpain'], fields=['home_town'])
[{'last_name': 'Arató', 'home_town': 'Kőszeg', 'first_name': 'András', 'id': 329237321}]

>>> albums = vk.photos.getAlbums(owner_id=329237321)
>>> {a['title'] for a in albums['items']}
{'Zuglói képek', 'In the arboretum of the Horticulture University in Budapest'}

See list of methods at VK developers section. Note that pythonic integers and lists can be used where the official API documentation specify numbers (including negative) and comma-separated lists.

Credits

Some ideas (such as first-class queryset-like methods) are inspired by vk-requests.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyvk-0.0.1.tar.gz (7.7 kB view hashes)

Uploaded Source

Built Distribution

pyvk-0.0.1-py2.py3-none-any.whl (10.2 kB view hashes)

Uploaded Python 2 Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page