Docs › Overview

Overview

Everything your team needs to integrate with the Apt. platform — REST endpoints, WebSocket feeds, and Flutter WebView embedding.

Two-phase integration

PhaseWorkstreamOwner
Phase 1Backend APIYour API / OMS team
Phase 2Frontend SDKYour mobile / web team

If any endpoint is unavailable, reach out — we're happy to discuss alternatives or a phased rollout.

Integration steps

#TaskNotes
1Authentication setupToken expiry, refresh flow, API key generation
2IP whitelistingShare Apt. server IPs for your firewall
3Provision test accounts3 accounts with Equity & F&O on NSE + BSE
4Backend endpointsREST + WebSocket per this spec
5Instrument master CSVDaily downloadable, token → symbol mapping
6Flutter WebView embedPer Frontend SDK sections
7UATEnd-to-end testing before go-live

What's in this doc

SectionEndpoints
Order ManagementPlace · Modify · Cancel
Positions & Order BookOrder history · Live positions
Account & FundsMargin · Available cash
WebSocket FeedsOrder updates · LTP
Market DataInstrument CSV · OHLC · LTP fallback
Flutter WebViewLoading state · Error handling
JS Channel BridgeWeb → Flutter messaging
File DownloadsAndroid DownloadManager

Authentication

Prerequisite for all endpoints. No changes from the v1 specification. Please confirm the items below before integration testing.

Confirm token expiry duration and the full refresh flow before we begin.

Items to confirm

ItemDetail needed
API key generationPortal, email, or programmatic?
Token expiryHow long does a session token remain valid?
Refresh flowRefresh token, or full re-authentication?
IP whitelistingMust requests come from whitelisted IPs?
Auth rate limitsAre login/refresh calls rate-limited separately?

Test Accounts

Three accounts required before integration testing begins. All must have Equity & F&O access on NSE and BSE with limited testing funds.

#AccountSegmentsExchanges
1Test Account 1Equity & F&ONSE and BSE
2Test Account 2Equity & F&ONSE and BSE
LLive / Staging AccountEquity & F&ONSE and BSE

Share credentials via a secure channel. Provision before UAT begins.

Order Management

Three endpoints for placing, modifying, and cancelling orders. All responses must include the broker order ID and a timestamp.

POST  1. Place Order

Submit a new order to the exchange.

Request fields

FieldTypeValues
symbolstringTrading symbolRequired
exchangestringNSE · BSERequired
quantityintegerNumber of unitsRequired
pricedecimalLimit price; 0 for MKTRequired
product_typeenumMIS · CNC · NRMLRequired
order_typeenumMKT · LMT · SL · SL-MRequired
validityenumDAY · IOCRequired

Response fields

FieldTypeDescription
broker_order_idstringUnique order ID from your OMS
timestampISO 8601Order acceptance time

PUT  2. Modify Order

Edit an open or pending order.

Response must confirm the updated order state — not just a success code.

FieldTypeNotes
broker_order_idstringTarget order
quantityintegerNew quantity
pricedecimalNew limit price
trigger_pricedecimalSL / SL-M only
order_typeenumMKT · LMT · SL · SL-M

DELETE  3. Cancel Order

Cancel an open or pending order by broker order ID.

If the order is already executed or cancelled, return an appropriate error — not a silent success.

FieldType
broker_order_idstring

Positions & Order Book

Read endpoints for order history and live position data including P&L.

GET  4. Order History / Order Book

All orders for the session across every status.

Required statuses

PENDING OPEN EXECUTED/ CANCELLED/ REJECTED/ FAILED

Required response fields

FieldTypeNotes
broker_order_idstringYour OMS reference
exchange_order_idstringExchange-assigned ID
placed_atISO 8601Order placement time
updated_atISO 8601Last status update time
rejection_reasonstringPopulated for REJECTED / FAILED

GET  5. Positions

Intraday (MIS) and overnight (NRML) positions across all states.

FieldTypeNotes
average_pricedecimalAverage entry price
ltpdecimalLast traded price
pnl_realiseddecimalRealised P&L
pnl_unrealiseddecimalUnrealised P&L
quantityintegerNet open quantity
product_typeenumMIS · NRML
statusenumopen · closed · partially_closed

Account & Funds

Margin and funds data for pre-order checks. Called before placing orders to validate sufficient margin.

GET  6. Funds / Limits

Must return values separately for Equity and F&O segments.

FieldTypeNotes
available_cashdecimalFree cash available
used_margindecimalMargin blocked by open positions
collateraldecimalPledged securities value
available_margindecimalNet margin available for new orders

WebSocket Feeds

Two real-time feeds required for core platform functionality.

Please share your WebSocket connection and reconnection behaviour documentation — heartbeat interval and max reconnect strategy.

WS  7. Order Update Feed

Real-time push for every order status transition.

Required transitions

PENDING OPEN EXECUTED/ CANCELLED/ REJECTED

Both broker_order_id and exchange_order_id must be present in every event.

Required event fields

FieldTypeNotes
broker_order_idstringMust be in every event
exchange_order_idstringMust be in every event
statusenumNew status after transition
timestampISO 8601Event time

WS  8. LTP Feed

Token-based live price subscription for real-time P&L and watchlist prices.

ParameterRequirement
Subscription modelToken-based (instrument token)
Minimum tokens3,000 per connection
Maximum tokens10,000 per connection
Tick frequencyPlease confirm
Partial subscription updatesPlease confirm

Market Data

Instrument master, OHLC candles, and REST LTP fallback.

9. Instrument Master (CSV)

Daily downloadable CSV: token → symbol mapping for all subscriptions and order routing.

Regenerate and publish at a fixed URL by market open each day.

ColumnTypeNotes
tokenintegerUsed in WebSocket subscriptions
trading_symbolstringExchange-standard symbol
exchangestringNSE · BSE · NFO · BFO
instrument_typestringEQ · FUT · CE · PE
lot_sizeintegerF&O instruments
tick_sizedecimalMinimum price movement
expirydateF&O only; blank for EQ

GET  10. OHLC / Historical Candles

ParameterRequirement
Timeframes1m · 15m · 1h · 1d
Candles per callMinimum 5,000
Rate limit target>20 req/sec — document if lower

Required fields per candle

FieldTypeNotes
opendecimal
highdecimal
lowdecimal
closedecimal
volumeinteger
oiintegerF&O only — Open Interest

GET  11. LTP REST Fallback

Fetch last traded price when the WebSocket LTP feed is unavailable or not yet connected.

Can be skipped if the LTP WebSocket reliably auto-reconnects with no data gap.

Flutter WebView

Embed the Apt. web app inside your Flutter app with proper loading and error states.

Loading state

Show a spinner while content loads — prevents users seeing a blank screen.

EventAction
onPageStartedSet isLoading = true
onPageFinishedSet isLoading = false
Dart
controller = WebViewController()
  ..setJavaScriptMode(JavaScriptMode.unrestricted)
  ..setNavigationDelegate(NavigationDelegate(
    onPageStarted: (url) => setState(() => isLoading = true),
    onPageFinished: (url) => setState(() => isLoading = false),
  ))
  ..loadRequest(Uri.parse('https://webtest.atoms.trade'));

// In build():
Stack(children: [
  WebViewWidget(controller: controller),
  if (isLoading)
    Container(
      color: Colors.white,
      child: const Center(child: CircularProgressIndicator()),
    ),
])

Error handling

Show an error screen instead of a blank page on load failure.

Error events

EventDescription
onHttpErrorHTTP errors (404, 500, etc.)
onWebResourceErrorNetwork failures, timeouts, DNS issues
onPageStartedReset error state on retry

Error screen must include

ElementDetail
Error iconIcons.error_outline
Message"Unable to load page"
Subtext"Please check your internet connection"
Retry buttonCalls controller.reload()

JS Channel Bridge

Communication between the Apt. web app and your Flutter host via a named JavaScript channel.

Channel spec

PropertyValue
Channel nameFlutterChannel
Supported messagenavigateToHome
PurposeNavigate back to the Flutter home screen

Available only inside the Flutter WebView. Message must exactly match navigateToHome — anything else is silently ignored.

Flutter — register channel

Dart
controller = WebViewController()
  ..setJavaScriptMode(JavaScriptMode.unrestricted)
  ..addJavaScriptChannel(
    'FlutterChannel',
    onMessageReceived: (JavaScriptMessage message) {
      if (message.message == 'navigateToHome') {
        widget.onNavigateToHome();
      }
    },
  );

Web app — send a message

JavaScript
window.FlutterChannel.postMessage('navigateToHome');

File Downloads

Download files to the Android Downloads folder using Flutter's MethodChannel and Android's DownloadManager.

Replace YOUR_PACKAGE_NAME with your Android app ID — e.g. com.example.myapp.

Flutter setup

pubspec.yaml

YAML
dependencies:
  url_launcher: ^6.2.0

Download function

Dart
final _downloadChannel = MethodChannel('YOUR_PACKAGE_NAME/download');

Future<void> triggerDownload(String url, {String? fileName}) async {
  final name = fileName ?? url.split('/').last.split('?').first;
  final safeName = name.isNotEmpty ? name : 'download';
  if (Platform.isAndroid) {
    try {
      final id = await _downloadChannel.invokeMethod<dynamic>(
        'downloadFile', {'url': url, 'fileName': safeName},
      );
      if (id != null) return;
    } catch (e) { debugPrint('Download failed: $e'); }
  }
  final uri = Uri.tryParse(url);
  if (uri != null && await canLaunchUrl(uri)) {
    await launchUrl(uri, mode: LaunchMode.externalApplication);
  }
}

Trigger from WebView

Option A — JS messaging (preferred)

JavaScript
window.FlutterChannel?.postMessage(
  JSON.stringify({ type: 'download', url: fileUrl })
);

Option B — Navigation interception (fallback)

Dart
onNavigationRequest: (NavigationRequest request) {
  if (request.url.contains('.xlsx') ||
      request.url.contains('amazonaws.com')) {
    triggerDownload(request.url);
    return NavigationDecision.prevent;
  }
  return NavigationDecision.navigate;
},

AndroidManifest.xml

XML
<uses-permission android:name="android.permission.INTERNET" />

Integration Checklist

Track delivery against each item before go-live.

Backend API

  • Place Order — returns broker_order_id + timestamp
  • Modify Order — confirms updated order state
  • Cancel Order — returns error for already-executed orders
  • Order Book — all 6 statuses, both order IDs, timestamps, rejection reason
  • Positions — MIS + NRML, all states, avg price, LTP, realised + unrealised P&L
  • Funds — available cash, used margin, collateral, available margin per segment
  • Order Update WebSocket — all transitions, both order IDs per event
  • LTP WebSocket — 3k–10k token range, tick frequency confirmed
  • Instrument Master CSV — all 7 columns, daily refresh confirmed
  • OHLC Candles — 4 timeframes, 5k candles/call, OI for F&O
  • Authentication — token expiry and refresh flow documented

Frontend SDK

  • WebView loads Apt. URL with loading indicator
  • Error screen on HTTP/network failures with retry
  • FlutterChannel registered and navigateToHome handled
  • JS messaging download trigger implemented
  • Navigation interception fallback for file URLs
  • Android DownloadManager with correct package name

Ops & Access

  • 3 test accounts provisioned (Equity + F&O, NSE + BSE)
  • IP whitelisting requirements confirmed
  • WebSocket reconnection behaviour documented
  • Rate limits documented for all endpoints

Rate Limits & Open Items

Items needing your confirmation before integration testing begins.

ItemOur requirementAction needed
OHLC rate limit>20 req/secConfirm; document if lower
LTP WebSocket tick frequencyAs fast as possibleConfirm actual frequency
LTP partial subscription updatesMust be supportedConfirm
WebSocket reconnect behaviourAuto-reconnect, no data gapShare reconnection docs
Token expiry durationConfirm duration
IP whitelistingApt. server IPsConfirm requirements

If any endpoint is unavailable, reach out — we are happy to discuss workarounds or a phased rollout.