After installing the “add-category-to-page”, I needed the endpoint to extract the wanted pages. So I included the following code in a customized plugin I have.

<?php
include_once '../config.php';
$ENDPOINTS_COMMON_BASE = ENDPOINT_BASE . '/' . PLUGIN_VERSION;
add_action('rest_api_init', function () {
global $ENDPOINTS_COMMON_BASE;
register_rest_route($ENDPOINTS_COMMON_BASE, '/pages-by-category/', array(
'methods' => 'GET',
'callback' => 'get_pages_by_category',
'args' => array(
'category' => array(
'required' => true,
'validate_callback' => function ($param, $request, $key) {
return is_string($param);
}
),
),
));
register_rest_route($ENDPOINTS_COMMON_BASE, '/pages-by-tag/', array(
'methods' => 'GET',
'callback' => 'get_pages_by_tag',
'args' => array(
'tag' => array(
'required' => true,
'validate_callback' => function ($param, $request, $key) {
return is_string($param);
}
),
),
));
});
function get_pages_by_category($request)
{
$category = $request->get_param('category');
$args = array(
'post_type' => 'page',
'tax_query' => array(
array(
'taxonomy' => 'category',
'field'    => 'slug',
'terms'    => $category,
),
),
);
$query = new WP_Query($args);
// return new WP_REST_Response($query, 200);
$pages = array();
if ($query->have_posts()) {
while ($query->have_posts()) {
$query->the_post();
$pages[] = array(
'id'    => get_the_ID(),
'title' => get_the_title(),
'content' => get_the_content(),
);
}

}
wp_reset_postdata();
return new WP_REST_Response($pages, 200);
}
function get_pages_by_tag($request)
{
$tag = $request->get_param('tag');
// return new WP_REST_Response($category, 200);
$args = array(
'post_type' => 'page',
'tax_query' => array(
array(
'taxonomy' => 'post_tag',
'field'    => 'slug',
'terms'    => $tag,
),
),
);
$query = new WP_Query($args);
$pages = array();
if ($query->have_posts()) {
while ($query->have_posts()) {
$query->the_post();
$pages[] = array(
'id'    => get_the_ID(),
'title' => get_the_title(),
'content' => get_the_content(),
);
}
}
wp_reset_postdata();
return new WP_REST_Response($pages, 200);
}

After this, now I can access the endpoint using a tag or category filter:

https://.....somepage..../wp-json/...pluginname..../V2/pages-by-tag?tag=sometag

and I get the filtered page

[{"id":18514,"title":" ...
page content here
...
e together and helping them.<\/p>\n<!-- \/wp:paragraph -->"}]