2.1.2 • Published 3 years ago
polygon.io v2.1.2
polygon.io
This package has moved
This package has moved to @polygon.io/client-js
Install
npm install --save polygon.io
usage
Authentication
- call the desired client with your api key to initialize it
import { polygonClient, restClient, websocketClient } from "polygon.io";
const rest = restClient("API KEY");
// you can use the api now
rest.forex
.previousClose()
.then(/* your success handler */)
.catch(/* your error handler*/);
REST API
- import all the rest submodule
import { restClient } from "polygon.io";
const rest = restClient("api key");
rest.forex.previousClose().then(/* your success handler */);
- import a specific submodule
import { referenceClient } from "polygon.io";
const reference = referenceClient("api key");
reference.tickers.then(/* your success handler */);
Websocket
You can get preauthenticated websocket clients for the 3 topics.
import { websocketClient } from "polygon.io";
const stocksWS = websocketClient("api key").getStocksWebsocket();
stocksWs.onmessage = raw => {
const message = JSON.parse(raw);
switch (message.ev) {
case "T":
// your trade message handler
break;
}
});
stocksWS.send({ action: "subscribe", params: "T.MSFT" });
documentation
- Generate the package documentation
npm run generate-doc
2.1.2
3 years ago
2.1.1
3 years ago
2.1.0
3 years ago
2.0.2
3 years ago
2.0.1
3 years ago
2.0.0
3 years ago
1.1.0
4 years ago
1.0.0
5 years ago
0.7.0
5 years ago
0.6.0
5 years ago
0.5.1
5 years ago
0.5.0
5 years ago
0.4.2
5 years ago
0.4.1
5 years ago
0.4.0
5 years ago
0.3.1
5 years ago
0.3.0
5 years ago
0.2.2
5 years ago
0.2.1
5 years ago
0.2.0
5 years ago
0.1.1
5 years ago
0.1.0
5 years ago
0.0.0
5 years ago