How to make external api call from custom plugin?

I made a plugin for issue-detail page and I want a button click to trigger an external api call to my service. What is the best practice of it ?

Should I wrote a java function and trigger it from velocity template or should I trigger a javascript function?

If the answer is javascript, can someone provide me an example ?