Skip to content

Commit

Permalink
Update require syntax in examples to use import instead. Update examp…
Browse files Browse the repository at this point in the history
…les to you env variable so they can easily be run from the command line (#173)
  • Loading branch information
timetraveler328 authored Aug 11, 2023
1 parent bd098db commit ef43990
Show file tree
Hide file tree
Showing 105 changed files with 274 additions and 210 deletions.
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ npm install --save @polygon.io/client-js
Next, create a new client with your [API key](https://polygon.io/dashboard/signup).

```javascript
const { restClient } = require('@polygon.io/client-js');
const rest = restClient("API KEY");
import { restClient } from '@polygon.io/client-js';
const rest = restClient(process.env.POLY_API_KEY);
```

## Using the client
Expand Down Expand Up @@ -61,7 +61,8 @@ rest.stocks.snapshotAllTickers().then((data) => {
});
```

See [full examples](./examples/rest/) for more details on how to use this client effectively.
See [full examples](./examples/rest/) for more details on how to use this client effectively.
To run these examples from the command line, first check out this project and run ```npm i``` in the root directory to install dependencies, then run ```POLY_API_KEY=yourAPIKey node examples/rest/crypto-aggregates_bars.js```, replacing yourAPIKey with your Polygon API Key.

## Launchpad Usage

Expand All @@ -73,7 +74,7 @@ Import the [Websocket](https://polygon.io/docs/stocks/ws_getting-started) client

```javascript
import { websocketClient } from "@polygon.io/client-js";
const stocksWS = websocketClient("API KEY").stocks();
const stocksWS = websocketClient(process.env.POLY_API_KEY).stocks();

stocksWS.onmessage = ({data}) => {
const [message] = JSON.parse(data);
Expand Down
4 changes: 2 additions & 2 deletions examples/rest/configuration.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
const { restClient } = require('@polygon.io/client-js');
import { restClient } from '@polygon.io/client-js';

// You can pass global options to fetch to add headers or configure requests
const globalFetchOptions = {
method: 'HEAD'
}
const rest = restClient("API KEY", "https://api.polygon.io", globalFetchOptions);
const rest = restClient(process.env.POLY_API_KEY, "https://api.polygon.io", globalFetchOptions);

// You can also pass options to each individual call, each key will override keys from the options also set globally

Expand Down
4 changes: 2 additions & 2 deletions examples/rest/crypto-aggregates_bars.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const { restClient } = require('@polygon.io/client-js');
const rest = restClient("API KEY", "https://api.polygon.io");
import { restClient } from '@polygon.io/client-js';
const rest = restClient(process.env.POLY_API_KEY);

// https://polygon.io/docs/crypto/get_v2_aggs_ticker__cryptoticker__range__multiplier___timespan___from___to
rest.crypto.aggregates("X:BTCUSD", 1, "day", "2023-01-30", "2023-02-03").then((data) => {
Expand Down
4 changes: 2 additions & 2 deletions examples/rest/crypto-conditions.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const { restClient } = require('@polygon.io/client-js');
const rest = restClient("API KEY", "https://api.polygon.io");
import { restClient } from '@polygon.io/client-js';
const rest = restClient(process.env.POLY_API_KEY);

// https://polygon.io/docs/crypto/get_v3_reference_conditions
rest.reference.conditions({ asset_class: "crypto", limit: 1000 }).then((data) => {
Expand Down
4 changes: 2 additions & 2 deletions examples/rest/crypto-daily_open_close.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const { restClient } = require('@polygon.io/client-js');
const rest = restClient("API KEY", "https://api.polygon.io");
import { restClient } from '@polygon.io/client-js';
const rest = restClient(process.env.POLY_API_KEY);

// https://polygon.io/docs/crypto/get_v1_open-close_crypto__from___to___date
rest.crypto.dailyOpenClose("BTC", "USD", "2019-01-01").then((data) => {
Expand Down
4 changes: 2 additions & 2 deletions examples/rest/crypto-exchanges.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const { restClient } = require('@polygon.io/client-js');
const rest = restClient("API KEY", "https://api.polygon.io");
import { restClient } from '@polygon.io/client-js';
const rest = restClient(process.env.POLY_API_KEY);

// https://polygon.io/docs/crypto/get_v3_reference_exchanges
rest.reference.exchanges({ asset_class: "crypto", limit: 1000 }).then((data) => {
Expand Down
4 changes: 2 additions & 2 deletions examples/rest/crypto-grouped_daily_bars.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const { restClient } = require('@polygon.io/client-js');
const rest = restClient("API KEY", "https://api.polygon.io");
import { restClient } from '@polygon.io/client-js';
const rest = restClient(process.env.POLY_API_KEY);

// https://polygon.io/docs/crypto/get_v2_aggs_grouped_locale_global_market_crypto__date
rest.crypto.aggregatesGroupedDaily("2023-03-31").then((data) => {
Expand Down
4 changes: 2 additions & 2 deletions examples/rest/crypto-last_trade_for_a_crypto_pair.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const { restClient } = require('@polygon.io/client-js');
const rest = restClient("API KEY", "https://api.polygon.io");
import { restClient } from '@polygon.io/client-js';
const rest = restClient(process.env.POLY_API_KEY);

// https://polygon.io/docs/crypto/get_v1_last_crypto__from___to
rest.crypto.lastTrade("BTC", "USD").then((data) => {
Expand Down
4 changes: 2 additions & 2 deletions examples/rest/crypto-market_holidays.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const { restClient } = require('@polygon.io/client-js');
const rest = restClient("API KEY", "https://api.polygon.io");
import { restClient } from '@polygon.io/client-js';
const rest = restClient(process.env.POLY_API_KEY);

// https://polygon.io/docs/crypto/get_v1_marketstatus_upcoming
rest.reference.marketHolidays().then((data) => {
Expand Down
4 changes: 2 additions & 2 deletions examples/rest/crypto-market_status.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const { restClient } = require('@polygon.io/client-js');
const rest = restClient("API KEY", "https://api.polygon.io");
import { restClient } from '@polygon.io/client-js';
const rest = restClient(process.env.POLY_API_KEY);

// https://polygon.io/docs/crypto/get_v1_marketstatus_now
rest.reference.marketStatus().then((data) => {
Expand Down
4 changes: 2 additions & 2 deletions examples/rest/crypto-previous_close.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const { restClient } = require('@polygon.io/client-js');
const rest = restClient("API KEY", "https://api.polygon.io");
import { restClient } from '@polygon.io/client-js';
const rest = restClient(process.env.POLY_API_KEY);

// https://polygon.io/docs/crypto/get_v2_aggs_ticker__cryptoticker__prev
rest.crypto.previousClose("X:BTCUSD").then((data) => {
Expand Down
4 changes: 2 additions & 2 deletions examples/rest/crypto-snapshots_all_tickers.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const { restClient } = require('@polygon.io/client-js');
const rest = restClient("API KEY", "https://api.polygon.io");
import { restClient } from '@polygon.io/client-js';
const rest = restClient(process.env.POLY_API_KEY);

// https://polygon.io/docs/crypto/get_v2_snapshot_locale_global_markets_crypto_tickers
rest.crypto.snapshotAllTickers("").then((data) => {
Expand Down
4 changes: 2 additions & 2 deletions examples/rest/crypto-snapshots_gainers_losers.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const { restClient } = require('@polygon.io/client-js');
const rest = restClient("API KEY", "https://api.polygon.io");
import { restClient } from '@polygon.io/client-js';
const rest = restClient(process.env.POLY_API_KEY);

// https://polygon.io/docs/crypto/get_v2_snapshot_locale_global_markets_crypto__direction
// gainers
Expand Down
4 changes: 2 additions & 2 deletions examples/rest/crypto-snapshots_ticker.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const { restClient } = require('@polygon.io/client-js');
const rest = restClient("API KEY", "https://api.polygon.io");
import { restClient } from '@polygon.io/client-js';
const rest = restClient(process.env.POLY_API_KEY);

// https://polygon.io/docs/crypto/get_v2_snapshot_locale_global_markets_crypto_tickers__ticker
rest.crypto.snapshotTicker("X:BTCUSD").then((data) => {
Expand Down
4 changes: 2 additions & 2 deletions examples/rest/crypto-snapshots_ticker_full_book_l2.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const { restClient } = require('@polygon.io/client-js');
const rest = restClient("API KEY", "https://api.polygon.io");
import { restClient } from '@polygon.io/client-js';
const rest = restClient(process.env.POLY_API_KEY);

// https://polygon.io/docs/crypto/get_v2_snapshot_locale_global_markets_crypto_tickers__ticker__book
rest.crypto.snapshotTickerFullBookL2("X:BTCUSD").then((data) => {
Expand Down
4 changes: 2 additions & 2 deletions examples/rest/crypto-technical_indicators_ema.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const { restClient } = require('@polygon.io/client-js');
const rest = restClient("API KEY", "https://api.polygon.io");
import { restClient } from '@polygon.io/client-js';
const rest = restClient(process.env.POLY_API_KEY);

// https://polygon.io/docs/crypto/get_v1_indicators_ema__cryptoticker
rest.crypto.ema("X:BTCUSD").then((data) => {
Expand Down
4 changes: 2 additions & 2 deletions examples/rest/crypto-technical_indicators_macd.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const { restClient } = require('@polygon.io/client-js');
const rest = restClient("API KEY", "https://api.polygon.io");
import { restClient } from '@polygon.io/client-js';
const rest = restClient(process.env.POLY_API_KEY);

// https://polygon.io/docs/crypto/get_v1_indicators_macd__cryptoticker
rest.crypto.macd("X:BTCUSD").then((data) => {
Expand Down
4 changes: 2 additions & 2 deletions examples/rest/crypto-technical_indicators_rsi.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const { restClient } = require('@polygon.io/client-js');
const rest = restClient("API KEY", "https://api.polygon.io");
import { restClient } from '@polygon.io/client-js';
const rest = restClient(process.env.POLY_API_KEY);

// hhttps://polygon.io/docs/crypto/get_v1_indicators_rsi__cryptoticker
rest.crypto.rsi("X:BTCUSD").then((data) => {
Expand Down
4 changes: 2 additions & 2 deletions examples/rest/crypto-technical_indicators_sma.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const { restClient } = require('@polygon.io/client-js');
const rest = restClient("API KEY", "https://api.polygon.io");
import { restClient } from '@polygon.io/client-js';
const rest = restClient(process.env.POLY_API_KEY);

// https://polygon.io/docs/crypto/get_v1_indicators_sma__cryptoticker
rest.crypto.sma("X:BTCUSD").then((data) => {
Expand Down
4 changes: 2 additions & 2 deletions examples/rest/crypto-tickers.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const { restClient } = require('@polygon.io/client-js');
const rest = restClient("API KEY", "https://api.polygon.io");
import { restClient } from '@polygon.io/client-js';
const rest = restClient(process.env.POLY_API_KEY);

// https://polygon.io/docs/crypto/get_v3_reference_tickers
rest.reference.tickers({ market: "crypto", limit: 1000 }).then((data) => {
Expand Down
4 changes: 2 additions & 2 deletions examples/rest/crypto-trades.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const { restClient } = require('@polygon.io/client-js');
const rest = restClient("API KEY", "https://api.polygon.io");
import { restClient } from '@polygon.io/client-js';
const rest = restClient(process.env.POLY_API_KEY);

// https://polygon.io/docs/crypto/get_v3_trades__cryptoticker
rest.crypto.trades("X:BTCUSD").then((data) => {
Expand Down
4 changes: 2 additions & 2 deletions examples/rest/forex-aggregates_bars.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const { restClient } = require('@polygon.io/client-js');
const rest = restClient("API KEY", "https://api.polygon.io");
import { restClient } from '@polygon.io/client-js';
const rest = restClient(process.env.POLY_API_KEY);

// https://polygon.io/docs/forex/get_v2_aggs_ticker__forexticker__range__multiplier___timespan___from___to
rest.forex.aggregates("C:EURUSD", 1, "day", "2019-01-01", "2019-02-01").then((data) => {
Expand Down
4 changes: 2 additions & 2 deletions examples/rest/forex-conditions.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const { restClient } = require('@polygon.io/client-js');
const rest = restClient("API KEY", "https://api.polygon.io");
import { restClient } from '@polygon.io/client-js';
const rest = restClient(process.env.POLY_API_KEY);

// https://polygon.io/docs/forex/get_v3_reference_conditions
rest.reference.conditions({ asset_class: "fx", limit: 1000 }).then((data) => {
Expand Down
4 changes: 2 additions & 2 deletions examples/rest/forex-exchanges.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const { restClient } = require('@polygon.io/client-js');
const rest = restClient("API KEY", "https://api.polygon.io");
import { restClient } from '@polygon.io/client-js';
const rest = restClient(process.env.POLY_API_KEY);

// https://polygon.io/docs/forex/get_v3_reference_exchanges
rest.reference.exchanges({ asset_class: "fx", limit: 1000 }).then((data) => {
Expand Down
4 changes: 2 additions & 2 deletions examples/rest/forex-grouped_daily_bars.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const { restClient } = require('@polygon.io/client-js');
const rest = restClient("API KEY", "https://api.polygon.io");
import { restClient } from '@polygon.io/client-js';
const rest = restClient(process.env.POLY_API_KEY);

// https://polygon.io/docs/forex/get_v2_aggs_grouped_locale_global_market_fx__date
rest.forex.aggregatesGroupedDaily("2023-03-31").then((data) => {
Expand Down
4 changes: 2 additions & 2 deletions examples/rest/forex-last_quote_for_a_currency_pair.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const { restClient } = require('@polygon.io/client-js');
const rest = restClient("API KEY", "https://api.polygon.io");
import { restClient } from '@polygon.io/client-js';
const rest = restClient(process.env.POLY_API_KEY);

// https://polygon.io/docs/forex/get_v1_last_quote_currencies__from___to
rest.forex.lastQuote("AUD", "USD").then((data) => {
Expand Down
4 changes: 2 additions & 2 deletions examples/rest/forex-market_holidays.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const { restClient } = require('@polygon.io/client-js');
const rest = restClient("API KEY", "https://api.polygon.io");
import { restClient } from '@polygon.io/client-js';
const rest = restClient(process.env.POLY_API_KEY);

// https://polygon.io/docs/forex/get_v1_marketstatus_upcoming
rest.reference.marketHolidays().then((data) => {
Expand Down
4 changes: 2 additions & 2 deletions examples/rest/forex-market_status.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const { restClient } = require('@polygon.io/client-js');
const rest = restClient("API KEY", "https://api.polygon.io");
import { restClient } from '@polygon.io/client-js';
const rest = restClient(process.env.POLY_API_KEY);

// https://polygon.io/docs/forex/get_v1_marketstatus_now
rest.reference.marketStatus().then((data) => {
Expand Down
4 changes: 2 additions & 2 deletions examples/rest/forex-previous_close.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const { restClient } = require('@polygon.io/client-js');
const rest = restClient("API KEY", "https://api.polygon.io");
import { restClient } from '@polygon.io/client-js';
const rest = restClient(process.env.POLY_API_KEY);

// https://polygon.io/docs/forex/get_v2_aggs_ticker__forexticker__prev
rest.forex.previousClose("C:EURUSD").then((data) => {
Expand Down
4 changes: 2 additions & 2 deletions examples/rest/forex-quotes.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const { restClient } = require('@polygon.io/client-js');
const rest = restClient("API KEY", "https://api.polygon.io");
import { restClient } from '@polygon.io/client-js';
const rest = restClient(process.env.POLY_API_KEY);

// https://polygon.io/docs/forex/get_v3_quotes__fxticker
rest.forex.quotes("C:EUR-USD").then((data) => {
Expand Down
4 changes: 2 additions & 2 deletions examples/rest/forex-real-time_currency_conversion.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const { restClient } = require('@polygon.io/client-js');
const rest = restClient("API KEY", "https://api.polygon.io");
import { restClient } from '@polygon.io/client-js';
const rest = restClient(process.env.POLY_API_KEY);

// https://polygon.io/docs/forex/get_v1_conversion__from___to
rest.forex.conversion("AUD", "USD").then((data) => {
Expand Down
4 changes: 2 additions & 2 deletions examples/rest/forex-snapshots_all_tickers.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const { restClient } = require('@polygon.io/client-js');
const rest = restClient("API KEY", "https://api.polygon.io");
import { restClient } from '@polygon.io/client-js';
const rest = restClient(process.env.POLY_API_KEY);

// https://polygon.io/docs/forex/get_v2_snapshot_locale_global_markets_forex_tickers
rest.forex.snapshotTicker("").then((data) => {
Expand Down
4 changes: 2 additions & 2 deletions examples/rest/forex-snapshots_gainers_losers.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const { restClient } = require('@polygon.io/client-js');
const rest = restClient("API KEY", "https://api.polygon.io");
import { restClient } from '@polygon.io/client-js';
const rest = restClient(process.env.POLY_API_KEY);

// https://polygon.io/docs/forex/get_v2_snapshot_locale_global_markets_forex__direction
// gainers
Expand Down
4 changes: 2 additions & 2 deletions examples/rest/forex-snapshots_ticker.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const { restClient } = require('@polygon.io/client-js');
const rest = restClient("API KEY", "https://api.polygon.io");
import { restClient } from '@polygon.io/client-js';
const rest = restClient(process.env.POLY_API_KEY);

// https://polygon.io/docs/forex/get_v2_snapshot_locale_global_markets_forex_tickers__ticker
rest.forex.snapshotTicker("C:EURUSD").then((data) => {
Expand Down
4 changes: 2 additions & 2 deletions examples/rest/forex-technical_indicators_ema.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const { restClient } = require('@polygon.io/client-js');
const rest = restClient("API KEY", "https://api.polygon.io");
import { restClient } from '@polygon.io/client-js';
const rest = restClient(process.env.POLY_API_KEY);

// https://polygon.io/docs/forex/get_v1_indicators_ema__fxticker
rest.forex.ema("C:EURUSD",
Expand Down
4 changes: 2 additions & 2 deletions examples/rest/forex-technical_indicators_macd.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const { restClient } = require('@polygon.io/client-js');
const rest = restClient("API KEY", "https://api.polygon.io");
import { restClient } from '@polygon.io/client-js';
const rest = restClient(process.env.POLY_API_KEY);

// https://polygon.io/docs/forex/get_v1_indicators_macd__fxticker
rest.forex.macd("C:EURUSD").then((data) => {
Expand Down
4 changes: 2 additions & 2 deletions examples/rest/forex-technical_indicators_rsi.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const { restClient } = require('@polygon.io/client-js');
const rest = restClient("API KEY", "https://api.polygon.io");
import { restClient } from '@polygon.io/client-js';
const rest = restClient(process.env.POLY_API_KEY);

// https://polygon.io/docs/forex/get_v1_indicators_rsi__fxticker
rest.forex.rsi("C:EURUSD").then((data) => {
Expand Down
4 changes: 2 additions & 2 deletions examples/rest/forex-technical_indicators_sma.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const { restClient } = require('@polygon.io/client-js');
const rest = restClient("API KEY", "https://api.polygon.io");
import { restClient } from '@polygon.io/client-js';
const rest = restClient(process.env.POLY_API_KEY);

// https://polygon.io/docs/forex/get_v1_indicators_sma__fxticker
rest.forex.sma("C:EURUSD").then((data) => {
Expand Down
4 changes: 2 additions & 2 deletions examples/rest/forex-tickers.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const { restClient } = require('@polygon.io/client-js');
const rest = restClient("API KEY", "https://api.polygon.io");
import { restClient } from '@polygon.io/client-js';
const rest = restClient(process.env.POLY_API_KEY);

// https://polygon.io/docs/forex/get_v3_reference_tickers
rest.reference.tickers({ market: "fx", limit: 1000 }).then((data) => {
Expand Down
4 changes: 2 additions & 2 deletions examples/rest/indices-aggregates_bars.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const { restClient } = require('@polygon.io/client-js');
const rest = restClient("API KEY", "https://api.polygon.io");
import { restClient } from '@polygon.io/client-js';
const rest = restClient(process.env.POLY_API_KEY);

// https://polygon.io/docs/indices/get_v2_aggs_ticker__indicesticker__range__multiplier___timespan___from___to
rest.indices.aggregates("I:SPX", 1, "day", "2023-03-10", "2023-03-10").then((data) => {
Expand Down
4 changes: 2 additions & 2 deletions examples/rest/indices-daily_open_close.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const { restClient } = require('@polygon.io/client-js');
const rest = restClient("API KEY", "https://api.polygon.io");
import { restClient } from '@polygon.io/client-js';
const rest = restClient(process.env.POLY_API_KEY);

// https://polygon.io/docs/indices/get_v1_open-close__indicesticker___date
rest.indices.dailyOpenClose("I:SPX", "2023-03-31").then((data) => {
Expand Down
4 changes: 2 additions & 2 deletions examples/rest/indices-market_holidays.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const { restClient } = require('@polygon.io/client-js');
const rest = restClient("API KEY", "https://api.polygon.io");
import { restClient } from '@polygon.io/client-js';
const rest = restClient(process.env.POLY_API_KEY);

// https://polygon.io/docs/indices/get_v1_marketstatus_upcoming
rest.reference.marketHolidays().then((data) => {
Expand Down
4 changes: 2 additions & 2 deletions examples/rest/indices-market_status.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const { restClient } = require('@polygon.io/client-js');
const rest = restClient("API KEY", "https://api.polygon.io");
import { restClient } from '@polygon.io/client-js';
const rest = restClient(process.env.POLY_API_KEY);

// https://polygon.io/docs/indices/get_v1_marketstatus_now
rest.reference.marketStatus().then((data) => {
Expand Down
4 changes: 2 additions & 2 deletions examples/rest/indices-previous_close.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const { restClient } = require('@polygon.io/client-js');
const rest = restClient("API KEY", "https://api.polygon.io");
import { restClient } from '@polygon.io/client-js';
const rest = restClient(process.env.POLY_API_KEY);

// https://polygon.io/docs/indices/get_v2_aggs_ticker__indicesticker__prev
rest.indices.previousClose("I:SPX").then((data) => {
Expand Down
4 changes: 2 additions & 2 deletions examples/rest/indices-snapshots.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const { restClient } = require('@polygon.io/client-js');
const rest = restClient("API KEY", "https://api.polygon.io");
import { restClient } from '@polygon.io/client-js';
const rest = restClient(process.env.POLY_API_KEY);

// https://polygon.io/docs/indices/get_v3_snapshot_indices
rest.indices.snapshotTicker({ "ticker.any_of": "I:SPX" }).then((data) => {
Expand Down
4 changes: 2 additions & 2 deletions examples/rest/indices-technical_indicators_ema.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const { restClient } = require('@polygon.io/client-js');
const rest = restClient("API KEY", "https://api.polygon.io");
import { restClient } from '@polygon.io/client-js';
const rest = restClient(process.env.POLY_API_KEY);

// https://polygon.io/docs/indices/get_v1_indicators_ema__indicesticker
rest.indices.ema("I:SPX").then((data) => {
Expand Down
Loading

0 comments on commit ef43990

Please sign in to comment.