Namaskara,
For example in get order details the response is as follows:
{
“status”: “success”,
“data”: {
“exchange”: “NSE”,
“product”: “D”,
“price”: 571.0,
“quantity”: 1,
“status”: “complete”,
“tag”: null,
“instrument_token”: “NSE_EQ|INE062A01020”,
“placed_by”: “******”,
“trading_symbol”: “SBIN-EQ”,
“tradingsymbol”: “SBIN-EQ”,
“order_type”: “LIMIT”,
“validity”: “DAY”,
“trigger_price”: 0.0,
“disclosed_quantity”: 0,
“transaction_type”: “BUY”,
“average_price”: 570.95,
“filled_quantity”: 1,
“pending_quantity”: 0,
“status_message”: null,
“status_message_raw”: null,
“exchange_order_id”: “1300000025660919”,
“parent_order_id”: null,
“order_id”: “231019025562880”,
“variety”: “SIMPLE”,
“order_timestamp”: “2023-10-19 13:25:13”,
“exchange_timestamp”: “2023-10-19 13:25:13”,
“is_amo”: false,
“order_request_id”: “1”,
“order_ref_id”: “GTT-C23191000044253”
}
}
I have higlighted the following Keys:
- tag
- status_message
- status_message_raw
- parent_order_id
Now these fields have a possibility of null in value field.
That is a mess to process. If not handled carefully, it leads to exceptions.
Most of your data is either a numeric (int, float) or alpha-numeric (string).
if its a numeric then state a rule that numeric zero (0) means no value. And for string field have “” to indicate that this fields is a blank field (string cannot be null by the way, it can be blank).
0 and “” are very easy to process , most importantly they dont raise an exception.
Please correct this across your api.
null → indicates very poor programming practice.
Regards
Rathnadhar K V