GET/us/funds
Get Funds
API to retrieve the user's US stocks wallet balance. Amounts are in USD and are read live from the US broker. Each balance also comes as an INR figure at the indicative exchange_rate, for display only.
Use available_to_trade to check how much you can invest. It includes unsettled credit, so it can be higher than available_to_withdraw.
Request
curl --location 'https://api.upstox.com/v2/us/funds' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer {your_access_token}'
For samples in other languages, see the Sample Code section on this page.
Responses
- 200
- 4XX
Response Body
{
"status": "success",
"data": {
"available_to_trade": 909.45,
"available_to_withdraw": 806.12,
"cash": 909.45,
"unsettled_cash": 103.33,
"exchange_rate": 96.34,
"available_to_trade_inr": 87616.41,
"available_to_withdraw_inr": 77661.60,
"cash_inr": 87616.41,
"unsettled_cash_inr": 9954.81
}
}
| Name | Type | Description |
|---|---|---|
| status | string | Outcome of the request. Typically success. |
| data | object | The user's US stocks wallet. |
| data.available_to_trade | number | Buying power in USD. Includes unsettled instant-funding credit. |
| data.available_to_withdraw | number | Settled cash in USD that can be withdrawn. |
| data.cash | number | Cash in the wallet, in USD. |
| data.unsettled_cash | number | Cash not yet settled: cash minus available_to_withdraw. |
| data.exchange_rate | number | Indicative USD to INR rate, for display only. |
| data.available_to_trade_inr | number | available_to_trade in INR at exchange_rate. Indicative, for display only. |
| data.available_to_withdraw_inr | number | available_to_withdraw in INR at exchange_rate. Indicative, for display only. |
| data.cash_inr | number | cash in INR at exchange_rate. Indicative, for display only. |
| data.unsettled_cash_inr | number | unsettled_cash in INR at exchange_rate. Indicative, for display only. |
Error codes
| Error code | Description |
|---|---|
| UDAPI1316 | US stocks is not activated for this account - Returned with HTTP 403. |
| UDAPI1320 | US stocks funds service is unavailable. Please try again later. - Returned with HTTP 423. |
Sample Code
Get US stocks funds
- Python
- Node.js
- Java
- PHP
- Python SDK
- Node.js SDK
- Java SDK
- PHP SDK
- .NET SDK
import requests
url = 'https://api.upstox.com/v2/us/funds'
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/us/funds';
const headers = {
'Accept': 'application/json',
'Authorization': 'Bearer {your_access_token}',
};
axios.get(url, { headers })
.then(response => {
console.log(response.data);
})
.catch(error => {
console.error(error.response ? error.response.data : 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) throws Exception {
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://api.upstox.com/v2/us/funds"))
.header("Accept", "application/json")
.header("Authorization", "Bearer {your_access_token}")
.GET()
.build();
HttpResponse<String> response = HttpClient.newHttpClient()
.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.statusCode());
System.out.println(response.body());
}
}
<?php
$url = 'https://api.upstox.com/v2/us/funds';
$headers = [
'Accept: application/json',
'Authorization: Bearer {your_access_token}',
];
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
if (curl_errno($ch)) {
echo 'Error: ' . curl_error($ch);
} else {
echo $response;
}
curl_close($ch);
?>
import upstox_client
from upstox_client.rest import ApiException
configuration = upstox_client.Configuration()
configuration.access_token = '{your_access_token}'
api_instance = upstox_client.UsStocksFundsApi(upstox_client.ApiClient(configuration))
try:
api_response = api_instance.get_us_funds()
print(api_response)
except ApiException as e:
print("Exception when calling UsStocksFundsApi->get_us_funds: %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.USStocksFundsApi();
apiInstance.getUsFunds((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.UsFundsResponse;
import com.upstox.auth.OAuth;
import io.swagger.client.api.UsStocksFundsApi;
public class Main {
public static void main(String[] args) {
ApiClient defaultClient = Configuration.getDefaultApiClient();
OAuth OAUTH2 = (OAuth) defaultClient.getAuthentication("OAUTH2");
OAUTH2.setAccessToken("{your_access_token}");
UsStocksFundsApi apiInstance = new UsStocksFundsApi();
try {
UsFundsResponse result = apiInstance.getUsFunds();
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling UsStocksFundsApi#getUsFunds");
e.printStackTrace();
}
}
}
<?php
$config = (new Upstox\Client\Configuration())
->setAccessToken('{your_access_token}');
$apiInstance = new Upstox\Client\Api\USStocksFundsApi(
new GuzzleHttp\Client(),
$config
);
try {
$result = $apiInstance->getUsFunds();
print_r($result);
} catch (Exception $e) {
echo 'Exception when calling USStocksFundsApi->getUsFunds: ' . $e->getMessage();
}
using UpstoxClient.Api;
using UpstoxClient.Client;
using UpstoxClient.Extensions;
using UpstoxClient.Model;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.DependencyInjection;
var host = Host.CreateDefaultBuilder()
.ConfigureApi((context, services, options) =>
{
options.AddTokens(new OAuthToken("{your_access_token}"));
}).Build();
await host.StartAsync();
var apiInstance = host.Services.GetRequiredService<IUSStocksFundsApi>();
try
{
var response = await apiInstance.GetUsFundsAsync();
Console.WriteLine(response.RawContent);
}
catch (Exception e)
{
Console.WriteLine("Exception: " + e.Message);
}
await host.StopAsync();