wp admin – wrapping the function & rest_api_init & # 39; in & # 39; is_admin () & # 39;

I'm creating a personalized administration page through add_menu_page, imagine that my custom page has url

wp-admin / admin.php? page = settings_page

then I am checki is_admin () function through var_dump In Myself settings_page And come back true – Okay, but when I'm wrapped rest_api_init action in if is_admin () statement, how is it:

if (is_admin ()) {
add_action (& # 39; rest_api_init & # 39 ;,   [$this, 'myRegisterRoutesFunction']);
}

I returned 404 - No route matching the URL and the request method was found. But if I take off Yes statement, it works well. I do not understand why, thanks for the tips!