Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
example of how to invoke OANDA V20 API from node.js
"use strict";
const oandaV20 = require('@oanda/v20/context');
const fs = require('fs');
var ctx = new oandaV20.Context('api-fxpractice.oanda.com', 443, true, "demo");
var key = fs.readFileSync('api.key', {encoding: 'utf8'});
//remove any bad chars (e.g. the trailing newline)
key = key.replace(/[^0-9a-fA-F-]/g, "");
console.log(key);
ctx.setToken(key);
ctx.account.list(function(res) {
var accounts = res.body;
console.log(accounts);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.