Get list of files in responses

List all the files attached to the Toloker responses in a pool.

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. List attachments

Find out the ID of the pools for which you want to get all the files attached to the Toloker responses. Then iterate through all the attachments calling the get_attachments() method.

for attachment in toloka_client.
get_attachments
(pool_id='1085757'):

print(attachment.id, attachment.name)

You should get an output that contains the IDs of the attachments and file names. It will look like this.

fr.5867be74-249b-4264-9ed0-aa5d4c201846 gx6864-almost-blue-1.jpg
fr.c548ebeb-dd92-4b2b-8113-4a69af1471ba nike_104090949.png
fr.cd9cdda5-4af6-4be9-b351-678b2b4e189f 37540601-sneaker-search.jpg

Complete code: Get list of files in responses

import toloka.client as toloka
toloka_client = toloka.TolokaClient('PlaceYourRealApiKey_Here', 'PRODUCTION')
for attachment in toloka_client.get_attachments(pool_id='1085757'):
print(attachment.id, attachment.name)
List of classes and methods used in this recipe

See also

Last updated: February 7, 2023

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