vk.com API python wrapper for asyncio
Project description
vk.com API python wrapper for asyncio
for old version of python you can use https://github.com/dimka665/vk
Features
asynchronous
support only python 3.5
have one dependency aiohttp
support two-factor authentication
support socks proxy with aiosocks
Install
pip install aiovk
Examples
Annotation
In all the examples below, I will give only the {code}
async def func():
{code}
loop = asyncio.get_event_loop()
loop.run_until_complete(func())
Drivers
HttpDriver - default driver for using aiohttp
>>> driver = HttpDriver()
>>> driver = HttpDriver(timeout=10) # default timeout for all requests
Socks5Driver - if you need a proxy required aiosocks
>>> driver = Socks5Driver(PROXY_ADDRESS, PORT) # 1234 is port
>>> driver = Socks5Driver(PROXY_ADDRESS, PORT, timeout=10)
>>> driver = Socks5Driver(PROXY_ADDRESS, PORT, PROXY_LOGIN, PROXY_PASSWORD, timeout=10)
How to use custom driver with session:
>>> session = TokenSession(..., driver=HttpDriver())
VK API
First variant:
>>> session = TokenSession()
>>> api = API(session)
>>> await api.users.get(user_ids=1)
[{'first_name': 'Pavel', 'last_name': 'Durov', 'id': 1}]
Second variant:
>>> session = TokenSession()
>>> api = API(session)
>>> await api('users.get', user_ids=1)
[{'first_name': 'Pavel', 'last_name': 'Durov', 'id': 1}]
Also you can add timeout argument for each request or define it in the session
See https://vk.com/dev/methods for detailed API guide.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
aiovk-0.3.tar.gz
(5.5 kB
view hashes)