Get a group with members
This example demonstrates how to retrieve a group by ID in ONLYOFFICE DocSpace and include its members in the response.
Before you start
- Replace
https://yourportal.onlyoffice.comandYOUR_API_KEYwith your actual DocSpace portal URL and API key. Ensure you have the necessary data and permissions to perform migration operations. - Before you can make requests to the API, you need to authenticate. Check out the Personal access tokens page to learn how to obtain and use access tokens.
Full example
- Node.js
- Python
// Set your DocSpace portal URL and API key
const API_HOST = 'https://yourportal.onlyoffice.com';
const API_KEY = 'your_api_key';
const GROUP_ID = '08e455dc-98c4-4390-b36f-54757080149c'; // Replace with your actual group ID
// Headers with API key
const headers = {
Authorization: API_KEY,
};
// Step 1: Get group by ID with members included
function getGroupWithMembers(groupId) {
const params = new URLSearchParams({ includeMembers: 'True' });
const url = `${API_HOST}/api/2.0/group/${groupId}?${params.toString()}`;
return fetch(url, { method: 'GET', headers })
.then((res) => {
if (res.status === 200) return res.json();
return res.text().then((t) => {
console.log(`Group retrieval failed. Status code: ${res.status}, Message: ${t}`);
return null;
});
})
.then((data) => {
const group = data?.response || {};
console.log(`Group: ${group.name}`);
console.log('Members:');
(group.members || []).forEach((m) => {
console.log(`- ${m.id} — ${m.displayName}`);
});
return group;
})
.catch((err) => {
console.log(`Group retrieval error: ${err.message}`);
return null;
});
}
// Run the method
console.log('Getting group with members...');
getGroupWithMembers(GROUP_ID);
import requests
# Set your DocSpace portal URL and API key
API_HOST = 'https://yourportal.onlyoffice.com'
API_KEY = 'your_api_key'
GROUP_ID = '08e455dc-98c4-4390-b36f-54757080149c' # Replace with your actual group ID
# Headers with API key
headers = {
'Authorization': API_KEY
}
# Step 1: Get group by ID with members included
def get_group_with_members(group_id):
url = f'{API_HOST}/api/2.0/group/{group_id}'
params = {'includeMembers': True}
response = requests.get(url, headers=headers, params=params)
if response.status_code == 200:
group = response.json().get('response', {})
print(f'Group: {group.get('name')}')
print('Members:')
for m in group.get('members', []):
print(f'- {m.get('id')} — {m.get('displayName')}')
else:
print(f"Group retrieval failed. Status code: {response.status_code}, Message: {response.text}")
# Run the method
if __name__ == '__main__':
print('Getting group with members...')
get_group_with_members(GROUP_ID)
How it works
A GET request is sent to /api/2.0/group/:id with the following query parameter:
includeMembers: true— include the list of group members in the response.
If successful, the API returns group details such as:
name— group display namemembers— array of member objects, each containing:id— unique member identifier (UUID)displayName— full name of the member