Additionally reward Tolokers who completed their tasks better than others.
Connect the Toloka-Kit library to your script.
import toloka.client as toloka
Replace the sample API key with your own one.
toloka_client = toloka.TolokaClient('PlaceYourRealApiKey_Here', 'PRODUCTION');
Now create the bonus for the Toloker. For this, you need the following information:
from decimal import Decimal
new_bonus = toloka_client.create_user_bonus(toloka.user_bonus.UserBonus(
user_id='a1b0b42923c429daa2c764d7ccfc364d',
amount=Decimal('0.50'), public_title={'EN': 'Perfect job!'} public_message={'EN': 'You are the best!'} assignment_id='000015fccc--63bfc4c358d7a46c32a7b233'))
The create_user_bonus()
request will return the UserBonus class object. You can use its attributes to print the information you need.
print(new_bonus.created)
You should get an output with the date and time when you issued the bonus which looks like this.
2023-01-12 13:45:36.767000+00:00
from decimal import Decimalimport toloka.client as tolokatoloka_client = toloka.TolokaClient('PlaceYourRealApiKey_Here', 'PRODUCTION')new_bonus = toloka_client.create_user_bonus(toloka.user_bonus.UserBonus( user_id='a1b0b42923c429daa2c764d7ccfc364d', amount=Decimal('0.50'), public_title={'EN': 'Perfect job!'}, public_message={'EN': 'You are the best!'}, assignment_id='000015fccc--63bfc4c358d7a46c32a7b233'))print(new_bonus.created)
Last updated: February 7, 2023