Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Samples are grouped by API area. Each `.md` file contains one or more Node.js sn
| [**option-chain/**](option-chain/) | Option contracts, put-call option chain. |
| [**expired-instruments/**](expired-instruments/) | Expiries, expired future/option contracts, expired historical candle data. |
| [**market-information/**](market-information/) | Exchange status, market timings, market holidays, OI, change in OI, PCR, max pain, FII, DII, and smartlist (futures, MTF, options). |
| [**ipos/**](ipos/) | IPO listing (by status) and IPO details (by slug id). |
| [**ipos/**](ipos/) | IPO listing (by status), IPO details (by slug id), and IPO orders: apply, order book, order details, cancel. |
| [**gtt-orders/**](gtt-orders/) | Place, modify, cancel, and get details for GTT (Good Till Triggered) orders. |
| [**margins/**](margins/) | Margin details. |
| [**charges/**](charges/) | Brokerage details. |
Expand Down
7 changes: 7 additions & 0 deletions examples/ipos/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,10 @@
## 2. IPO Details

- 2.1 [Get IPO details](code/get_ipo_details.md#get-ipo-details)

## 3. IPO Orders

- 3.1 [Apply for an IPO](code/apply_for_ipo.md#apply-for-an-ipo)
- 3.2 [Get IPO orders](code/get_ipo_orders.md#get-ipo-orders)
- 3.3 [Get IPO order details](code/get_ipo_order_by_id.md#get-ipo-order-details)
- 3.4 [Cancel IPO order](code/cancel_ipo_order.md#cancel-ipo-order)
40 changes: 40 additions & 0 deletions examples/ipos/code/apply_for_ipo.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
## Apply for an IPO

```javascript
let UpstoxClient = require('upstox-js-sdk');
let defaultClient = UpstoxClient.ApiClient.instance;
var OAUTH2 = defaultClient.authentications['OAUTH2'];
OAUTH2.accessToken = "{your_access_token}";

let apiInstance = new UpstoxClient.IPOApi();

let body = new UpstoxClient.IpoApplyRequest();

// id is the IPO slug id returned in the listing and details responses
body.id = "{ipo_slug_id}";

// UPI id used to block the application amount
body.upi = "{your_upi_id}";

// category: IND (individual) | HNI
// Must be a category the issue accepts — see investors[].category in the IPO details response
body.category = "IND";

// 1 to 3 bids. quantity must be a multiple of the IPO's lot_size and at
// least its minimum_quantity. price must sit inside the IPO's price band,
// or equal its cut_off_price, and must be in whole rupees.
let bid = new UpstoxClient.IpoBidRequest();
bid.quantity = 100;
bid.price = 250;
body.bids = [bid];

apiInstance.applyForIpo(body, (error, data, response) => {
if (error) {
console.error(error);
} else {
// data.data.orderId is the application id — pass it as orderId to the
// get-order and cancel-order APIs
console.log('API called successfully. Returned data: ' + JSON.stringify(data));
}
});
```
21 changes: 21 additions & 0 deletions examples/ipos/code/cancel_ipo_order.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
## Cancel IPO order

```javascript
let UpstoxClient = require('upstox-js-sdk');
let defaultClient = UpstoxClient.ApiClient.instance;
var OAUTH2 = defaultClient.authentications['OAUTH2'];
OAUTH2.accessToken = "{your_access_token}";

let apiInstance = new UpstoxClient.IPOApi();

// orderId is the IPO application id returned as order_id by the apply and orders APIs
let orderId = "{ipo_order_id}";

apiInstance.cancelIpoOrder(orderId, (error, data, response) => {
if (error) {
console.error(error);
} else {
console.log('API called successfully. Returned data: ' + JSON.stringify(data));
}
});
```
21 changes: 21 additions & 0 deletions examples/ipos/code/get_ipo_order_by_id.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
## Get IPO order details

```javascript
let UpstoxClient = require('upstox-js-sdk');
let defaultClient = UpstoxClient.ApiClient.instance;
var OAUTH2 = defaultClient.authentications['OAUTH2'];
OAUTH2.accessToken = "{your_access_token}";

let apiInstance = new UpstoxClient.IPOApi();

// orderId is the IPO application id returned as order_id by the apply and orders APIs
let orderId = "{ipo_order_id}";

apiInstance.getIpoOrderById(orderId, (error, data, response) => {
if (error) {
console.error(error);
} else {
console.log('API called successfully. Returned data: ' + JSON.stringify(data));
}
});
```
23 changes: 23 additions & 0 deletions examples/ipos/code/get_ipo_orders.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
## Get IPO orders

```javascript
let UpstoxClient = require('upstox-js-sdk');
let defaultClient = UpstoxClient.ApiClient.instance;
var OAUTH2 = defaultClient.authentications['OAUTH2'];
OAUTH2.accessToken = "{your_access_token}";

let apiInstance = new UpstoxClient.IPOApi();

let opts = {
pageNumber: 1,
records: 20
};

apiInstance.getIpoOrders(opts, (error, data, response) => {
if (error) {
console.error(error);
} else {
console.log('API called successfully. Returned data: ' + JSON.stringify(data));
}
});
```
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "upstox-js-sdk",
"version": "2.29.0",
"version": "2.30.0",
"description": "The official Node Js client for communicating with the Upstox API",
"license": "MIT",
"main": "dist/index.js",
Expand Down
2 changes: 1 addition & 1 deletion src/ApiClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export class ApiClient {
*/
this.defaultHeaders = {
'X-Upstox-SDK-Language': 'nodejs',
'X-Upstox-SDK-Version': '2.29.0'
'X-Upstox-SDK-Version': '2.30.0'
};

/**
Expand Down
191 changes: 191 additions & 0 deletions src/api/IPOApi.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,13 @@
*/
import {ApiClient} from "../ApiClient";
import {ApiGatewayErrorResponse} from '../model/ApiGatewayErrorResponse';
import {IpoApplyRequest} from '../model/IpoApplyRequest';
import {IpoApplyResponse} from '../model/IpoApplyResponse';
import {IpoCancelResponse} from '../model/IpoCancelResponse';
import {IpoDetailsResponse} from '../model/IpoDetailsResponse';
import {IpoListingResponse} from '../model/IpoListingResponse';
import {IpoOrderDetailResponse} from '../model/IpoOrderDetailResponse';
import {IpoOrderResponse} from '../model/IpoOrderResponse';

/**
* IPO service.
Expand All @@ -36,6 +41,100 @@ export class IPOApi {
this.apiClient = apiClient || ApiClient.instance;
}

/**
* Callback function to receive the result of the applyForIpo operation.
* @callback moduleapi/IPOApi~applyForIpoCallback
* @param {String} error Error message, if any.
* @param {module:model/IpoApplyResponse{ data The data returned by the service call.
* @param {String} response The complete HTTP response.
*/

/**
* Apply for IPO
* Places an IPO application for the authenticated user.
* @param {module:model/IpoApplyRequest} body
* @param {module:api/IPOApi~applyForIpoCallback} callback The callback function, accepting three arguments: error, data, response
* data is of type: {@link <&vendorExtensions.x-jsdoc-type>}
*/
applyForIpo(body, callback) {

let postBody = body;
// verify the required parameter 'body' is set
if (body === undefined || body === null) {
throw new Error("Missing the required parameter 'body' when calling applyForIpo");
}

let pathParams = {

};
let queryParams = {

};
let headerParams = {

};
let formParams = {

};

let authNames = ['OAUTH2'];
let contentTypes = ['application/json'];
let accepts = ['*/*', 'application/json'];
let returnType = IpoApplyResponse;

return this.apiClient.callApi(
'/v2/ipos/orders', 'POST',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType, callback
);
}
/**
* Callback function to receive the result of the cancelIpoOrder operation.
* @callback moduleapi/IPOApi~cancelIpoOrderCallback
* @param {String} error Error message, if any.
* @param {module:model/IpoCancelResponse{ data The data returned by the service call.
* @param {String} response The complete HTTP response.
*/

/**
* Cancel IPO Order
* Cancels/deletes an IPO order of the authenticated user by order id.
* @param {Object} orderId IPO application id, as returned in &#x60;order_id&#x60; by the apply and orders APIs
* @param {module:api/IPOApi~cancelIpoOrderCallback} callback The callback function, accepting three arguments: error, data, response
* data is of type: {@link <&vendorExtensions.x-jsdoc-type>}
*/
cancelIpoOrder(orderId, callback) {

let postBody = null;
// verify the required parameter 'orderId' is set
if (orderId === undefined || orderId === null) {
throw new Error("Missing the required parameter 'orderId' when calling cancelIpoOrder");
}

let pathParams = {
'order_id': orderId
};
let queryParams = {

};
let headerParams = {

};
let formParams = {

};

let authNames = ['OAUTH2'];
let contentTypes = [];
let accepts = ['*/*', 'application/json'];
let returnType = IpoCancelResponse;

return this.apiClient.callApi(
'/v2/ipos/orders/{order_id}', 'DELETE',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType, callback
);
}
/**
* Callback function to receive the result of the getIpoDetails operation.
* @callback moduleapi/IPOApi~getIpoDetailsCallback
Expand Down Expand Up @@ -130,5 +229,97 @@ export class IPOApi {
authNames, contentTypes, accepts, returnType, callback
);
}
/**
* Callback function to receive the result of the getIpoOrderById operation.
* @callback moduleapi/IPOApi~getIpoOrderByIdCallback
* @param {String} error Error message, if any.
* @param {module:model/IpoOrderDetailResponse{ data The data returned by the service call.
* @param {String} response The complete HTTP response.
*/

/**
* Get IPO Order
* Fetches a single IPO order of the authenticated user by order id.
* @param {Object} orderId IPO application id, as returned in &#x60;order_id&#x60; by the apply and orders APIs
* @param {module:api/IPOApi~getIpoOrderByIdCallback} callback The callback function, accepting three arguments: error, data, response
* data is of type: {@link <&vendorExtensions.x-jsdoc-type>}
*/
getIpoOrderById(orderId, callback) {

let postBody = null;
// verify the required parameter 'orderId' is set
if (orderId === undefined || orderId === null) {
throw new Error("Missing the required parameter 'orderId' when calling getIpoOrderById");
}

let pathParams = {
'order_id': orderId
};
let queryParams = {

};
let headerParams = {

};
let formParams = {

};

let authNames = ['OAUTH2'];
let contentTypes = [];
let accepts = ['*/*', 'application/json'];
let returnType = IpoOrderDetailResponse;

return this.apiClient.callApi(
'/v2/ipos/orders/{order_id}', 'GET',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType, callback
);
}
/**
* Callback function to receive the result of the getIpoOrders operation.
* @callback moduleapi/IPOApi~getIpoOrdersCallback
* @param {String} error Error message, if any.
* @param {module:model/IpoOrderResponse{ data The data returned by the service call.
* @param {String} response The complete HTTP response.
*/

/**
* Get IPO Orders
* Fetches the authenticated user&#x27;s IPO orders/applications.
* @param {Object} opts Optional parameters
* @param {Object} opts.pageNumber Page number, starting at 1
* @param {Object} opts.records Number of records per page
* @param {module:api/IPOApi~getIpoOrdersCallback} callback The callback function, accepting three arguments: error, data, response
* data is of type: {@link <&vendorExtensions.x-jsdoc-type>}
*/
getIpoOrders(opts, callback) {
opts = opts || {};
let postBody = null;

let pathParams = {

};
let queryParams = {
'page_number': opts['pageNumber'],'records': opts['records']
};
let headerParams = {

};
let formParams = {

};

let authNames = ['OAUTH2'];
let contentTypes = [];
let accepts = ['*/*', 'application/json'];
let returnType = IpoOrderResponse;

return this.apiClient.callApi(
'/v2/ipos/orders', 'GET',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType, callback
);
}

}
Loading
Loading