I can add a role to a document with this code:
var REST = globalvars.absoluteUrl + "/_api/SP.Sharing.DocumentSharingManager.UpdateDocumentSharingInfo";
var data = JSON.stringify({
'resourceAddress': fileAdress,
'userRoleAssignments':
[{
'__metadata': { 'type': 'SP.Sharing.UserRoleAssignment' },
'Role': role,
'UserId': sharedWith
}],
'validateExistingPermissions': false,
'additiveMode': true,
'sendServerManagedNotification': sendEmail,
'customMessage': contentEmail,
'includeAnonymousLinksInNotification': false
});
But I don't know how to retrieve this information.