Created
February 15, 2017 19:30
-
-
Save risacher/f261c9928c9442607275abf1a97319d3 to your computer and use it in GitHub Desktop.
example of how to invoke OANDA V20 API from node.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"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