JavaScript bindings for OANDA's v20 REST API enabling programmatic forex and CFD trading operations.
Operations for retrieving user account information including username, country, email, and FIFO status.
All user operations are accessed via ctx.user where ctx is a Context instance.
Get information about a user.
/**
* Get user information
* @param userSpecifier - User identifier (username or user ID)
* @param responseHandler - Callback receiving Response object
* Response body contains: { userInfo: UserInfo }
*/
getInfo(userSpecifier, responseHandler);Usage Example:
ctx.user.getInfo('12345678', response => {
if (response.isSuccess()) {
const user = response.body.userInfo;
console.log('User Information:');
console.log(` User ID: ${user.userID}`);
console.log(` Username: ${user.username}`);
console.log(` Email: ${user.emailAddress}`);
console.log(` Country: ${user.country}`);
}
});Get external user information (public-facing information).
/**
* Get external user information
* @param userSpecifier - User identifier (username or user ID)
* @param responseHandler - Callback receiving Response object
* Response body contains: { userInfo: UserInfoExternal }
*/
getExternalInfo(userSpecifier, responseHandler);Usage Example:
ctx.user.getExternalInfo('12345678', response => {
if (response.isSuccess()) {
const user = response.body.userInfo;
console.log('External User Information:');
console.log(` User ID: ${user.userID}`);
console.log(` Country: ${user.country}`);
console.log(` FIFO: ${user.FIFO}`);
}
});Complete user information.
interface UserInfo {
username: string; // User-provided username
userID: string; // OANDA-assigned user ID
country: string; // User's country
emailAddress: string; // User's email address
}External (public) user information.
interface UserInfoExternal {
userID: string; // OANDA-assigned user ID
country: string; // User's country
FIFO: boolean; // Flag indicating if First-In-First-Out rules apply
}The FIFO (First-In-First-Out) flag indicates whether the user's account is subject to FIFO trade closure rules:
This affects how trade closure operations work and which trades can be individually closed.
Install with Tessl CLI
npx tessl i tessl/npm-oanda--v20