In case of exceptions on the REST-V1 / REST-V20 this API can (possibly) provide extra information regarding the status of the services.
import sys
import json
import oandapyV20
from oandapyV20.exceptions import V20Error
import oandapyV20.contrib.healthAPI as health
# for time being: add health URL's to available environments
setattr(sys.modules["oandapyV20.oandapyV20"],
"TRADING_ENVIRONMENTS",
{"health": {
"stream": "http://api-status.oanda.com",
"api": "http://api-status.oanda.com",
}})
api = oandapyV20.API(access_token=None, environment="health")
r = health.Services()
print("REQ: {}".format(r))
try:
api.request(r)
except Exception as err:
print("Pretty bad! health service not accessible")
exit(2)
else:
print("{}".format(json.dumps(r.response, indent=2)))
print("# services: ", len(r.response['services']))
# show some info
for service in r.response['services']:
print('ID : {}'.format(service['id']))
print('DESC: {}'.format(service['name']))
print('ST: {}'.format(service.get('current-event').get('status').get('description')))
Provide support to the health-API endpoints.
In case of exceptions on the REST-V1 / REST-V20 this API can (possibly) provide extra information regarding the status of the services.