That would be wp_get_object_terms
. You’d need an array of post id’s as the input, together with the taxonomy you want to retrieve the terms for (let’s say: books). This should work (untested):
$my_query = new wp_query ($args);
$my_posts = $my_query->posts;
$my_post_ids = wp_list_pluck ($my_posts, 'ID');
$my_terms = wp_get_object_terms ($my_post_ids, 'books');