Given a book node nid, programmatically get all child node nids
To get the complete list of child node nids for the book:
use the BookOutlineStorage::loadBookChildren from the book.outline_storage service.
like the following:
/** @var \Drupal\book\BookOutlineStorageInterface $book_outline_storage */
$book_outline_storage = \Drupal::service('book.outline_storage');
$childrens  =  $book_outline_storage-&gt;loadBookChildren(NID);