nebsl-b2c-api 1.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- nebsl_b2c_api-1.0.0/PKG-INFO +384 -0
- nebsl_b2c_api-1.0.0/README.md +367 -0
- nebsl_b2c_api-1.0.0/nebsl_b2c_api.egg-info/PKG-INFO +384 -0
- nebsl_b2c_api-1.0.0/nebsl_b2c_api.egg-info/SOURCES.txt +16 -0
- nebsl_b2c_api-1.0.0/nebsl_b2c_api.egg-info/dependency_links.txt +1 -0
- nebsl_b2c_api-1.0.0/nebsl_b2c_api.egg-info/requires.txt +4 -0
- nebsl_b2c_api-1.0.0/nebsl_b2c_api.egg-info/top_level.txt +1 -0
- nebsl_b2c_api-1.0.0/pycloudrestapi/__init__.py +6 -0
- nebsl_b2c_api-1.0.0/pycloudrestapi/__main__.py +0 -0
- nebsl_b2c_api-1.0.0/pycloudrestapi/__version__.py +8 -0
- nebsl_b2c_api-1.0.0/pycloudrestapi/common_methods.py +245 -0
- nebsl_b2c_api-1.0.0/pycloudrestapi/connect.py +620 -0
- nebsl_b2c_api-1.0.0/pycloudrestapi/constants.py +270 -0
- nebsl_b2c_api-1.0.0/pycloudrestapi/logger_config.py +29 -0
- nebsl_b2c_api-1.0.0/pycloudrestapi/parser.py +498 -0
- nebsl_b2c_api-1.0.0/pycloudrestapi/utils.py +198 -0
- nebsl_b2c_api-1.0.0/pyproject.toml +31 -0
- nebsl_b2c_api-1.0.0/setup.cfg +4 -0
|
@@ -0,0 +1,384 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: nebsl-b2c-api
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: The official Python client for the NEBSL B2C REST API
|
|
5
|
+
Author-email: code161263 <code@northeastltd.com>
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/giridhargk/nebslB2C
|
|
8
|
+
Classifier: Programming Language :: Python :: 3
|
|
9
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
10
|
+
Classifier: Operating System :: OS Independent
|
|
11
|
+
Requires-Python: >=3.7
|
|
12
|
+
Description-Content-Type: text/markdown
|
|
13
|
+
Requires-Dist: python-engineio==4.9.0
|
|
14
|
+
Requires-Dist: python-socketio==5.0.1
|
|
15
|
+
Requires-Dist: requests==2.31.0
|
|
16
|
+
Requires-Dist: websockets==12.0
|
|
17
|
+
|
|
18
|
+
# NEBSL REST API Integration Guide
|
|
19
|
+
|
|
20
|
+
> Source documentation: NEBSL Cloud REST API docs
|
|
21
|
+
|
|
22
|
+
## Overview
|
|
23
|
+
|
|
24
|
+
This repository contains a Git-friendly Markdown version of the NEBSL REST API documentation, organized for developers who want a quick implementation reference.
|
|
25
|
+
|
|
26
|
+
Based on the accessible documentation summary, the API supports:
|
|
27
|
+
|
|
28
|
+
- JSON-based requests and responses
|
|
29
|
+
- Data compression
|
|
30
|
+
- Authentication and session-based access
|
|
31
|
+
- Order operations such as:
|
|
32
|
+
- Place Order
|
|
33
|
+
- Modify Order
|
|
34
|
+
- Cancel Order
|
|
35
|
+
- Reports such as:
|
|
36
|
+
- Order Book
|
|
37
|
+
- Trade Book
|
|
38
|
+
- Position
|
|
39
|
+
- Holding
|
|
40
|
+
- Limit
|
|
41
|
+
- Portfolio information management
|
|
42
|
+
- Scrip Master details
|
|
43
|
+
|
|
44
|
+
---
|
|
45
|
+
|
|
46
|
+
## Basic Integration Flow
|
|
47
|
+
|
|
48
|
+
The documentation indicates the following high-level onboarding flow for implementation:
|
|
49
|
+
|
|
50
|
+
1. **Login**
|
|
51
|
+
- Make the login API call using your authorized credentials.
|
|
52
|
+
- Store the returned session/authentication details securely.
|
|
53
|
+
|
|
54
|
+
2. **Maintain Session**
|
|
55
|
+
- Reuse the session or token returned by the login API for subsequent requests.
|
|
56
|
+
- Ensure session validity before making trade or report requests.
|
|
57
|
+
|
|
58
|
+
3. **Call Functional APIs**
|
|
59
|
+
- After successful login, call the required APIs depending on your use case:
|
|
60
|
+
- Order placement
|
|
61
|
+
- Order modification
|
|
62
|
+
- Order cancellation
|
|
63
|
+
- Order book and trade book retrieval
|
|
64
|
+
- Portfolio and holdings retrieval
|
|
65
|
+
- Limits and positions
|
|
66
|
+
- Scrip master and related reference data
|
|
67
|
+
|
|
68
|
+
4. **Handle Standard Response Structure**
|
|
69
|
+
- Parse the API response uniformly.
|
|
70
|
+
- Centralize success/error handling in one place in your application.
|
|
71
|
+
|
|
72
|
+
---
|
|
73
|
+
|
|
74
|
+
## Request Conventions
|
|
75
|
+
|
|
76
|
+
From the available documentation summary:
|
|
77
|
+
|
|
78
|
+
- **GET** and **DELETE** request parameters are passed as **query parameters**
|
|
79
|
+
- **POST** and **PUT** request parameters are passed as **JSON body**
|
|
80
|
+
- Content type is expected to be **`application/json`**
|
|
81
|
+
|
|
82
|
+
### Example patterns
|
|
83
|
+
|
|
84
|
+
#### GET
|
|
85
|
+
```http
|
|
86
|
+
GET /api/example?clientCode=ABC123&exchange=NSE
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
#### POST
|
|
90
|
+
```http
|
|
91
|
+
POST /api/example
|
|
92
|
+
Content-Type: application/json
|
|
93
|
+
|
|
94
|
+
{
|
|
95
|
+
"clientCode": "ABC123",
|
|
96
|
+
"exchange": "NSE"
|
|
97
|
+
}
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
---
|
|
101
|
+
|
|
102
|
+
## Response Structure
|
|
103
|
+
|
|
104
|
+
The published documentation includes a dedicated **Response Structure** section.
|
|
105
|
+
A practical reusable structure for implementation is shown below:
|
|
106
|
+
|
|
107
|
+
```json
|
|
108
|
+
{
|
|
109
|
+
"status": true,
|
|
110
|
+
"message": "Request processed successfully",
|
|
111
|
+
"data": {}
|
|
112
|
+
}
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
### Recommended handling
|
|
116
|
+
|
|
117
|
+
- `status` → whether the request succeeded
|
|
118
|
+
- `message` → human-readable success or error message
|
|
119
|
+
- `data` → actual payload returned by the API
|
|
120
|
+
|
|
121
|
+
> Exact field names and nested objects may vary by endpoint. Validate each endpoint response during implementation.
|
|
122
|
+
|
|
123
|
+
---
|
|
124
|
+
|
|
125
|
+
## Functional Areas
|
|
126
|
+
|
|
127
|
+
## 1. Authentication
|
|
128
|
+
|
|
129
|
+
Used to establish a valid session before accessing trading or reporting APIs.
|
|
130
|
+
|
|
131
|
+
Typical responsibilities:
|
|
132
|
+
|
|
133
|
+
- User login
|
|
134
|
+
- Session generation
|
|
135
|
+
- Session validation
|
|
136
|
+
- Logout or session termination
|
|
137
|
+
|
|
138
|
+
### Implementation notes
|
|
139
|
+
|
|
140
|
+
- Keep secrets out of source control
|
|
141
|
+
- Store session tokens securely
|
|
142
|
+
- Add automatic re-login or refresh handling where needed
|
|
143
|
+
- Centralize auth logic in a dedicated client/service layer
|
|
144
|
+
|
|
145
|
+
---
|
|
146
|
+
|
|
147
|
+
## 2. Order Management
|
|
148
|
+
|
|
149
|
+
The documentation summary explicitly mentions:
|
|
150
|
+
|
|
151
|
+
- **Place Order**
|
|
152
|
+
- **Modify Order**
|
|
153
|
+
- **Cancel Order**
|
|
154
|
+
|
|
155
|
+
### Typical order lifecycle
|
|
156
|
+
|
|
157
|
+
1. Validate session
|
|
158
|
+
2. Build order payload
|
|
159
|
+
3. Submit order
|
|
160
|
+
4. Parse acknowledgement / order reference
|
|
161
|
+
5. Track order status using Order Book or Trade Book APIs
|
|
162
|
+
6. Handle rejects, partial fills, or exchange-side failures
|
|
163
|
+
|
|
164
|
+
### Suggested internal module structure
|
|
165
|
+
|
|
166
|
+
```text
|
|
167
|
+
src/
|
|
168
|
+
api/
|
|
169
|
+
auth_client.*
|
|
170
|
+
order_client.*
|
|
171
|
+
report_client.*
|
|
172
|
+
models/
|
|
173
|
+
auth.*
|
|
174
|
+
order.*
|
|
175
|
+
report.*
|
|
176
|
+
services/
|
|
177
|
+
session_service.*
|
|
178
|
+
order_service.*
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
---
|
|
182
|
+
|
|
183
|
+
## 3. Reports
|
|
184
|
+
|
|
185
|
+
The documentation summary lists the following report categories:
|
|
186
|
+
|
|
187
|
+
- **Order Book**
|
|
188
|
+
- **Trade Book**
|
|
189
|
+
- **Position**
|
|
190
|
+
- **Holding**
|
|
191
|
+
- **Limit**
|
|
192
|
+
|
|
193
|
+
### Common usage
|
|
194
|
+
|
|
195
|
+
- Fetch order history
|
|
196
|
+
- Track completed trades
|
|
197
|
+
- Retrieve live positions
|
|
198
|
+
- Show demat/portfolio holdings
|
|
199
|
+
- Check client trading limits and margins
|
|
200
|
+
|
|
201
|
+
### Recommended implementation pattern
|
|
202
|
+
|
|
203
|
+
- Wrap each report in a dedicated function/service
|
|
204
|
+
- Normalize response mapping into internal DTOs/models
|
|
205
|
+
- Add retry logic for transient failures
|
|
206
|
+
- Log raw responses safely for debugging
|
|
207
|
+
|
|
208
|
+
---
|
|
209
|
+
|
|
210
|
+
## 4. Portfolio Information Management
|
|
211
|
+
|
|
212
|
+
The documentation summary mentions **Portfolio information management**.
|
|
213
|
+
|
|
214
|
+
This usually includes:
|
|
215
|
+
|
|
216
|
+
- Portfolio-level summary retrieval
|
|
217
|
+
- Client asset visibility
|
|
218
|
+
- Security-wise holdings
|
|
219
|
+
- Position and valuation access
|
|
220
|
+
- Investment overview components
|
|
221
|
+
|
|
222
|
+
---
|
|
223
|
+
|
|
224
|
+
## 5. Scrip Master Details
|
|
225
|
+
|
|
226
|
+
The documentation summary mentions **Scrip Master Details**.
|
|
227
|
+
|
|
228
|
+
This is usually used to:
|
|
229
|
+
|
|
230
|
+
- Fetch instrument metadata
|
|
231
|
+
- Resolve symbol/token/security identifiers
|
|
232
|
+
- Validate tradable contracts or scrips
|
|
233
|
+
- Map internal instrument references
|
|
234
|
+
|
|
235
|
+
---
|
|
236
|
+
|
|
237
|
+
## Suggested README Sections for Production Repositories
|
|
238
|
+
|
|
239
|
+
If you are adding this into a Git repository, this structure works well:
|
|
240
|
+
|
|
241
|
+
```md
|
|
242
|
+
# Project Name
|
|
243
|
+
|
|
244
|
+
## Environment Variables
|
|
245
|
+
## Authentication
|
|
246
|
+
## API Endpoints
|
|
247
|
+
## Request/Response Examples
|
|
248
|
+
## Error Handling
|
|
249
|
+
## Retry Strategy
|
|
250
|
+
## Logging
|
|
251
|
+
## Security Notes
|
|
252
|
+
## Testing
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
---
|
|
256
|
+
|
|
257
|
+
## Example API Client Wrapper
|
|
258
|
+
|
|
259
|
+
Below is a generic example in JavaScript/TypeScript style:
|
|
260
|
+
|
|
261
|
+
```ts
|
|
262
|
+
type ApiResponse<T> = {
|
|
263
|
+
status: boolean;
|
|
264
|
+
message: string;
|
|
265
|
+
data: T;
|
|
266
|
+
};
|
|
267
|
+
|
|
268
|
+
async function apiRequest<T>(
|
|
269
|
+
url: string,
|
|
270
|
+
method: "GET" | "POST" | "PUT" | "DELETE",
|
|
271
|
+
body?: unknown
|
|
272
|
+
): Promise<ApiResponse<T>> {
|
|
273
|
+
const options: RequestInit = {
|
|
274
|
+
method,
|
|
275
|
+
headers: {
|
|
276
|
+
"Content-Type": "application/json"
|
|
277
|
+
}
|
|
278
|
+
};
|
|
279
|
+
|
|
280
|
+
if (body && (method === "POST" || method === "PUT")) {
|
|
281
|
+
options.body = JSON.stringify(body);
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
const response = await fetch(url, options);
|
|
285
|
+
if (!response.ok) {
|
|
286
|
+
throw new Error(`HTTP ${response.status}`);
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
return response.json() as Promise<ApiResponse<T>>;
|
|
290
|
+
}
|
|
291
|
+
```
|
|
292
|
+
|
|
293
|
+
---
|
|
294
|
+
|
|
295
|
+
## Error Handling Recommendations
|
|
296
|
+
|
|
297
|
+
Implement these checks consistently:
|
|
298
|
+
|
|
299
|
+
- HTTP status validation
|
|
300
|
+
- API-level `status` validation
|
|
301
|
+
- Empty `data` handling
|
|
302
|
+
- Unauthorized session handling
|
|
303
|
+
- Timeout and retry handling
|
|
304
|
+
- Structured logs for trading/reporting calls
|
|
305
|
+
|
|
306
|
+
### Suggested categories
|
|
307
|
+
|
|
308
|
+
- Authentication errors
|
|
309
|
+
- Validation errors
|
|
310
|
+
- Business rule failures
|
|
311
|
+
- Exchange/order rejections
|
|
312
|
+
- Network timeouts
|
|
313
|
+
- Server-side internal errors
|
|
314
|
+
|
|
315
|
+
---
|
|
316
|
+
|
|
317
|
+
## Security Recommendations
|
|
318
|
+
|
|
319
|
+
- Never commit credentials to Git
|
|
320
|
+
- Use environment variables or a secret manager
|
|
321
|
+
- Mask client identifiers in logs
|
|
322
|
+
- Encrypt stored session artifacts where required
|
|
323
|
+
- Add rate limiting and retry backoff
|
|
324
|
+
- Keep audit logs for critical trade actions
|
|
325
|
+
|
|
326
|
+
---
|
|
327
|
+
|
|
328
|
+
## Testing Checklist
|
|
329
|
+
|
|
330
|
+
- [ ] Login success flow
|
|
331
|
+
- [ ] Login failure flow
|
|
332
|
+
- [ ] Session expiry flow
|
|
333
|
+
- [ ] Place order success
|
|
334
|
+
- [ ] Place order rejection
|
|
335
|
+
- [ ] Modify order success/failure
|
|
336
|
+
- [ ] Cancel order success/failure
|
|
337
|
+
- [ ] Order Book fetch
|
|
338
|
+
- [ ] Trade Book fetch
|
|
339
|
+
- [ ] Position fetch
|
|
340
|
+
- [ ] Holding fetch
|
|
341
|
+
- [ ] Limit fetch
|
|
342
|
+
- [ ] Invalid request body handling
|
|
343
|
+
- [ ] Network timeout handling
|
|
344
|
+
|
|
345
|
+
---
|
|
346
|
+
|
|
347
|
+
## Repository Usage Example
|
|
348
|
+
|
|
349
|
+
```bash
|
|
350
|
+
git clone <your-repo-url>
|
|
351
|
+
cd <your-repo>
|
|
352
|
+
cp .env.example .env
|
|
353
|
+
```
|
|
354
|
+
|
|
355
|
+
---
|
|
356
|
+
|
|
357
|
+
## Important Note
|
|
358
|
+
|
|
359
|
+
This README is a **developer-friendly Markdown conversion based on the publicly visible documentation summary available from the NEBSL REST API page**.
|
|
360
|
+
|
|
361
|
+
During this conversion, the original documentation site was not fully machine-readable from my side, so this file is a **clean implementation README draft**, not a verbatim endpoint-by-endpoint export.
|
|
362
|
+
|
|
363
|
+
For a complete production reference, you should still verify:
|
|
364
|
+
|
|
365
|
+
- Exact endpoint paths
|
|
366
|
+
- Required headers
|
|
367
|
+
- Authentication field names
|
|
368
|
+
- Mandatory request fields
|
|
369
|
+
- Exact response schema for each endpoint
|
|
370
|
+
- Error codes and exchange-specific behaviors
|
|
371
|
+
|
|
372
|
+
---
|
|
373
|
+
|
|
374
|
+
## Recommended Next Step
|
|
375
|
+
|
|
376
|
+
Use this file as the root `README.md`, then extend it with:
|
|
377
|
+
|
|
378
|
+
- Exact endpoint list
|
|
379
|
+
- Full request/response payload samples
|
|
380
|
+
- Sandbox/production base URLs
|
|
381
|
+
- Authentication headers
|
|
382
|
+
- Error code reference
|
|
383
|
+
- SDK examples for your preferred language
|
|
384
|
+
|