WordPress REST API – get custom taxonomy category posts

You need to first register rest route for your custom taxonomy i.e. my_portfolio

add_filter( 'register_taxonomy_args', 'my_portfolio_taxonomy', 10, 2 );
 
function my_portfolio_taxonomy( $args, $taxonomy_name ) {
 
    if ( 'my_portfolio' === $taxonomy_name ) {
        $args['show_in_rest'] = true;
 
        // Optionally customize the rest_base or rest_controller_class
        $args['rest_base']             = 'my-portfolio';
        $args['rest_controller_class'] = 'WP_REST_Terms_Controller';
    }
 
    return $args;
}

After that you can access url like : http://yourdomain.in/wp-json/wp/v2/posts?my-portfolio=28

Please note 28 is custom taxonomy id. you need to add id of photos in that case