# How to use api for fetching order margin

**URL:** https://tradebetter.5paisa.com/t/how-to-use-api-for-fetching-order-margin/449
**Category:** Xstream APIs 👨🏻‍💻
**Created:** [July 9, 2025, 5:16am UTC](https://tradebetter.5paisa.com/t/how-to-use-api-for-fetching-order-margin/449 "2025-07-09T05:16:12Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Aryan\_Charan](https://avatars.discourse-cdn.com/v4/letter/a/e274bd/32.png) [@Aryan\_Charan](https://tradebetter.5paisa.com/u/Aryan_Charan)
#### Post date: [July 9, 2025, 5:16am UTC](https://tradebetter.5paisa.com/t/how-to-use-api-for-fetching-order-margin/449/1 "2025-07-09T05:16:12Z")

</div>

How to use the order margin function of python sdk  
No matter what args i use it throws none/body

And upon inspection i found that the url [https://Openapi.5paisa.com/VendorsAPI/Service1.svc/V1/PreOrdMarginCalculationVendor](https://Openapi.5paisa.com/VendorsAPI/Service1.svc/V1/PreOrdMarginCalculationVendor)  
Throws error 500 no matter the content in request which shows that its a server side error, because wrong credentials or request result in error 400/403

Help appreciated

---

<div class="post-metadata">

### Author: ![bhavesh\_shirode](https://dub1.discourse-cdn.com/flex018/user_avatar/tradebetter.5paisa.com/bhavesh_shirode/32/60_2.png) [@bhavesh\_shirode](https://tradebetter.5paisa.com/u/bhavesh_shirode)
#### Post date: [July 16, 2025, 12:28pm UTC](https://tradebetter.5paisa.com/t/how-to-use-api-for-fetching-order-margin/449/2 "2025-07-16T12:28:13Z")

</div>

@Aryan_Charan We have now migrated to new API which helps user calculate margin for either single or multiple orders. Please find the python documentation for it below.

Orders = [  
{  
“Exch”: “N”,  
“ExchType”: “C”,  
“ScripCode”: 2885,  
“ScripData”: “”,  
“PlaceModifyCancel”: “P”,  
“OrderType”: “S”,  
“Price”: 0,  
“Qty”: 1,  
“IsIntraday”: False  
},  
{  
“Exch”: “N”,  
“ExchType”: “C”,  
“ScripCode”: 1660,  
“ScripData”: “”,  
“PlaceModifyCancel”: “P”,  
“OrderType”: “S”,  
“Price”: 0,  
“Qty”: 1,  
“IsIntraday”: False  
},  
{  
“Exch”: “N”,  
“ExchType”: “D”,  
“ScripCode”: 52538,  
“ScripData”: “”,  
“PlaceModifyCancel”: “P”,  
“OrderType”: “S”,  
“Price”: 0,  
“Qty”: 75,  
“IsIntraday”: False  
}  
]

a = client.multi\_order\_Margin(CoverPositions=‘Y’, Orders=Orders)  
print(a)
