Get Fund And Margin
Get equity and commodity funds
- Curl
- Python
- Node.js
- Java
- PHP
- Python SDK
- Node.js SDK
- Java SDK
curl --location 'https://api.upstox.com/v2/user/get-funds-and-margin' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer {your_access_token}'
import requests
url = 'https://api.upstox.com/v2/user/get-funds-and-margin'
headers = {
'Accept': 'application/json',
'Authorization': 'Bearer {your_access_token}'
}
response = requests.get(url, headers=headers)
print(response.status_code)
print(response.json())
const axios = require('axios');
const url = 'https://api.upstox.com/v2/user/get-funds-and-margin';
const headers = {
'Accept': 'application/json',
'Authorization': 'Bearer {your_access_token}'
};
axios.get(url, { headers })
.then(response => {
console.log(response.status);
console.log(response.data);
})
.catch(error => {
console.error('Error:', error.message);
});
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
public class Main {
public static void main(String[] args) {
String url = "https://api.upstox.com/v2/user/get-funds-and-margin";
String acceptHeader = "application/json";
String authorizationHeader = "Bearer {your_access_token}";
HttpClient httpClient = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create(url))
.header("Accept", acceptHeader)
.header("Authorization", authorizationHeader)
.GET()
.build();
try {
HttpResponse<String> response = httpClient.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println("Status Code: " + response.statusCode());
System.out.println("Response Body: " + response.body());
} catch (Exception e) {
System.err.println("Error: " + e.getMessage());
}
}
}
<?php
$url = 'https://api.upstox.com/v2/user/get-funds-and-margin';
$acceptHeader = 'application/json';
$authorizationHeader = 'Bearer {your_access_token}';
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Accept: ' . $acceptHeader,
'Authorization: ' . $authorizationHeader,
));
$response = curl_exec($ch);
$status_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
echo "Status Code: " . $status_code . PHP_EOL;
echo "Response Body: " . $response . PHP_EOL;
?>
import upstox_client
from upstox_client.rest import ApiException
configuration = upstox_client.Configuration()
configuration.access_token = '{your_access_token}'
api_version = '2.0'
api_instance = upstox_client.UserApi(upstox_client.ApiClient(configuration))
try:
# Get User Fund And Margin
api_response = api_instance.get_user_fund_margin(api_version)
print(api_response)
except ApiException as e:
print("Exception when calling UserApi->get_user_fund_margin: %s\n" % e)
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.UserApi();
let apiVersion = "2.0";
apiInstance.getUserFundMargin(apiVersion, null, (error, data, response) => {
if (error) {
console.error(error);
} else {
console.log('API called successfully. Returned data: ' + JSON.stringify(data));
}
});
import com.upstox.ApiClient;
import com.upstox.ApiException;
import com.upstox.Configuration;
import com.upstox.api.GetUserFundMarginResponse;
import com.upstox.auth.*;
import io.swagger.client.api.UserApi;
public class Main {
public static void main(String[] args) {
ApiClient defaultClient = Configuration.getDefaultApiClient();
OAuth OAUTH2 = (OAuth) defaultClient.getAuthentication("OAUTH2");
OAUTH2.setAccessToken("{your_access_token}");
UserApi apiInstance = new UserApi();
String apiVersion = "2.0"; // String | API Version Header
String segment = "";
try {
GetUserFundMarginResponse result = apiInstance.getUserFundMargin(apiVersion, segment);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling UserApi#getUserFundMargin");
e.printStackTrace();
}
}
}
Get equity funds
- Curl
- Python
- Node.js
- Java
- PHP
- Python SDK
- Node.js SDK
- Java SDK
curl --location 'https://api.upstox.com/v2/user/get-funds-and-margin?segment=SEC' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer {your_access_token}'
import requests
url = 'https://api.upstox.com/v2/user/get-funds-and-margin?segment=SEC'
headers = {
'Accept': 'application/json',
'Authorization': 'Bearer {your_access_token}'
}
response = requests.get(url, headers=headers)
print(response.status_code)
print(response.json())
const axios = require('axios');
const url = 'https://api.upstox.com/v2/user/get-funds-and-margin?segment=SEC';
const headers = {
'Accept': 'application/json',
'Authorization': 'Bearer {your_access_token}'
};
axios.get(url, { headers })
.then(response => {
console.log(response.status);
console.log(response.data);
})
.catch(error => {
console.error('Error:', error.message);
});
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
public class Main {
public static void main(String[] args) {
String url = "https://api.upstox.com/v2/user/get-funds-and-margin?segment=SEC";
String acceptHeader = "application/json";
String authorizationHeader = "Bearer {your_access_token}";
HttpClient httpClient = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create(url))
.header("Accept", acceptHeader)
.header("Authorization", authorizationHeader)
.GET()
.build();
try {
HttpResponse<String> response = httpClient.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println("Status Code: " + response.statusCode());
System.out.println("Response Body: " + response.body());
} catch (Exception e) {
System.err.println("Error: " + e.getMessage());
}
}
}
<?php
$url = 'https://api.upstox.com/v2/user/get-funds-and-margin?segment=SEC';
$acceptHeader = 'application/json';
$authorizationHeader = 'Bearer {your_access_token}';
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Accept: ' . $acceptHeader,
'Authorization: ' . $authorizationHeader,
));
$response = curl_exec($ch);
$status_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
echo "Status Code: " . $status_code . PHP_EOL;
echo "Response Body: " . $response . PHP_EOL;
?>
import upstox_client
from upstox_client.rest import ApiException
configuration = upstox_client.Configuration()
configuration.access_token = '{your_access_token}'
api_version = '2.0'
api_instance = upstox_client.UserApi(upstox_client.ApiClient(configuration))
segment = 'SEC'
try:
# Get User Fund And Margin
api_response = api_instance.get_user_fund_margin(api_version, segment=segment)
print(api_response)
except ApiException as e:
print("Exception when calling UserApi->get_user_fund_margin: %s\n" % e)
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.UserApi();
let apiVersion = "2.0";
let opts = {
'segment': "SEC"
};
apiInstance.getUserFundMargin(apiVersion, opts, (error, data, response) => {
if (error) {
console.error(error);
} else {
console.log('API called successfully. Returned data: ' + JSON.stringify(data));
}
});
import com.upstox.ApiClient;
import com.upstox.ApiException;
import com.upstox.Configuration;
import com.upstox.api.GetUserFundMarginResponse;
import com.upstox.auth.*;
import io.swagger.client.api.UserApi;
public class Main {
public static void main(String[] args) {
ApiClient defaultClient = Configuration.getDefaultApiClient();
OAuth OAUTH2 = (OAuth) defaultClient.getAuthentication("OAUTH2");
OAUTH2.setAccessToken("{your_access_token}");
UserApi apiInstance = new UserApi();
String apiVersion = "2.0"; // String | API Version Header
String segment = "SEC"; // String |
try {
GetUserFundMarginResponse result = apiInstance.getUserFundMargin(apiVersion, segment);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling UserApi#getUserFundMargin");
e.printStackTrace();
}
}
}
Get commodity funds
- Curl
- Python
- Node.js
- Java
- PHP
- Python SDK
- Node.js SDK
- Java SDK
curl --location 'https://api.upstox.com/v2/user/get-funds-and-margin?segment=COM' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer {your_access_token}'
import requests
url = 'https://api.upstox.com/v2/user/get-funds-and-margin?segment=COM'
headers = {
'Accept': 'application/json',
'Authorization': 'Bearer {your_access_token}'
}
response = requests.get(url, headers=headers)
print(response.status_code)
print(response.json())
const axios = require('axios');
const url = 'https://api.upstox.com/v2/user/get-funds-and-margin?segment=COM';
const headers = {
'Accept': 'application/json',
'Authorization': 'Bearer {your_access_token}'
};
axios.get(url, { headers })
.then(response => {
console.log(response.status);
console.log(response.data);
})
.catch(error => {
console.error('Error:', error.message);
});
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
public class Main {
public static void main(String[] args) {
String url = "https://api.upstox.com/v2/user/get-funds-and-margin?segment=COM";
String acceptHeader = "application/json";
String authorizationHeader = "Bearer {your_access_token}";
HttpClient httpClient = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create(url))
.header("Accept", acceptHeader)
.header("Authorization", authorizationHeader)
.GET()
.build();
try {
HttpResponse<String> response = httpClient.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println("Status Code: " + response.statusCode());
System.out.println("Response Body: " + response.body());
} catch (Exception e) {
System.err.println("Error: " + e.getMessage());
}
}
}
<?php
$url = 'https://api.upstox.com/v2/user/get-funds-and-margin?segment=COM';
$acceptHeader = 'application/json';
$authorizationHeader = 'Bearer {your_access_token}';
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Accept: ' . $acceptHeader,
'Authorization: ' . $authorizationHeader,
));
$response = curl_exec($ch);
$status_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
echo "Status Code: " . $status_code . PHP_EOL;
echo "Response Body: " . $response . PHP_EOL;
?>
import upstox_client
from upstox_client.rest import ApiException
configuration = upstox_client.Configuration()
configuration.access_token = '{your_access_token}'
api_version = '2.0'
api_instance = upstox_client.UserApi(upstox_client.ApiClient(configuration))
segment = 'COM'
try:
# Get User Fund And Margin
api_response = api_instance.get_user_fund_margin(api_version, segment=segment)
print(api_response)
except ApiException as e:
print("Exception when calling UserApi->get_user_fund_margin: %s\n" % e)
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.UserApi();
let apiVersion = "2.0";
let opts = {
'segment': "COM"
};
apiInstance.getUserFundMargin(apiVersion, opts, (error, data, response) => {
if (error) {
console.error(error);
} else {
console.log('API called successfully. Returned data: ' + JSON.stringify(data));
}
});
import com.upstox.ApiClient;
import com.upstox.ApiException;
import com.upstox.Configuration;
import com.upstox.api.GetUserFundMarginResponse;
import com.upstox.auth.*;
import io.swagger.client.api.UserApi;
public class Main {
public static void main(String[] args) {
ApiClient defaultClient = Configuration.getDefaultApiClient();
OAuth OAUTH2 = (OAuth) defaultClient.getAuthentication("OAUTH2");
OAUTH2.setAccessToken("{your_access_token}");
UserApi apiInstance = new UserApi();
String apiVersion = "2.0"; // String | API Version Header
String segment = "COM"; // String |
try {
GetUserFundMarginResponse result = apiInstance.getUserFundMargin(apiVersion, segment);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling UserApi#getUserFundMargin");
e.printStackTrace();
}
}
}