Java bindings for the OANDA v20 REST API enabling programmatic access to forex trading, account management, market data, and transaction history
User profile information and external user data.
Get detailed user information (private).
getInfo(userSpecifier: string, responseHandler: (response: Response) => void): void;Parameters:
userSpecifier - User ID or '@' for authenticated userResponse: { userInfo: UserInfo }
Example:
ctx.user.getInfo('@', (response) => {
if (response.isSuccess()) {
const user = response.body.userInfo;
console.log(user.username, user.userID, user.country, user.emailAddress);
}
});Get external (public) user information.
getExternalInfo(userSpecifier: string, responseHandler: (response: Response) => void): void;Response: { userInfo: UserInfoExternal }
Example:
ctx.user.getExternalInfo('12345', (response) => {
if (response.isSuccess()) {
const userInfo = response.body.userInfo;
console.log(userInfo.userID, userInfo.country, userInfo.FIFO);
}
});Complete user information.
class UserInfo {
username: string;
userID: number;
country: string;
emailAddress: string;
}External (public) user information.
class UserInfoExternal {
userID: number;
country: string;
FIFO: boolean; // First-In-First-Out execution rules
}'@' - Currently authenticated user'12345')The FIFO flag indicates whether accounts must follow First-In-First-Out execution:
true: Trades must be closed in order opened (US accounts, NFA regulations)false: Trades can be closed in any orderctx.user.getInfo('@', (response) => {
if (response.isSuccess()) {
const user = response.body.userInfo;
} else if (response.statusCode === '401') {
console.error('Authentication failed');
} else if (response.statusCode === '403') {
console.error('Access forbidden');
}
});Install with Tessl CLI
npx tessl i tessl/maven-oanda--v20