Calling a Rest API with parameters on button Click

@TomJNowell pointed you the way to go. You have to enqueue a JS file, and within this JS file you can use any technique to do the REST request, like an XMLHttpRequest object or the fetch API. The REST API itself, of course, is part of WordPress, and defined with register_rest_route(). It is also something you have to provide either within the theme or within a plugin.

Both the JS and the REST API should be part of the same component – i.e. the theme or a plugin.

how do I call an external API hosted on RapidAPI

A web browser does not allow JS functions to invoke a request to another domain name than the originating one.