Skip to main content
Join the official 2019 Python Developers SurveyStart the survey!

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


Release history Release notifications

This version

0.0.1

Download files

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

Files for pyvk, version 0.0.1
Filename, size File type Python version Upload date Hashes
Filename, size pyvk-0.0.1-py2.py3-none-any.whl (10.2 kB) File type Wheel Python version py2.py3 Upload date Hashes View hashes
Filename, size pyvk-0.0.1.tar.gz (7.7 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page