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");
rest.forex
.previousClose()
.then()
.catch();
- import all the rest submodule
import { restClient } from "polygon.io";
const rest = restClient("api key");
rest.forex.previousClose().then();
- import a specific submodule
import { referenceClient } from "polygon.io";
const reference = referenceClient("api key");
reference.tickers.then();
You can get preauthenticated websocket clients for the 3 topics.
import { websocketClient } from "polygon.io";
const stocksWS = websocketClient("api key").getStocksWebsocket();
stocksWs.on("message", raw => {
const message = JSON.parse(raw);
switch (message.ev) {
case "T":
break;
}
});
stocksWS.send({ action: "subscribe", params: "T.MSFT" });
- Generate the package documentation
npm run generate-doc