toloka.client.TolokaClient
| Source code
TolokaClient( self, token: str, environment: Union[Environment, str, None] = None, retries: Union[int, Retry] = 3, timeout: Union[float, Tuple[float, float]] = 10.0, url: Optional[str] = None, retry_quotas: Union[List[str], str, None] = 'MIN', retryer_factory: Optional[Callable[[], Retry]] = None, act_under_account_id: Optional[str] = None, verify: Union[str, bool, SSLContext] = True)
A class that implements interaction with Toloka API.
Objects of other classes are created and modified only in memory of your computer.
You can transfer information about these objects to Toloka only by calling one of the TolokaClient
methods.
For example, creating an instance of Project
class will not add a project to Toloka right away. It will create a Project
instance in your local memory.
You need to call the TolokaClient.create_project
method and pass the created project instance to it.
Likewise, if you read a project using the TolokaClient.get_project
method, you will get an instance of Project
class.
But if you change some parameters in this object manually in your code, it will not affect the existing project in Toloka.
Call TolokaClient.update_project
and pass the Project
to apply your changes.
Starting July 1, 2024 Sandbox environment is unavailable.
Parameters | Type | Description |
---|---|---|
token | str | Your OAuth token for Toloka. You can learn more about how to get it here |
environment | Union[Environment, str, None] | There are two environments in Toloka:
You need to register in each environment separately. OAuth tokens are generated in each environment separately too. Default value: |
retries | Union[int, Retry] | Retry policy for failed API requests. Possible values:
Default value: |
timeout | Union[float, Tuple[float, float]] | Number of seconds that Requests library will wait for your client to establish connection to a remote machine. Possible values:
Default value: |
url | Optional[str] | Set a specific URL instead of Toloka environment. May be useful for testing purposes. You can only set one parameter – either Default value: |
retry_quotas | Union[List[str], str, None] | List of quotas that must be retried. Set
Default value: |
retryer_factory | Optional[Callable[[], Retry]] | Factory that creates Default value: |
act_under_account_id | Optional[str] | ID of the requester that has been shared access with the current token owner account. All requests will be made using a specified account. See Shared access to the requester's account documentation page. ID of the requester can be retrieved using the get_requester method (this method should be called by the account owner using account's token). |
verify | Union[str, bool, SSLContext] | SSL certificates (a.k.a CA bundle) used to verify the identity of requested hosts. Either |
Examples:
How to create TolokaClient
instance and make your first request to Toloka.
import tolokayour_oauth_token = input('Enter your token:')toloka_client = toloka.client.TolokaClient(your_oauth_token, 'PRODUCTION') # Or switch to 'SANDBOX' environment
toloka_client
instance will be used to pass all API calls later on.
Method | Description |
---|---|
accept_assignment | Accepts an assignment. |
add_message_thread_to_folders | Adds a message thread to folders. |
aggregate_solutions_by_pool | Starts aggregation of responses in all completed tasks in a pool. |
aggregate_solutions_by_task | Aggregates responses to a single task on the Toloka server. |
archive_app_project | Archives an App project. |
archive_pool | Archives a pool. |
archive_pool_async | Archives a pool. Sends an asynchronous request to Toloka. |
archive_project | Archives a project. |
archive_project_async | Archives a project. Sends an asynchronous request to Toloka. |
archive_training | Archives a training. |
archive_training_async | Archives a training. Sends an asynchronous request to Toloka. |
clone_pool | Clones an existing pool. |
clone_pool_async | Clones an existing pool. Sends an asynchronous request to Toloka. |
clone_project | Clones a project and all pools and trainings inside it. |
clone_training | Clones an existing training. |
clone_training_async | Clones an existing training. Sends an asynchronous request to Toloka. |
close_pool | Closes a pool. |
close_pool_async | Closes a pool. Sends an asynchronous request to Toloka. |
close_pool_for_update | Closes a pool that is to be updated. |
close_pool_for_update_async | Closes a pool that is to be updated. Sends an asynchronous request to Toloka. |
close_training | Closes a training. |
close_training_async | Closes a training. Sends an asynchronous request to Toloka. |
compose_message_thread | Creates a message thread and sends the first thread message to Tolokers. |
create_app_batch | Creates a batch with task items in an App project in Toloka. |
create_app_item | Creates an App task item in Toloka. |
create_app_items | Creates task items in an App project in Toloka and adds them to an existing batch. |
create_app_project | Creates an App project in Toloka. |
create_pool | Creates a new pool in Toloka. |
create_project | Creates a new project in Toloka. |
create_skill | Creates a new skill. |
create_task | Creates a new task in Toloka. |
create_task_suite | Creates a task suite in Toloka. |
create_task_suites | Creates several task suites in Toloka. |
create_task_suites_async | Creates several task suites in Toloka asynchronously. |
create_tasks | Creates several tasks in Toloka. |
create_tasks_async | Creates tasks in Toloka asynchronously. |
create_training | Creates a new training in Toloka. |
create_user_bonus | Issues a bonus payment to a Toloker. |
create_user_bonuses | Issues several bonus payments to Tolokers. |
create_user_bonuses_async | Issues bonus payments to Tolokers asynchronously. |
delete_user_restriction | Removes existing restriction. |
delete_user_skill | Removes a skill from a Toloker. |
delete_webhook_subscription | Deletes a subscription. |
download_attachment | Downloads an attachment. |
find_aggregated_solutions | Finds aggregated responses that match certain criteria. |
find_app_batches | Finds batches that match certain criteria in an App project. |
find_app_items | Finds task items that match certain criteria in an App project. |
find_app_projects | Finds App projects that match certain criteria. |
find_apps | Finds App solutions that match certain criteria. |
find_assignments | Finds assignments that match certain criteria. |
find_attachments | Finds attachments that match certain criteria and returns their metadata. |
find_message_threads | Finds message threads that match certain criteria. |
find_operations | Finds operations that match certain criteria. |
find_pools | Finds pools that match certain criteria. |
find_projects | Finds projects that match certain criteria. |
find_skills | Finds skills that match certain criteria. |
find_task_suites | Finds task suites that match certain criteria. |
find_tasks | Finds tasks that match certain criteria. |
find_trainings | Finds trainings that match certain criteria. |
find_user_bonuses | Finds Tolokers' bonuses that match certain criteria. |
find_user_restrictions | Finds Toloker restrictions that match certain criteria. |
find_user_skills | Finds Toloker's skills that match certain criteria. |
find_webhook_subscriptions | Finds webhook subscriptions that match certain criteria. |
get_aggregated_solutions | Finds all aggregated responses that match certain criteria. |
get_analytics | Sends analytics requests to Toloka. |
get_app | Gets information from Toloka about an App solution. |
get_app_batch | Gets information from Toloka about a batch in an App project. |
get_app_batches | Finds all batches that match certain criteria in an App project. |
get_app_item | Gets information from Toloka about an App task item. |
get_app_items | Finds all App task items that match certain criteria in an App project. |
get_app_project | Gets information from Toloka about an App project. |
get_app_projects | Finds all App projects that match certain criteria. |
get_apps | Finds all App solutions that match certain criteria. |
get_assignment | Gets an assignment from Toloka. |
get_assignments | Finds all assignments that match certain criteria. |
get_assignments_df | Downloads assignments as pandas.DataFrame. |
get_attachment | Gets attachment metadata without downloading it. |
get_attachments | Finds all attachments that match certain criteria and returns their metadata. |
get_message_threads | Finds all message threads that match certain criteria. |
get_operation | Gets information about an operation from Toloka. |
get_operation_log | Gets an operation log. |
get_operations | Finds all operations that match certain criteria. |
get_pool | Gets pool data from Toloka. |
get_pools | Finds all pools that match certain criteria. |
get_project | Gets project data from Toloka. |
get_projects | Finds all projects that match certain criteria. |
get_requester | Gets information about the requester and the account balance. |
get_skill | Gets skill information from Toloka. |
get_skills | Finds all skills that match certain criteria. |
get_task | Gets a task with specified ID from Toloka. |
get_task_suite | Gets task suite data from Toloka. |
get_task_suites | Finds all task suites that match certain criteria. |
get_tasks | Finds all tasks that match certain criteria. |
get_training | Gets information about a training from Toloka. |
get_trainings | Finds all trainings that match certain criteria. |
get_user | Gets information about a Toloker. |
get_user_bonus | Gets information about a Toloker's bonus. |
get_user_bonuses | Finds all Tolokers' bonuses that match certain rules and returns them in an iterable object |
get_user_restriction | Gets information about a Toloker restriction. |
get_user_restrictions | Finds all Toloker restrictions that match certain criteria. |
get_user_skill | Gets the value of a Toloker's skill. |
get_user_skills | Finds all Toloker's skills that match certain criteria. |
get_webhook_subscription | Gets the properties of a subscription from Toloka. |
get_webhook_subscriptions | Finds all webhook subscriptions that match certain criteria. |
open_pool | Opens a pool. |
open_pool_async | Opens a pool. Sends an asynchronous request to Toloka. |
open_training | Opens a training. |
open_training_async | Opens a training. Sends an asynchronous request to Toloka. |
patch_app_batch | Updates an App batch. |
patch_assignment | Changes an assignment status and associated public comment. |
patch_pool | Changes pool parameters in Toloka. |
patch_task | Changes a task overlap value. |
patch_task_overlap_or_min | Stops assigning a task to Tolokers. |
patch_task_suite | Changes task suite parameter values in Toloka. |
patch_task_suite_overlap_or_min | Stops assigning a task suite to Tolokers. |
reject_assignment | Rejects an assignment. |
remove_message_thread_from_folders | Removes a message thread from folders. |
reply_message_thread | Sends a reply message in a thread. |
resume_app_batch | Resumes annotation of a batch of task items in an App project. |
set_user_restriction | Restricts access to projects or pools for a Toloker. |
set_user_skill | Assigns a skill to a Toloker. |
start_app_batch | Launches annotation of a batch of task items in an App project. |
stop_app_batch | Stops annotation of a batch of task items in an App project. |
unarchive_app_project | Unarchives an App project. |
update_pool | Updates all pool parameters in Toloka. |
update_project | Updates all project parameters in Toloka. |
update_skill | Updates all skill parameters in Toloka. |
update_training | Updates parameters of a training in Toloka. |
upsert_webhook_subscriptions | Creates subscriptions. |
wait_operation | Waits for a Toloka operation to complete. |
Last updated: August 28, 2023