Call external API in wordpress based on user input

I want to create a simple wordpress website in which I want to display a search box on a page. On searching a string in text/search box, an external API call should be made based on that string and the data returned by the API should be shown to user.
I have successfully referred code from below URL so far – https://rapidapi.com/blog/integrate-external-api-wordpress/.