How to correctly setup plugin action code

I am no json coder, i am trying to make a simple plugin that i will use to randomly generate the name
I am on to the client side or server side code thing, my issue is

  1. I dont know what to run, server side or client, I am pulling data from an api (I got the api call setup)
  2. I dont know to to create the action at all

All i want the action to do is preform the api call and fill the selected input in it. but its not a full action, its more of a selected event of an action.
When random is clicked
call this api (Heres the result)
fill input with that result (IDK if thats right or if its fill the input with the api)