New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

schwab-client-js

Package Overview
Dependencies
Maintainers
0
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

schwab-client-js - npm Package Compare versions

Comparing version 1.0.5 to 1.0.6

6

bin/schwab-authorize.js

@@ -28,3 +28,3 @@ #!/usr/bin/env node

console.log(
"SCHWAB_CALLBACK_URL is not set. That is ok, but that will only work if the callback URL is defined as https://127.0.0.1 in your app settings on developer.schwab.com.",
"SCHWAB_CALLBACK_URL is not set. That is ok. I will use https://127.0.0.1:5556 . However, this will not work unless you have added https://127.0.0.1:5556 to your app settings on developer.schwab.com.",
);

@@ -77,3 +77,3 @@ }

// Default callback URL (local only)
const callbackUrl = process.env.SCHWAB_CALLBACK_URL || "https://127.0.0.1:8443";
const callbackUrl = process.env.SCHWAB_CALLBACK_URL || "https://127.0.0.1:5556";

@@ -87,3 +87,3 @@ // Authorization URL for Schwab API

const urlObj = new URL(callbackUrl);
const port = urlObj.port || 8443;
const port = urlObj.port || 5556;

@@ -90,0 +90,0 @@ // Function to update .env file with a new refresh token

/**
* @function fetchData
* @author Jason Levitt
* @description General purpose fetch routine for making REST API calls
* It uses the built-in fetch (node version 18 and newer) and adds the
* fetch library for earlier versions of node.
* @description General purpose fetch routine for making REST API calls.
* It uses the built-in NodeJS fetch() (node version 18 and newer).
* @param {string} url - The full URL including any parameters

@@ -8,0 +7,0 @@ * @param {Object} args - Optional configuration structure

/**
* @function fetchData
* @author Jason Levitt
* @description General purpose fetch routine for making REST API calls
* It uses the built-in fetch (node version 18 and newer) and adds the
* fetch library for earlier versions of node.
* @description General purpose fetch routine for making REST API calls.
* It uses the built-in NodeJS fetch() (node version 18 and newer).
* @param {string} url - The full URL including any parameters

@@ -46,2 +45,3 @@ * @param {Object} args - Optional configuration structure

if (!response.ok) {
// Get the text version of the response because we can't depend on JSON here
let rt = await response.text();

@@ -51,2 +51,3 @@ // Check for garbage nothingness that Schwab returns sometimes

if (rt && cleanedString.length !== 0) {
// We hope it's a real JSON object now
rt = JSON.parse(rt);

@@ -53,0 +54,0 @@ if (isErrorResponse(rt)) {

@@ -32,3 +32,3 @@ /**

appSecret: process.env.SCHWAB_SECRET || "",
appRefresh: process.env.SCHWAB_REFRESH_TOKEN || "",
appRefresh: process.env.SCHWAB_REFRESH_TOKEN || "", // expires every seven days
access_token: "", // expires every 30 minutes

@@ -65,3 +65,3 @@ access_exp: Math.floor(Date.now() / 1000) + 29 * 60, // expiration is 29 minutes in the future

catch (error) {
throw new Error(`Error: failed to update access token. Details: ${error.message}`);
throw new Error(`Error: failed to update access token. You may need to run schwab-authorize. Details: ${error.message}`);
}

@@ -68,0 +68,0 @@ }

@@ -5,3 +5,3 @@ {

"description": "Javascript client for the Schwab API",
"version": "1.0.5",
"version": "1.0.6",
"homepage": "https://github.com/slimandslam/schwab-client-js#readme",

@@ -45,17 +45,17 @@ "main": "./dist/schwab-client-js.js",

"@types/debug": "^4.1.12",
"@types/node": "^22.9.0",
"@types/node": "^22.10.2",
"@types/ws": "^8.5.13",
"debug": "^4.3.7",
"dotenv": "^16.4.5",
"debug": "^4.4.0",
"dotenv": "^16.4.7",
"open": "^10.1.0",
"selfsigned": "^2.4.1",
"typescript": "^5.6.3",
"typescript": "^5.7.2",
"ws": "^8.18.0"
},
"devDependencies": {
"@typescript-eslint/eslint-plugin": "^8.14.0",
"@typescript-eslint/parser": "^8.14.0",
"eslint": "^9.15.0",
"@typescript-eslint/eslint-plugin": "^8.18.0",
"@typescript-eslint/parser": "^8.18.0",
"eslint": "^9.17.0",
"eslint-define-config": "^2.1.0",
"prettier": "^3.3.3"
"prettier": "^3.4.2"
},

@@ -62,0 +62,0 @@ "engineStrict": true,

@@ -5,3 +5,3 @@ # schwab-client-js

[![Donate Paypal](https://img.shields.io/badge/Donate-PayPal-blue.svg)](https://paypal.me/jlevittpay?country.x=US&locale.x=en_US) [![Donate Venmo](https://img.shields.io/badge/Donate%20via-Venmo-blue)](https://venmo.com/JasonLevitt) [![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://opensource.org/license/mit) ![Node.js supported](https://img.shields.io/node/v/schwab-client-js.svg) ![npm Downloads](https://img.shields.io/npm/dt/schwab-client-js) ![GitHub Downloads (all assets, all releases)](https://img.shields.io/github/downloads/slimandslam/schwab-client-js/total)
[![Donate Paypal](https://img.shields.io/badge/Donate-PayPal-blue.svg)](https://paypal.me/jlevittpay?country.x=US&locale.x=en_US) [![Donate Venmo](https://img.shields.io/badge/Donate%20via-Venmo-blue)](https://venmo.com/JasonLevitt) [![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://opensource.org/license/mit) ![Node.js supported](https://img.shields.io/node/v/schwab-client-js.svg) ![npm Downloads](https://img.shields.io/npm/dt/schwab-client-js) [![npm version](https://badge.fury.io/js/schwab-client-js.svg)](https://www.npmjs.com/package/schwab-client-js)

@@ -31,3 +31,3 @@ Disclaimer: This project is not affiliated with, endorsed by, or associated with The Charles Schwab Corporation. All registered trademarks are the property of their respective owners. Use of these names, logos, and brands is for identification purposes only. This project is licensed under the MIT license, and acts in accordance with Schwab's API terms and conditions.

**Software prerequisites: nodejs version 18 or newer.**
**Software prerequisites: nodejs version 18 or newer and a nodejs package manager such as yarn or npm**

@@ -55,4 +55,4 @@ **Install the package:**

▪ Create a new app and where it says "Select an API product" add both: "Accounts and Trading Production" and "Market Data Production". <br />
▪ You will probably want to use the callback url `https://127.0.0.1` <br />
▪ You may have to wait a day or two for Schwab to approve your app. You cannot do anything while the status of your app is **Pending** or **Approved - Pending**. When the status of your app is **Ready for use**, you can proceed. <br />
▪ Use a callback url like `https://127.0.0.1:5556`. Port numbers below 1024 require superuser privileges to "listen" on most systems, so choose a port number above 1024. You can specify up to three callback URLs. <br />
▪ You may have to wait a day or two for Schwab to approve your app. You cannot do anything while the status of your app is **Approved - Pending**. When the status of your app is **Ready For Use**, you can proceed. <br />
▪ Once your app is approved, go to the [apps section](https://developer.schwab.com/dashboard/apps) and click on **View Details** for your app. At the bottom you should see your **App Key** and **Secret**. <br />

@@ -64,3 +64,3 @@

1. Create a `.env` file at the root of your project and add the App Key and Secret from developer.schwab.com. If your callback URL is anything besides `https://127.0.0.1` (for example, you added a port number), also add it to your .env file like this:
1. Create a `.env` file at the root of your project and add the App Key and Secret from developer.schwab.com. Also add your callback URL to your .env file like this:

@@ -80,6 +80,6 @@ ```

3. Your `.env` file should now look like this (as previously mentioned, the SCHWAB_CALLBACK_URL is optional and will default to `https://127.0.0.1` if not provided):
3. Your `.env` file should now look like this (as previously mentioned, the SCHWAB_CALLBACK_URL is optional and will default to `https://127.0.0.1:5556` if not provided):
```
SCHWAB_CALLBACK_URL=https://somewhere.blahhhh
SCHWAB_CALLBACK_URL=https://127.0.0.1:5556
SCHWAB_APP_KEY=xxxxxxxxxxxxxxxxxxxxxxxxxxxxx

@@ -244,8 +244,12 @@ SCHWAB_SECRET=zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz

- In some method calls, the order of parameters is slightly different than the Schwab documentation. Those changes were made to make it easier to create method calls (putting the required arguments first).
- In two cases, placeOrderByAcct() and orderDelete(), I return slightly different things when the call succeeds. placeOrderByAcct() returns a JSON object with the orderId, and orderDelete() returns null.
- Two types of date formats are used. Check the Schwab developer docs to see which one you need. The two types:
- ISO 8601 format: "2024-11-28T12:17:41-05:00" or just "2024-11-28".
- Milliseconds since the Epoch: 1730432440000 (2024-10-31T22:40:40-05:00 in CST)
### A Few Minor Changes I Made
- In two methods, when the call succeeds, I return slightly different things than what the Schwab documentation says.
- `placeOrderByAcct()` - This is the method for placing trades. When you place an order, I return a JSON object containing the orderId (the raw Schwab API puts the orderID in a header and returns null).
- `orderDelete()` - I return null when you successfully delete an order.
- Two types of date/time formats are used. Check the Schwab developer docs to see which one you need. The two types:
- **ISO 8601 format:** for example "2024-11-28T12:17:41-05:00" or just "2024-11-28".
- **Milliseconds since the Epoch:** for example 1730432440000 (decoded, that's 2024-10-31T22:40:40-05:00 in CST)
- **Rate limits:** there is an overall rate limit of 120 API calls per minute. You should see HTTP status code 429 "Rate Limit Exceeded" if you exceed the limit. You can set the rate limit for just trades in the details section of your app on developer.schwab.com
| **Subclass \| Description** | **Method** | **Parameters** |

@@ -252,0 +256,0 @@ | ------------------------------------------------------------- | --------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc