Overview
The .NET SDK is a wrapper of the Noren API combining REST calls and WebSocket streaming for trading. It targets .NET Standard 2.0, built on Visual Studio 2019, with a dependency on Newtonsoft.Json 9.0.1. The namespace is NorenRestApiWrapper; the primary class is NorenRestApi.
Callback-based, not async/awaitEvery request method takes a delegate — public delegate void OnResponse(NorenResponseMsg Response, bool ok) — rather than returning a Task. Structure your calling code around callbacks, not await, when integrating this SDK.
Installation
Clone the repository and reference the project directly, or pull the compiled dependency from the Deps folder — there's no NuGet package as of this writing. Example projects are included: Example1, Example2_InlineHandler, Example3_Websocket, and Example4_oauth for the OAuth flow specifically.
Initialization
| Parameter | Description |
endPoint | https://api.shoonya.com/OAuthlogin/authorize/oauth. |
Appkey | The secret key issued to you — do not append the user ID to it. |
Create an instance of NorenRestApi to make requests. Every request method takes an OnResponse callback delegate as its first argument.
OAuth & Session Methods
| Method | Description |
SendgetOAuthURL(oauth_url, client_id) | Requests the OAuth provider to initiate verification with the end user. Returns a URL to open in a browser; on success, the redirect provides auth_code. |
SendgetAccessToken(response, endPoint, authCode, secretcode, client_id, uid) | Exchanges auth_code for an access token via the OnResponse callback, returning a GetAccessTokenResponse with access_token, susertoken, refresh_token, and actid. |
SendGetUserDetails(response) | Fetches enabled exchanges, order types, and product types for the logged-in user. |
SendLogout(response) | Terminates the current session. |
SetSession(endpoint, uid, pwd, usertoken) | Initializes the API with an existing session instead of creating a new one via login. |
Available Functionality
| Category | Methods |
| WatchLists | SendGetMWList, SendGetMarketWatch, SendAddMultiScripsToMW, SendDeleteMultiMWScrips |
| Market | SendSearchScrip, SendGetSecurityInfo, GetQuote, time/daily price series, GetOptionChain, GetIndexList, ExchMsg, top-list methods |
| Calculators | span_calculator, get_option_greek, GetBrokerage |
| Orders & Trades | SendPlaceOrder, SendModifyOrder, SendCancelOrder, SendExitSNOOrder, SendProductConversion, SendGetOrderMargin, SendGetOrderBook, SendGetTradeBook, SendGetOrderHistory, SendGetMultiLegOrderBook, SendGetPositionBook, SendGetHoldings, SendGetLimits |
| Streaming | Connect, SubscribeMarketData, UnSubscribeMarketData, SubscribeOrderUpdate |
Order types beyond a plain LMT/SL-LMT buy/sell are supported here — PlaceOrder covers Cover Orders (prd = H) and Bracket Orders (prd = B) with blprc/bpprc/trailprc fields, unlike the REST Place Order endpoint documented elsewhere on this site, which rejects CO/BO. Confirm which product types your account is enabled for before relying on this.
Best Practices
- Design around the callback signature (
OnResponse) from the start — retrofitting async/await over a callback-based SDK later is more work than structuring for it up front.
- Cast the
NorenResponseMsg in your callback to the specific response type documented for that call (e.g. GetAccessTokenResponse, PlaceOrderResponse) and check stat == "Ok" before reading any other field.
- Cover Orders and Bracket Orders (
prd = H / B) are supported here but not on the plain REST Place Order endpoint — don't assume feature parity between this SDK and the raw HTTP API when porting code between platforms.
- Reference the
Example4_oauth project in the repository for a complete working OAuth handshake — it's the fastest way to confirm your endPoint and Appkey are configured correctly before writing your own integration.
- Same as the Python SDK, this wrapper doesn't auto-refresh an expired token — pair it with Token Renewal for unattended processes.
Overview
The .NET SDK is a wrapper of the Noren API combining REST calls and WebSocket streaming for trading. It targets .NET Standard 2.0, built on Visual Studio 2019, with a dependency on Newtonsoft.Json 9.0.1. The namespace is
NorenRestApiWrapper; the primary class isNorenRestApi.public delegate void OnResponse(NorenResponseMsg Response, bool ok)— rather than returning aTask. Structure your calling code around callbacks, notawait, when integrating this SDK.Installation
NorenRestApiWrapperNorenRestApiClone the repository and reference the project directly, or pull the compiled dependency from the
Depsfolder — there's no NuGet package as of this writing. Example projects are included:Example1,Example2_InlineHandler,Example3_Websocket, andExample4_oauthfor the OAuth flow specifically.Initialization
endPointAppkeyCreate an instance of
NorenRestApito make requests. Every request method takes anOnResponsecallback delegate as its first argument.OAuth & Session Methods
SendgetOAuthURL(oauth_url, client_id)auth_code.SendgetAccessToken(response, endPoint, authCode, secretcode, client_id, uid)auth_codefor an access token via theOnResponsecallback, returning aGetAccessTokenResponsewithaccess_token,susertoken,refresh_token, andactid.SendGetUserDetails(response)SendLogout(response)SetSession(endpoint, uid, pwd, usertoken)Available Functionality
SendGetMWList,SendGetMarketWatch,SendAddMultiScripsToMW,SendDeleteMultiMWScripsSendSearchScrip,SendGetSecurityInfo,GetQuote, time/daily price series,GetOptionChain,GetIndexList,ExchMsg, top-list methodsspan_calculator,get_option_greek,GetBrokerageSendPlaceOrder,SendModifyOrder,SendCancelOrder,SendExitSNOOrder,SendProductConversion,SendGetOrderMargin,SendGetOrderBook,SendGetTradeBook,SendGetOrderHistory,SendGetMultiLegOrderBook,SendGetPositionBook,SendGetHoldings,SendGetLimitsConnect,SubscribeMarketData,UnSubscribeMarketData,SubscribeOrderUpdateOrder types beyond a plain
LMT/SL-LMTbuy/sell are supported here —PlaceOrdercovers Cover Orders (prd = H) and Bracket Orders (prd = B) withblprc/bpprc/trailprcfields, unlike the REST Place Order endpoint documented elsewhere on this site, which rejectsCO/BO. Confirm which product types your account is enabled for before relying on this.Quick Start Example
Best Practices
OnResponse) from the start — retrofitting async/await over a callback-based SDK later is more work than structuring for it up front.NorenResponseMsgin your callback to the specific response type documented for that call (e.g.GetAccessTokenResponse,PlaceOrderResponse) and checkstat == "Ok"before reading any other field.prd = H/B) are supported here but not on the plain REST Place Order endpoint — don't assume feature parity between this SDK and the raw HTTP API when porting code between platforms.Example4_oauthproject in the repository for a complete working OAuth handshake — it's the fastest way to confirm yourendPointandAppkeyare configured correctly before writing your own integration.