Get Profile
API to retrieve user profile data, which encompasses details such as supported exchanges, enabled product offerings, and permitted order types. If you're business and developing an application for multi-client API usage, you can utilize this data to display in the user's profile section.
Request
curl --location 'https://api.upstox.com/v2/user/profile' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer {your_access_token}'
Additional samples in various languages are available in the Sample Code section on this page.
Responses
- 200
- 4XX
Response Body
| Name | Type | Description |
|---|---|---|
| status | string | A string indicating the outcome of the request. Typically success for successful operations. |
| data | object | Response data for user profile |
| data.email | string | E-mail address of the user |
| data.exchanges | string[] | List of exchanges enabled for the user. Valid exchanges can be found in the Exchange Appendix |
| data.products | string[] | Lists the types of products enabled for the user. Possible values: I, D, CO, MTF |
| data.broker | string | The broker ID |
| data.user_id | string | Uniquely identifies the user (commonly referred as UCC) |
| data.user_name | string | Name of the user |
| data.order_types | string[] | Order types enabled for the user. Possible values: MARKET, LIMIT, SL, SL-M |
| data.user_type | string | Identifies the user's registered role at the broker. This will be individual for all retail users |
| data.poa | boolean | Indicates whether the user has authorized power of attorney for transactions. |
| data.ddpi | boolean | Indicates whether the user has authorized DDPI (Demat Debit and Pledge Instruction) for transactions. |
| data.is_active | boolean | Indicates if the account status is active. |
Error codes
| Error code | Description |
|---|---|
| UDAPI100058 | No segments for these users are active. Manual reactivation is recommended from Upstox app/web. - Thrown when the signing-in user lacks active segments on their account. It's recommended that the user re-enable these segments through the Upstox app or website. |
Sample Code
Get user profile information using access token
- Python
- Node.js
- Java
- PHP
- Python SDK
- Node.js SDK
- Java SDK
import requests
url = 'https://api.upstox.com/v2/user/profile'
headers = {
'Content-Type': 'application/json',
'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/profile';
const headers = {
'Content-Type': 'application/json',
'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);
});
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.net.http.HttpHeaders;
public class Main {
public static void main(String[] args) {
try {
String url = "https://api.upstox.com/v2/user/profile";
HttpClient httpClient = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create(url))
.header("Content-Type", "application/json")
.header("Accept", "application/json")
.header("Authorization", "Bearer {your_access_token}")
.build();
HttpResponse<String> response = httpClient.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println("Response Code: " + response.statusCode());
HttpHeaders headers = response.headers();
headers.map().forEach((k, v) -> System.out.println(k + ":" + v));
System.out.println("Response Body: " + response.body());
} catch (Exception e) {
e.printStackTrace();
}
}
}
<?php
$url = 'https://api.upstox.com/v2/user/profile';
$headers = array(
'Content-Type: application/json',
'Accept: application/json',
'Authorization: Bearer {your_access_token}'
);
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
echo "Response Code: $httpCode\n";
echo "Response Body: $response\n";
?>
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_profile(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"; // String | API Version Header
apiInstance.getProfile(apiVersion, (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.GetProfileResponse;
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";
try {
GetProfileResponse result = apiInstance.getProfile(apiVersion);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling UserApi#getProfile");
e.printStackTrace();
}
}
}
Loading...