8000 Update require syntax in examples to use import instead. Update examp… · polygon-io/client-js@ef43990 · GitHub
[go: up one dir, main page]

Skip to content

Commit ef43990

Browse files
Update require syntax in examples to use import instead. Update examples to you env variable so they can easily be run from the command line (#173)
1 parent bd098db commit ef43990

File tree

105 files changed

+274
-210
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

105 files changed

+274
-210
lines changed

README.md

Lines changed: 5 additions & 4 deletions

examples/rest/configuration.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
const { restClient } = require('@polygon.io/client-js');
1+
import { restClient } from '@polygon.io/client-js';
22

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

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

examples/rest/crypto-aggregates_bars.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
const { restClient } = require('@polygon.io/client-js');
2-
const rest = restClient("API KEY", "https://api.polygon.io");
1+
import { restClient } from '@polygon.io/client-js';
2+
const rest = restClient(process.env.POLY_API_KEY);
33

44
// https://polygon.io/docs/crypto/get_v2_aggs_ticker__cryptoticker__range__multiplier___timespan___from___to
55
rest.crypto.aggregates("X:BTCUSD", 1, "day", "2023-01-30", "2023-02-03").then((data) => {

examples/rest/crypto-conditions.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
const { restClient } = require('@polygon.io/client-js');
2-
const rest = restClient("API KEY", "https://api.polygon.io");
1+
import { restClient } from '@polygon.io/client-js';
2+
const rest = restClient(process.env.POLY_API_KEY);
33

44
// https://polygon.io/docs/crypto/get_v3_reference_conditions
55
rest.reference.conditions({ asset_class: "crypto", limit: 1000 }).then((data) => {

examples/rest/crypto-daily_open_close.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
const { restClient } = require('@polygon.io/client-js');
2-
const rest = restClient("API KEY", "https://api.polygon.io");
1+
import { restClient } from '@polygon.io/client-js';
2+
const rest = restClient(process.env.POLY_API_KEY);
33

44
// https://polygon.io/docs/crypto/get_v1_open-close_crypto__from___to___date
55
rest.crypto.dailyOpenClose("BTC", "USD", "2019-01-01").then((data) => {

examples/rest/crypto-exchanges.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
const { restClient } = require('@polygon.io/client-js');
2-
const rest = restClient("API KEY", "https://api.polygon.io");
1+
import { restClient } from '@polygon.io/client-js';
2+
const rest = restClient(process.env.POLY_API_KEY);
33

44
// https://polygon.io/docs/crypto/get_v3_reference_exchanges
55
rest.reference.exchanges({ asset_class: "crypto", limit: 1000 }).then((data) => {

examples/rest/crypto-grouped_daily_bars.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
const { restClient } = require('@polygon.io/client-js');
2-
const rest = restClient("API KEY", "https://api.polygon.io");
1+
import { restClient } from '@polygon.io/client-js';
2+
const rest = restClient(process.env.POLY_API_KEY);
33

44
// https://polygon.io/docs/crypto/get_v2_aggs_grouped_locale_global_market_crypto__date
55
rest.crypto.aggregatesGroupedDaily("2023-03-31").then((data) => {

examples/rest/crypto-last_trade_for_a_crypto_pair.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
const { restClient } = require('@polygon.io/client-js');
2-
const rest = restClient("API KEY", "https://api.polygon.io");
1+
import { restClient } from '@polygon.io/client-js';
2+
const rest = restClient(process.env.POLY_API_KEY);
33

44
// https://polygon.io/docs/crypto/get_v1_last_crypto__from___to
55
rest.crypto.lastTrade("BTC", "USD").then((data) => {

examples/rest/crypto-market_holidays.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
const { restClient } = require('@polygon.io/client-js');
2-
const rest = restClient("API KEY", "https://api.polygon.io");
1+
import { restClient } from '@polygon.io/client-js';
2+
const rest = restClient(process.env.POLY_API_KEY);
33

44
// https://polygon.io/docs/crypto/get_v1_marketstatus_upcoming
55
rest.reference.marketHolidays().then((data) => {

examples/rest/crypto-market_status.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
const { restClient } = require('@polygon.io/client-js');
2-
const rest = restClient("API KEY", "https://api.polygon.io");
1+
import { restClient } from '@polygon.io/client-js';
2+
const rest = restClient(process.env.POLY_API_KEY);
33

44
// https://polygon.io/docs/crypto/get_v1_marketstatus_now
55
rest.reference.marketStatus().then((data) => {

0 commit comments

Comments
 (0)
0