Get list of message threads

Get the list of all the message threads present in a specific folder in your account.

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 message thread IDs and topics

Iterate through all the message threads calling the get_message_threads() method.

for message_thread in toloka_client.
get_message_threads
(folder=['INBOX', 'UNREAD']):

topic=message_thread.topic

print(message_thread.id, topic.get('EN') or list(topic.values())[0])

You should get an output with the message thread IDs and topics which looks like this.

63c00f08138adb3ab310b2a5 Perfect job!
63c1573b138adb3ab310b2af Thank you!

Complete code: Get list of message threads

import toloka.client as toloka
toloka_client = toloka.TolokaClient('PlaceYourRealApiKey_Here', 'PRODUCTION')
for message_thread in toloka_client.get_message_threads(folder=['INBOX', 'UNREAD']):
topic=message_thread.topic
print(message_thread.id, topic.get('EN') or list(topic.values())[0])
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