This adds a path parameter and adjusts the query being made on the request accordingly:
add_filter('rest_page_query', function ($args, $request){
$path = $request->get_param('path');
if (!empty($path)) {
$pageByPath = get_page_by_path($path, OBJECT, 'page');
// overwrite the page id with the page id by path
$args['p'] = $pageByPath->ID;
}
return $args;
}, 10, 2);
Allowing you to request a specific sub page like this:
.../wp-json/wp/v2/pages?path=/pageslug/subpageslug/