Extract a list of room users via python

Extracting users from a room can be a difficult task, especially when the room is large and contains over 100 users. 


The Python script below has been developed to help you to retrieve the user details from a specific room more easily.




Before executing the Python script, please ensure you have all three of the following:


  • Pod URL: The URL you use to login to Symphony, for example, https://companyabc.symphony.com/ 
  • Room/Conversation ID: Refer to the Knowledge Article found here on how to obtain the room/conversation ID
  • A valid SessionToken: Refer to the Knowledge Article found here on how to generate RSA key pairs and perform the required steps

Note: The room ID should be in URLSafe Base64 encoding. To obtain the URLSafe Base64 room ID, replace forward slashes with underscores, replace pluses with minuses, and ignore any trailing equal signs


Once you have the three required parameters, they can be passed into the script to generate and retrieve the user details.


Python Script


Run the script below to extract the list of room users:

import requests

# Function here will pass the userid to the new API call to obtain the names of the user
def retrieve_names(podname, userid, session_token):
    url = "https://"+str(podname)+".symphony.com/pod/v3/users?uid=" + str(userid)
    headers = {
        'sessionToken': str(session_token),
        'Cache-Control': "no-cache",
        'Connection': "keep-alive"
    user_response = requests.request("GET", url, headers=headers)
    record = user_response.json()
    firstname = record['users'][0]['firstName']
    lastname = record['users'][0]['lastName']
    displayname = record['users'][0]['displayName']

    # Here it will print out the data. Once finished you can copy and paste somewhere.
    # print(record)
    print('userid: ' + str(userid) + ' | firstname: ' + firstname + ' | lastname: ' + lastname + ' | displayname: ' + displayname)

# Function here will retrieve the users in the room and pass each id to the "retrieve_names" function
def retrieve_room_users(podname, streamid, session_token):
    url = "https://"+str(podname)+".symphony.com/pod/v2/room/" + str(streamid) + "/membership/list"

    headers = {
        'sessionToken': str(session_token),
        'Cache-Control': "no-cache",
        'Connection': "keep-alive"
    response = requests.request("GET", url, headers=headers)
    list = response.json()
    usercount = len(list)
    for uid in list:
        thisid = uid['id']
        retrieve_names(podname, thisid, session_token)

# Run query from here

# first parameter is your PODNAME, replace PODNAME with your actual PODNAME
# second parameter is your STREAMID, replace STREAMID with the actual room STREAMID
# third parameter is your SESSIONTOKEN, replace SESSIONTOKEN with the actual SESSIONTOKEN

retrieve_room_users('PODNAME', 'STREAMID', "SESSIONTOKEN")


Note: Refer to the API endpoint for further parameters available in extracting user information


Note: This is an unsupported script created by Symphony which you use at your own risk. Symphony are not liable for any error(s) which may occur