I've examined this, this and this and more.
The best example I found was replacing the "wp-json" slug (which I can't add code here right now).
localhost/wp-json/wp/v2
localhost/api/wp/v2
While you can make a change like above. So how can we change the rest of the URL? Okay, I'm not saying "endpoint" or "route" change. I'm still talking about a prefix change.
Ok this way was very good: localhost/api/wp/v2 well how do we change the wp/v2? Can you actually do something like localhost/api/posts if you look at it? Because we want to remove wp/v2.
Well, it's also possible: localhost/api/any/posts.