You could create a common library for the API you specified. I am using Python, so probably I will work utilize the urllib3 module. python - urllib3 how to find code and message of Http error - Stack Overflow
if you want to implemen retry logic you could use while == True, if its pass the error break the it with False. If certain try still error you could use sys.exit()
Hope it helps you
Cheers