How to call API endpoint using python