It would be helpful to understand what you're trying to do when the button is clicked to suggest a possible solution.
The python script is an API of other program.
I need call this API when click a button to make that program do something.
Do you need to use the results of a search to send to an API for validation? I'm still not understanding what exactly you're trying to accomplish and what the workflow is. If so, you could probably handle this with a custom search command.