Skip to main content

Python API wrapper around vk.com API

Project description

py-vkontakte — Python client for API vk.com

Build codecov Total alerts
Package GitHub release Solid Solid

Table of contents

Install

pip install py-vkontakte

First start

>>> import vk
>>> api = vk.Api('YOUR_TOKEN')

Method

User

# Single user
>>> user = api.get_user('durov')

# Many user
>>> user_items = api.get_users([1, 'sgaynetdinov'])  # Return generator
>>> [user.id for user in user_items]
[1, 23768217]

# User object
>>> user.id  # 1
>>> user.first_name  # 'Павел'
>>> user.last_name  # 'Дуров'
>>> user.maiden_name  # None
>>> user.nickname  # ''
>>> user.bdate  # '10.10.1984'
>>> user.sex  # 'male'
>>> user.status  # '道德經'
>>> user.site  # 'http://t.me/durov'
>>> user.relation  # None
>>> user.relation_partner  # None
>>> user.facebook  # '501012028'
>>> user.skype  # None
>>> user.twitter  # 'durov'
>>> user.livejournal  # None
>>> user.instagram  # 'durov'
>>> user.is_verified  # True
>>> user.is_trending  # False
>>> user.domain  # 'durov'
>>> user.screen_name  # 'durov'
>>> user.last_seen  # datetime.datetime
>>> user.platform  # 'web (vk.com)'
>>> user.is_deactivated  # False
>>> user.is_deleted  # False
>>> user.is_banned  # False
>>> user.can_write_private_message  # False
>>> user.is_friend  # False

>>> user.get_about()
>>> user.get_activities()
>>> user.get_books()
>>> user.get_career()
>>> user.get_games()
>>> user.get_movies()
>>> user.get_music()
>>> user.get_quotes()
>>> user.get_tv()

UserCareer

# Get user career data
>>> career = user.get_career()

# Career object
>>> career[0].group
>>> career[0].company
>>> career[0].country
>>> career[0].city
>>> career[0].city_name
>>> career[0].start
>>> career[0].end
>>> career[0].position

Group

# Single group
>>> group = api.get_group('devclub')

# Checking a user is a member of a current group
>>> user = api.get_user('durov')
>>> user in group  # or user.id in group

>>> user_items = [user for user in group.get_members()] # Get group members
>>> user_id_items = [user_id for user_id in group.get_members_only_id()] # Get only group members ID

# Many group
>>> groups_items = api.get_groups([1, 'devclub'])  # Return generator
>>> [group for group in groups_items]
[<Group: apiclub>, <Group: devclub>]

Examples

>>> import vk
>>> api = vk.Api('YOUR_TOKEN')
>>> group = api.get_group('devclub')
>>> user_id_items = []
>>> for user in group.get_members():
...     if user.is_friend and user.is_online:
...     	user_id_items.append(user.id)

Run tests

pip install -r requirements-dev.txt
pytest

Publish new release in PyPI

  • Edit field version in file setup.py
  • Create new release from github.com

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

py-vkontakte-5.76.0.tar.gz (13.6 kB view details)

Uploaded Source

Built Distribution

py_vkontakte-5.76.0-py3-none-any.whl (17.5 kB view details)

Uploaded Python 3

File details

Details for the file py-vkontakte-5.76.0.tar.gz.

File metadata

  • Download URL: py-vkontakte-5.76.0.tar.gz
  • Upload date:
  • Size: 13.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.6

File hashes

Hashes for py-vkontakte-5.76.0.tar.gz
Algorithm Hash digest
SHA256 0beda6f34f7c39ab3bcacb71ec78a48e9af6008a0b3ae0d236ea6fc9163cac1f
MD5 92f6c504068cbb4600c3bc81fab7a914
BLAKE2b-256 691d899a3578f47d63604f513b9281cfdd4a39b4884fe5b7a386118c175e437b

See more details on using hashes here.

File details

Details for the file py_vkontakte-5.76.0-py3-none-any.whl.

File metadata

  • Download URL: py_vkontakte-5.76.0-py3-none-any.whl
  • Upload date:
  • Size: 17.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.6

File hashes

Hashes for py_vkontakte-5.76.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a415ac7516936a4efaadce100beffb3a436505f3b50ff9c2a39100f471af851f
MD5 c8dc32b6dad45477646de9bc92d908cd
BLAKE2b-256 13d235acfa842391786a8bbe9d7d6d1f4891f9e66faf5ed142cd84ec370c6022

See more details on using hashes here.

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