Issue when trying to use API with response codes

Issue when trying to use API with response codes

In the API documentation, it shows that when a call is made there is always a response code that is returned either a 0 or some other non zero code. I am trying to write a script that will output data if it returns 0 or the message if not. In the API documentation, it shows that when a call is made there is always a response code that is returned either a 0 or some other non zero code. I am trying to write a python script that will output data if it returns 0 or the message if not.

My problem is that when I get a success I see the following:

{
    "code" : 0,
    "message" : "success",
    "data" : {
        "monitor_id" : "..."
    }
}

But when it fails I see the following:

{
    "error_code": 1001,
    "message": "Resource not found."
}

As per the Documentation, I read the following:

Responses will be in the JSON format.

JSON RESPONSE PARAMETERS

Node Name Description
code Site24x7 error code. Indicates zero for a success response and non-zero in case of an error.
message Status Message for the invoked API.
data Comprising the invoked API’s Data.

Is there a reason for the different naming as in code vs error_code

I'm trying to do something like:

if code == 0:
print 'data'
if code !=0:
print 'data'

Any help you can offer will be useful. Maybe I'm doing this wrong?