Code Monkey home page Code Monkey logo

node-etrade-api's Introduction

E*TRADE API

A Node.js module for the E*TRADE web services API.

Usage

All you need to get started with this module is your E*TRADE-supplied consumer key and consumer secret

var etrade = require('etrade');

var configuration = 
{
  useSandbox : true|false, // true if not provided
  key : 'your_key',
  secret : 'your_secret'
}

var et = new etrade(configuration);

You now have an etrade client. Before you can do anything useful, you will need to authenticate yourself with the E*TRADE system, and a user will have to authorize your service to access his/her account data.

Authorization

Authorization is a painful four step process. In general it looks like this:

  1. Your user logs into your site and you ask E*TRADE to generate a "request token"
  2. You redirect your user to E*TRADE's authorization site, where they log in and authorize your application.
  3. They are provided with a "verification code" (for example: H92GX) that they must copy and paste back into your site.
  4. You provide the verification code back to E*TRADE, and get an "access token" which permits all broader activity.

It looks like this in code:

et.getRequestToken(
  function(authorizationUrl) { 
    // Your service requires users, who will need to visit
    // the following URL and, after logging in and 
    // authorizing your service to access their account
    // data, paste the E*TRADE provided verification
    // code back into your application.
    console.log("Please have your client visit " + 
                authorizationUrl + 
                " to authorize your service"); },
  function(error) { 
    console.log("Error encountered while attempting " +
                "to retrieve a request token: " + 
                error); }
);

The user should come back to you with their verification code, through some "out-of-band" process (you can, apparently work with E*TRADE to have them redirect your user back to your site if your service is public facing).

et.getAccessToken(verificationCode,
  function() {
    // Your app can start using other E*TRADE API now
  },
  function(error) {
    console.log("Error encountered while attempting " +
                "to exchange request token for access token: " +
                error);
  }
);

node-etrade-api's People

Contributors

jleonard avatar patricktynan avatar theidealist avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.