Socket
Socket
Sign inDemoInstall

polygon.io

Package Overview
Dependencies
31
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

polygon.io

Isomorphic Javascript client for Polygon.io Stocks, Forex, and Crypto APIs


Version published
Maintainers
1
Weekly downloads
136
decreased by-34.62%

Weekly downloads

Readme

Source

polygon.io

code style: prettier

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

Keywords

FAQs

Last updated on 26 Mar 2021

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc