Get list of bans

Get the list of all the Toloker bans.

Steps to follow

1. Import Toloka-Kit

Connect the Toloka-Kit library to your script.

import toloka.client as toloka

2. Instantiate TolokaClient

Replace the sample API key with your own one.

toloka_client = toloka.
TolokaClient
('PlaceYourRealApiKey_Here', 'PRODUCTION');

3. Print ban IDs, Toloker IDs, and creation dates

Iterate through all the bans calling the get_user_restrictions() method. Specify the scope which was used to restrict the Toloker access:

  • ALL_PROJECTS includes the Tolokers which have been banned from accessing all your projects.

  • PROJECT includes the Tolokers which have been banned from accessing a single project. Specify the project ID as an argument: project_id='120798'.

  • POOL includes the Tolokers which have been banned from accessing a single project. Specify the pool ID as an argument: pool_id='38955320'.

for restriction in toloka_client.
get_user_restrictions
(scope='PROJECT', project_id='120798'):

print(restriction.id, restriction.user_id, restriction.created)

You should get an output with the ban IDs, Toloker IDs, and ban creation dates which looks like this.

163294518 19025b33f844331a1c2c7ff57ec520b0 2023-07-18 15:31:28.459000+00:00
163295269 240d5b7897f98c119cd892e34295587e 2023-07-18 15:41:02.992000+00:00

Complete code: Get list of bans

import toloka.client as toloka
toloka_client = toloka.TolokaClient('PlaceYourRealApiKey_Here', 'PRODUCTION')
for restriction in toloka_client.get_user_restrictions(scope='PROJECT', project_id='120798'):
print(restriction.id, restriction.user_id, restriction.created)
List of classes and methods used in this recipe

See also

Last updated: July 19, 2023

Toloka-Kit
OverviewGetting API keyQuick start
Recipes
Reference
toloka.client
toloka.async_client
toloka.autoquality [autoquality]
toloka.metrics
toloka.streaming