Filter Tolokers

Use pool filters to specify the Toloker groups you want to pick your tasks.

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. Specify pool parameters

First, specify the parameters you want your pool to have. You can choose your own values or have your own set of the pool parameters. Refer to the Pool class page for more details.

new_pool = toloka.pool.
Pool
(

# The ID of the project in which the pool is created

project_id='133047',

# The pool name you will see in the list and use to distinguish the pool from other ones

private_name='Pool with filters',

# The date when the pool is going to expire and will be closed

will_expire=datetime(2030, 1, 1),

# The reward for the task suite specified in U.S. dollars

reward_per_assignment=0.05,

# The maximum duration of the task suite completion available to Tolokers

assignment_max_duration_seconds=60*5,

# The filters used to select Tolokers

filter=(

(toloka.filter.
AdultAllowed
==True) &

(toloka.filter.
Citizenship
=='US') &

(toloka.filter.
ClientType
=='TOLOKA_APP') &

(toloka.filter.
DeviceCategory
=='SMARTPHONE') &

(toloka.filter.
Gender
=='MALE') &

(toloka.filter.
Languages
.in_(['EN','DE','FR'])) &

(toloka.filter.
OSFamily
=='IOS') &

(toloka.filter.
Skill
('12648')>70)

)

)
Filters used for the pool
Selected filters in the Toloka interface

4. Create pool on platform

This actually creates a pool in Toloka.

new_pool = toloka_client.
create_pool
(new_pool)

5. Print created pool ID

The create_pool() request will return the Pool class object. You can use its attributes to print the information you need.

print(new_pool.id)

You should get an output with the created pool ID which looks like this.

1443815

Complete code: Filter Tolokers

import toloka.client as toloka
toloka_client = toloka.TolokaClient('PlaceYourRealApiKey_Here', 'PRODUCTION')
new_pool = toloka.pool.Pool(
project_id='133047',
private_name='Pool with filters',
will_expire=datetime(2030, 1, 1),
reward_per_assignment=0.05,
assignment_max_duration_seconds=60*5,
filter=(
(toloka.filter.AdultAllowed==True) &
(toloka.filter.Citizenship=='US') &
(toloka.filter.ClientType=='TOLOKA_APP') &
(toloka.filter.DeviceCategory=='SMARTPHONE') &
(toloka.filter.Gender=='MALE') &
(toloka.filter.Languages.in_(['EN','DE','FR'])) &
(toloka.filter.OSFamily=='IOS') &
(toloka.filter.Skill('12648')>70)
)
)
new_pool = toloka_client.create_pool(new_pool)
print(new_pool.id)
List of classes and methods used in this recipe

See also

Last updated: August 24, 2023

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