npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

etrade-ts

v1.1.1

Published

[![CircleCI](https://circleci.com/gh/markdoten/etrade-ts/tree/main.svg?style=svg)](https://circleci.com/gh/markdoten/etrade-ts/tree/main)

Downloads

9

Readme

etrade-ts

CircleCI

A TypeScript E-Trade SDK implementation.

Documentation: https://markdoten.github.io/etrade-ts/

E-Trade developer documentation: https://developer.etrade.com/home

IMPORTANT!

The E-Trade documentation shows camel case property names throughout. However, for property names that as assigned to other interfaces, they are title case even though the documentation does not show that. For consistency, properties within responses are converted to camel case, so that it matches the E-Trade documentation.

When making place order requests, a few of the properties need to be title case. The SDK automatically takes care of it.

Authorization

The E-Trade OAuth flow is a multi-step process. Here is the E-Trade OAuth documentation: https://developer.etrade.com/getting-started/developer-guides.

etrade.auth.startOAuth(): Fetxches the OAuth request token and secret, then returns the OAuth URL.

etrade.auth.completeOAuth(verifier: string): Receives the OAuth verifier code, fetches the access token and secret, then set up the session for future use.

Here is an example using Express. Note that the endpoint /etrade/auth/code in this example would be set up in E-Trade as the OAuth callback.

import Etrade from 'etrade-ts';
import express from 'express';
import type {Request, Response} from 'express';

const app = express();
app.use(express.json());

const etrade: Etrade = new Etrade({
  consumerKey: '<consumer key>',
  consumerSecret: '<consumer secret>'
});

app.get('/etrade/auth/start', async (req: Request, res: Response) =>
  res.redirect(await etrade.auth.startOAuth()));

app.get('/etrade/auth/code', async (req: Request, res: Response) => {
  await etrade.auth.completeOAuth(req.query.oauth_verifier.toString());
});

app.listen(8080);

Once the OAuth process is complete, requests can be made using other APIs.

APIs

Each of the APIs (Accounts, Alerts, Market, Order) are available on the Etrade instance.

Most API requests require to be made on a specific account within the E-Trade profile. First you will need to fetch the list of accounts and select which one you want to use.

const {accounts: {account}} = await etrade.accounts.ListAccounts();
console.log(account);

Once you select one of the accounts in the list, the accountIdKey property will need to be passed into most requests:

const {order} = await etrade.order.ListOrders({accountIdKey});