Those who worked on the python API vk using the library 'vk'?

Good evening,
deal with the vk library for python and can not figure out what was going on and why I do it refuses to work. The following example is taken from the network and should work as far as I know , without a token, but for some reason is not working showing the following error.

Installed: pip install vk

import datetime
from time import sleep
import vk

def get_status(current_status, vk_api, id):
 profiles = vk_api.users.get(user_id=id, fields='online last_seen')
 if (not current_status) and (profiles[0]['online']): # if appeared in the network, we deduce the time
 now = datetime.datetime.now()
print('~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~')
 print('Appeared online at: ', now.strftime("%d-%m-%Y %H:%M"))
 return True
 if (current_status) and (not profiles[0]['online']): # if was online but already gone, we deduce the time of release
 print('out of the network: ', datetime.datetime.fromtimestamp(profiles[0]['last_seen']['time']).strftime('%d-%m-%Y %H:%M'))
print('~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~')
 return False
 return current_status

if __name__ == '__main__':
 id = input("user ID: ")
 session = vk.Session()
 vk_api = vk.API(session)
 current_status = False
while(True):
 current_status = get_status(current_status, vk_api, id)
 sleep(60)


start and enter the Id of the user:
User ID: 1
Traceback (most recent call last):
 File "test.py", line 24, in <module>
 current_status = get_status(current_status, vk_api, id)
 File "test.py", line 6, in get_status
 profiles = vk_api.users.get(user_id=1, fields='online last_seen')
 File "/usr/local/lib/python2.7/dist-packages/vk/api.py", line 173, in __call__
 return self._api._session.make_request(self)
 File "/usr/local/lib/python2.7/dist-packages/vk/api.py", line 102, in make_request
 raise error
vk.exceptions.VkAPIError: 5. User authorization failed: no access_token passed.. request_params = {u 'oauth': u'1', u 'fields': u online, last_seen', u user_id': u'1', u 'method': u users.'get'}
March 20th 20 at 11:33
1 answer
March 20th 20 at 11:35
Solution
Method users.get has long required a token. Reference: click
Thanks, got the token, but was not able to understand as what argument should I pass in vk_api.users.get().

Tried: profiles = vk_api.users.get(user_id=id, fields='online last_seen', access_token='123456789')
Tell me how it is possible to override a default limit of 3 request per second? - Magdalen_Hoeger commented on March 20th 20 at 11:38
@verla.Murazik4, how to bypass limit 3 requests for users in a second no, or I'm just not familiar with those.

Yes, your method may work, but if you use several API methods you will insert each time the token but it is not very convenient. Better to pass the access_token argument to the constructor vk.Session, and then need to specify the token will not.

That is, so:
session = vk.Session(access_token='sometoken') - marge_Fra commented on March 20th 20 at 11:41
1. Thanks, I tried your method when trying to specify the version of the API 5.95
and 5.93 but the result is always get_status() always returns false in ie to check the status of user I and leaves.

2. Tell this module to be official and provided by group of developers Vkontakte?

3. As I understand it regardless of whether I use the module vk, or vk_api or the same request
I will always be limited to three requests per second?

Here below an example:
import datetime
from time import sleep
import vk

def get_status(current_status, vk_api, id):
 profiles = vk_api.users.get(user_id=id, fields='online last_seen', v=5.93)
 if (not current_status) and (profiles[0]['online']): 
 now = datetime.datetime.now()
print('~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~')
 print('Was online: ', now.strftime("%d-%m-%Y %H:%M"))
 return True
 if (current_status) and (not profiles[0]['online']):
 print('leaved : ', datetime.datetime.fromtimestamp(profiles[0]['last_seen']['time']).strftime('%d-%m-%Y %H:%M'))
print('~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~')
 return False
 return current_status

if __name__ == '__main__':
 id = input("User id: ")
 session = vk.Session(access_token='1234567890')
 vk_api = vk.API(session)
 current_status = False
while(True):
 current_status = get_status(current_status, vk_api, id)
 print("status:" + str(current_status))
 sleep(10)
- Magdalen_Hoeger commented on March 20th 20 at 11:44

Find more questions by tags PythonAPIVKontakte