How to call external api from macro and use it in post-hook

I want to call external api from macro using python. And I want to call that macro in post-hook. How can I achieve it? I am getting multiple errors.