@massive.com/client-js 9.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +129 -0
- package/LICENSE +21 -0
- package/README.md +122 -0
- package/dist/main.d.ts +27237 -0
- package/dist/main.js +1 -0
- package/package.json +92 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
## [8.0.0](https://github.com/massive.com/client-js/compare/v7.4.0...v8.0.0) (2025-06-21)
|
|
2
|
+
### Breaking Changes
|
|
3
|
+
* Functions call naming has updated to new autogenerated standards w/ all rest client
|
|
4
|
+
* Debug mode has been deprecated from `globalFetchOptions`
|
|
5
|
+
|
|
6
|
+
## [7.3.2](https://github.com/massive.com/client-js/compare/v7.3.1...v7.3.2) (2023-10-05)
|
|
7
|
+
### Bug Fixes
|
|
8
|
+
* Rearrange request config types so they inherit global options for pagination and trace
|
|
9
|
+
|
|
10
|
+
## [7.3.1](https://github.com/massive.com/client-js/compare/v7.3.0...v7.3.1) (2023-09-15)
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
* Fix unintended change to top level response object that returned results array instead of results object
|
|
13
|
+
|
|
14
|
+
### Other Changes
|
|
15
|
+
* Improved test coverage for response object
|
|
16
|
+
|
|
17
|
+
## [7.3.0](https://github.com/massive.com/client-js/compare/v7.2.6...v7.3.0) (2023-09-11)
|
|
18
|
+
### New Feature
|
|
19
|
+
* Update README with pagination and trace modes
|
|
20
|
+
* Added request tracing and API pagination support
|
|
21
|
+
|
|
22
|
+
## [7.2.6](https://github.com/massive.com/client-js/compare/v7.2.5...v7.2.6) (2023-08-11)
|
|
23
|
+
### Bug Fixes
|
|
24
|
+
* Export universal snapshot types
|
|
25
|
+
* Add next_url to Aggregates enpdoints response types
|
|
26
|
+
* Update examples to use import syntax instead of require
|
|
27
|
+
|
|
28
|
+
## [7.2.4](https://github.com/massive.com/client-js/compare/v7.2.3...v7.2.4) (2023-06-14)
|
|
29
|
+
### Bug Fixes
|
|
30
|
+
* Update snapshot min to support n and t
|
|
31
|
+
* Exports and Updates Options WebSocket Event Types
|
|
32
|
+
* Universal snapshot
|
|
33
|
+
|
|
34
|
+
## [7.2.3](https://github.com/massive.com/client-js/compare/v7.2.2...v7.2.3) (2023-05-15)
|
|
35
|
+
### Bug Fixes
|
|
36
|
+
* Fix typing issue with optional headers Launchpad Typescript definitions
|
|
37
|
+
* Export types from requests file
|
|
38
|
+
* Make Launchpad Headers optional to support metered product
|
|
39
|
+
|
|
40
|
+
## [7.2.2](https://github.com/massive.com/client-js/compare/v7.2.1...v7.2.2) (2023-04-19)
|
|
41
|
+
### Bug Fixes
|
|
42
|
+
* Remove examples and unneccesary files from npm package
|
|
43
|
+
|
|
44
|
+
## [7.2.1](https://github.com/massive.com/client-js/compare/v7.2.0...v7.2.1) (2023-04-12)
|
|
45
|
+
### Bug Fixes
|
|
46
|
+
* Update snapshot response type to reflect recent additions
|
|
47
|
+
|
|
48
|
+
## [7.2.0](https://github.com/massive.com/client-js/compare/v7.1.1...v7.2.0) (2023-04-07)
|
|
49
|
+
### New Feature
|
|
50
|
+
* Support Dual Module Formats so that this package can be used with CommonJS
|
|
51
|
+
|
|
52
|
+
## [7.1.1](https://github.com/massive.com/client-js/v7.0.1...v7.1.1) (2023-03-20)
|
|
53
|
+
|
|
54
|
+
### Bug Fixes
|
|
55
|
+
* Fix misspelled filling_url to filing_url
|
|
56
|
+
* Preserve JSON errors returned from the server
|
|
57
|
+
|
|
58
|
+
## [7.1.0](https://github.com/massive.com/client-js/compare/v7.0.3...v7.1.0) (2023-03-13)
|
|
59
|
+
### New Feature
|
|
60
|
+
* Indices
|
|
61
|
+
|
|
62
|
+
## [7.0.3](https://github.com/massive.com/client-js/v7.0.2...v7.0.3) (2023-02-21)
|
|
63
|
+
|
|
64
|
+
### Bug Fixes
|
|
65
|
+
* Fix grouped daily forex url
|
|
66
|
+
|
|
67
|
+
## [7.0.2](https://github.com/massive.com/client-js/v7.0.1...v7.0.2) (2023-02-15)
|
|
68
|
+
|
|
69
|
+
### Bug Fixes
|
|
70
|
+
* Wrap fetch call in try/catch and bubble up network errors
|
|
71
|
+
|
|
72
|
+
## [6.2.1](https://github.com/massive.com/client-js/v6.2.0...v6.2.1) (2023-02-15)
|
|
73
|
+
|
|
74
|
+
### Bug Fixes
|
|
75
|
+
* Wrap fetch call in try/catch and bubble up network errors
|
|
76
|
+
|
|
77
|
+
## [7.0.1](https://github.com/massive.com/client-js/v7.0.0...v7.0.1) (2023-02-01)
|
|
78
|
+
|
|
79
|
+
### Bug Fixes
|
|
80
|
+
* Add ticker_root, postal_code, and round_lot attributes to the Ticker Details response types
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
## [7.0.0](https://github.com/massive.com/client-js/v6.2.0...v7.0.0) (2023-01-25)
|
|
84
|
+
|
|
85
|
+
> Description
|
|
86
|
+
|
|
87
|
+
### Upgrade Steps
|
|
88
|
+
|
|
89
|
+
#### Node Version
|
|
90
|
+
To use this version in a node project you will need to use node 16 or above. This change was made to support exporting ES Modules instead of CommonJS Modules. The ES Modules exported by this package should be fully supported in Node 16+.
|
|
91
|
+
|
|
92
|
+
#### Headers and Request Options
|
|
93
|
+
The headers parameter has been replaced with a request options parameter which accepts headers. If you were passing headers to an endpoint, your code should change from
|
|
94
|
+
|
|
95
|
+
```javascript
|
|
96
|
+
rest.forex.previousClose("C:EURUSD", {}, myHeadersObject)
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
to
|
|
100
|
+
|
|
101
|
+
```javascript
|
|
102
|
+
rest.forex.previousClose("C:EURUSD", {}, { headers: myHeadersObject })
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
This change was made to allow additional request options to be passed to the request. You can pass any of the [available request options for fetch](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch#supplying_request_options) in the request options object, and they will be passed through to the fetch request.
|
|
106
|
+
|
|
107
|
+
You can also pass request options when initializing the client like:
|
|
108
|
+
|
|
109
|
+
```javascript
|
|
110
|
+
const rest = restClient("API KEY", "https://api.massive.com", { headers: myHeaders });
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
These will be applied to each request unless overridden by options passed directly to the endpoint function.
|
|
114
|
+
|
|
115
|
+
You can find more examples in the [configuration examples file](./examples/rest/configuration.js).
|
|
116
|
+
|
|
117
|
+
### Breaking Changes
|
|
118
|
+
* Node 16+ compilation target
|
|
119
|
+
* Pass entire request options as optional parameter instead of just headers
|
|
120
|
+
|
|
121
|
+
### New Features
|
|
122
|
+
* Allow request options to be passed globally to the client, or individually to endpoint functions
|
|
123
|
+
|
|
124
|
+
### Bug Fixes
|
|
125
|
+
* Pass api key in header instead of query parameter to improve security
|
|
126
|
+
|
|
127
|
+
### Other Changes
|
|
128
|
+
* Improved test coverage
|
|
129
|
+
* Additional examples
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2019 Polygon.io
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
# Massive JS Client
|
|
2
|
+
|
|
3
|
+
[](https://github.com/prettier/prettier)
|
|
4
|
+
|
|
5
|
+
Welcome to the official JS client library for the [Massive](https://massive.com/) REST and WebSocket API. To get started, please see the [Getting Started](https://massive.com/docs/stocks/getting-started) section in our documentation, view the [examples](./examples/) directory for code snippets, or the [blog post](https://massive.com/blog/javascript-stock-market-data/) with video tutorials to learn more. To generate the package documentation please run `npm run generate-doc`.
|
|
6
|
+
|
|
7
|
+
For upgrade instructions please see the [Release Notes](./CHANGELOG.md).
|
|
8
|
+
|
|
9
|
+
**Note:** Polygon.io has rebranded as [Massive.com](https://massive.com) on Oct 30, 2025. Existing API keys, accounts, and integrations continue to work exactly as before. The only change in this SDK is that it now defaults to the new API base at `api.massive.com`, while `api.polygon.io` remains supported for an extended period.
|
|
10
|
+
|
|
11
|
+
For details, see our [rebrand announcement blog post](https://massive.com/blog/polygon-is-now-massive/) or open an issue / contact [support@massive.com](mailto:support@massive.com) if you have questions.
|
|
12
|
+
|
|
13
|
+
## Getting the client
|
|
14
|
+
|
|
15
|
+
To get started, you'll need to install the client library:
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
npm install --save '@massive.com/client-js'
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Next, create a new client with your [API key](https://massive.com/dashboard/signup).
|
|
22
|
+
|
|
23
|
+
```javascript
|
|
24
|
+
import { restClient } from '@massive.com/client-js';
|
|
25
|
+
const rest = restClient(process.env.POLY_API_KEY);
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Using the client
|
|
29
|
+
|
|
30
|
+
After creating the client, making calls to the Massive API is easy. For example, here's how to get aggregates (bars):
|
|
31
|
+
|
|
32
|
+
```javascript
|
|
33
|
+
rest.getStocksAggregates("AAPL", 1, GetStocksAggregatesTimespanEnum.Day, "2023-01-01", "2023-04-14").then((response) => {
|
|
34
|
+
console.log(response);
|
|
35
|
+
}).catch(e => {
|
|
36
|
+
console.error('An error happened:', e);
|
|
37
|
+
});
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
Or, maybe you want to get the last trades or quotes for a ticker:
|
|
41
|
+
|
|
42
|
+
```javascript
|
|
43
|
+
// last trade
|
|
44
|
+
rest.getLastStocksTrade("AAPL").then((response) => {
|
|
45
|
+
console.log(response);
|
|
46
|
+
}).catch(e => {
|
|
47
|
+
console.error('An error happened:', e);
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
// last quote (NBBO)
|
|
51
|
+
rest.getLastStocksQuote("AAPL").then((response) => {
|
|
52
|
+
console.log(response);
|
|
53
|
+
}).catch(e => {
|
|
54
|
+
console.error('An error happened:', e);
|
|
55
|
+
});
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
Finally, maybe you want a market-wide snapshot of all tickers:
|
|
59
|
+
|
|
60
|
+
```javascript
|
|
61
|
+
rest.getSnapshots().then((response) => {
|
|
62
|
+
console.log(response);
|
|
63
|
+
}).catch(e => {
|
|
64
|
+
console.error('An error happened:', e);
|
|
65
|
+
});
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
See [full examples](./examples/rest/) for more details on how to use this client effectively.
|
|
69
|
+
|
|
70
|
+
## Pagination
|
|
71
|
+
|
|
72
|
+
The client can handle pagination for you through the `globalFetchOptions` by turning on the `pagination: true` option. The feature will automatically fetch all `next_url` pages of data when the API response indicates more data is available.
|
|
73
|
+
|
|
74
|
+
```javascript
|
|
75
|
+
import { restClient } from '@massive.com/client-js';
|
|
76
|
+
|
|
77
|
+
const globalFetchOptions = {
|
|
78
|
+
pagination: true,
|
|
79
|
+
};
|
|
80
|
+
const rest = restClient(process.env.POLY_API_KEY, "https://api.massive.com", globalFetchOptions);
|
|
81
|
+
|
|
82
|
+
rest.getStocksAggregates("AAPL", 1, GetStocksAggregatesTimespanEnum.Day, "2023-01-01", "2023-04-14").then((response) => {
|
|
83
|
+
const data = response.data; // convert axios-wrapped response
|
|
84
|
+
const resultCount = data.resultsCount;
|
|
85
|
+
console.log("Result count:", resultCount);
|
|
86
|
+
}).catch(e => {
|
|
87
|
+
console.error('An error happened:', e);
|
|
88
|
+
});
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
If there is a `next_url` field in the API response, the client will recursively fetch the next page for you, and then pass along the accumulated data.
|
|
92
|
+
|
|
93
|
+
## WebSocket Client
|
|
94
|
+
|
|
95
|
+
Import the [Websocket](https://massive.com/docs/stocks/ws_getting-started) client and models packages to get started. You can get preauthenticated [websocket clients](https://www.npmjs.com/package/websocket) for the 3 topics.
|
|
96
|
+
|
|
97
|
+
```javascript
|
|
98
|
+
import { websocketClient } from "@massive.com/client-js";
|
|
99
|
+
const stocksWS = websocketClient(process.env.POLY_API_KEY, 'wss://delayed.massive.com').stocks();
|
|
100
|
+
|
|
101
|
+
stocksWS.onmessage = ({response}) => {
|
|
102
|
+
const [message] = JSON.parse(response);
|
|
103
|
+
|
|
104
|
+
stocksWS.send('{"action":"subscribe", "params":"AM.MSFT,A.MSFT"}');
|
|
105
|
+
|
|
106
|
+
switch (message.ev) {
|
|
107
|
+
case "AM":
|
|
108
|
+
// your trade message handler
|
|
109
|
+
break;
|
|
110
|
+
case "A":
|
|
111
|
+
// your trade message handler
|
|
112
|
+
break;
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
stocksWS.send({ action: "subscribe", params: "T.MSFT" });
|
|
117
|
+
```
|
|
118
|
+
See [full examples](./examples/websocket/) for more details on how to use this client effectively.
|
|
119
|
+
|
|
120
|
+
## Contributing
|
|
121
|
+
|
|
122
|
+
If you found a bug or have an idea for a new feature, please first discuss it with us by [submitting a new issue](https://github.com/massive.com/client-js/issues/new/choose). We will respond to issues within at most 3 weeks. We're also open to volunteers if you want to submit a PR for any open issues but please discuss it with us beforehand. PRs that aren't linked to an existing issue or discussed with us ahead of time will generally be declined. If you have more general feedback or want to discuss using this client with other users, feel free to reach out on our [Slack channel](https://massive.com.slack.com/archives/C03FCSBSAFL).
|