From 246ec610cd4ef052991154d34d5f64dcf625700c Mon Sep 17 00:00:00 2001 From: Huseyin ELMAS Date: Mon, 20 Mar 2023 23:42:00 +0300 Subject: [PATCH 01/39] fix: incorrect stock financials field usages #141 (#142) `source_filling_url ` and `filling_date ` field names are used incorrectly. --- src/rest/reference/stockFinancials.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/rest/reference/stockFinancials.ts b/src/rest/reference/stockFinancials.ts index 848d2fa..7577d75 100644 --- a/src/rest/reference/stockFinancials.ts +++ b/src/rest/reference/stockFinancials.ts @@ -27,7 +27,7 @@ export interface IStocksFinancial { fiscal_period: string; fiscal_year: string; source_filing_file_url: string; - source_filling_url: string; + source_filing_url: string; start_date: string; } @@ -52,11 +52,11 @@ export interface IStockFinancialQuery extends IPolygonQuery { "company_name.gt"?: string; "company_name.gte"?: string; sic?: string; - filling_date?: string; - "filling_date.lt"?: string; - "filling_date.lte"?: string; - "filling_date.gt"?: string; - "filling_date.gte"?: string; + filing_date?: string; + "filing_date.lt"?: string; + "filing_date.lte"?: string; + "filing_date.gt"?: string; + "filing_date.gte"?: string; period_of_report_date?: string; "period_of_report_date.lt"?: string; "period_of_report_date.lte"?: string; @@ -66,7 +66,7 @@ export interface IStockFinancialQuery extends IPolygonQuery { included_sources?: "true" | "false"; order?: "asc" | "desc"; limit?: number; - sort?: "filling_date" | "period_of_report_date"; + sort?: "filing_date" | "period_of_report_date"; } export const stockFinancials = async ( From 3a586a98dd4d891b7f9b1c5a537e1048b181f997 Mon Sep 17 00:00:00 2001 From: Katie Adams <64220601+timetraveler328@users.noreply.github.com> Date: Mon, 20 Mar 2023 16:51:41 -0400 Subject: [PATCH 02/39] Release/v7.1.1 (#144) * Support throwing custom error to preserve JSON error provided by API (#143) * Changelog * 7.1.1 --- CHANGELOG.md | 6 ++++++ package-lock.json | 4 ++-- package.json | 2 +- src/rest/transport/request.ts | 26 +++++++++++++++++++++++--- 4 files changed, 32 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ce2a6c5..e9361a2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +## [7.1.1](https://github.com/polygon-io/client-js/v7.0.1...v7.1.1) (2023-03-20) + +### Bug Fixes +* Fix misspelled filling_url to filing_url +* Preserve JSON errors returned from the server + ## [7.1.0](https://github.com/polygon-io/client-js/compare/v7.0.3...v7.1.0) (2023-03-13) ### New Feature * Indices diff --git a/package-lock.json b/package-lock.json index b503826..08068e4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@polygon.io/client-js", - "version": "7.1.0", + "version": "7.1.1", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@polygon.io/client-js", - "version": "7.1.0", + "version": "7.1.1", "license": "MIT", "workspaces": [ "./lib/*", diff --git a/package.json b/package.json index 69e6590..5134d96 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@polygon.io/client-js", - "version": "7.1.0", + "version": "7.1.1", "description": "Isomorphic Javascript client for Polygon.io Stocks, Forex, and Crypto APIs", "main": "lib/main.js", "types": "lib/main.d.ts", diff --git a/src/rest/transport/request.ts b/src/rest/transport/request.ts index a1e763e..490b952 100644 --- a/src/rest/transport/request.ts +++ b/src/rest/transport/request.ts @@ -25,6 +25,17 @@ export interface IPolygonQueryWithCredentials extends IPolygonQuery { export type IGet = (path: string, query: IPolygonQuery, options: IRequestOptions) => Promise; export type ICurriedGet = (apiKey: string, apiBase: string, globalOptions?: IRequestOptions) => IGet; +export type IStructuredError = InstanceType; + +class StructuredError extends Error { + status: string; + request_id: string; + constructor(message: string, status: string = '', requestId: string = '') { + super(message); + this.status = status; + this.request_id = requestId; + } +} export const getWithGlobals: ICurriedGet = (apiKey, apiBase, globalOptions = {}): IGet => async ( path, query = {}, options = {} ): Promise => { @@ -45,8 +56,17 @@ export const getWithGlobals: ICurriedGet = (apiKey, apiBase, globalOptions = {}) }); if (response.status >= 400) { - const message = await response.text(); - throw new Error(message); + const rawMessage = await response.text(); + let error; + try { + // first try parsing JSON from the response + const json = JSON.parse(rawMessage); + error = new StructuredError(json.message, json.status, json.request_id); + } catch (e) { + // default to sending a string error message + error = new Error(rawMessage); + } + throw error; } if (response?.headers?.get('content-type') === 'text/csv') { @@ -55,6 +75,6 @@ export const getWithGlobals: ICurriedGet = (apiKey, apiBase, globalOptions = {}) return response.json(); } catch (e) { - throw new Error(e); + throw e; } }; From ba80dbe0eb8e30b45790e25726fb1a32c1456753 Mon Sep 17 00:00:00 2001 From: Katie Adams <64220601+timetraveler328@users.noreply.github.com> Date: Sat, 8 Apr 2023 11:11:08 -0400 Subject: [PATCH 03/39] Release/7.2.0 (#147) * Changelog * Use tsup build tool to bundle dual modules so that commonjs and esmodules are both supported (#146) * 7.2.0 --- .gitignore | 1 + CHANGELOG.md | 4 + package-lock.json | 1454 ++++++++++++++++++++++++++++++++++++++++++++- package.json | 15 +- tsconfig.json | 2 +- 5 files changed, 1467 insertions(+), 9 deletions(-) diff --git a/.gitignore b/.gitignore index 9b3eb89..477e27f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ # project artifcats +dist lib docs .DS_Store diff --git a/CHANGELOG.md b/CHANGELOG.md index e9361a2..a0fdb08 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## [7.2.0](https://github.com/polygon-io/client-js/compare/v7.1.1...v7.2.0) (2023-04-07) +### New Feature +* Support Dual Module Formats so that this package can be used with CommonJS + ## [7.1.1](https://github.com/polygon-io/client-js/v7.0.1...v7.1.1) (2023-03-20) ### Bug Fixes diff --git a/package-lock.json b/package-lock.json index 08068e4..91e8b5e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@polygon.io/client-js", - "version": "7.1.1", + "version": "7.2.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@polygon.io/client-js", - "version": "7.1.1", + "version": "7.2.0", "license": "MIT", "workspaces": [ "./lib/*", @@ -30,6 +30,7 @@ "prettier": "^2.5.1", "sinon": "^12.0.1", "ts-node": "^10.9.1", + "tsup": "^6.7.0", "typedoc": "^0.22.10", "typescript": "^4.5.2" }, @@ -49,6 +50,358 @@ "node": ">=12" } }, + "node_modules/@esbuild/android-arm": { + "version": "0.17.15", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.17.15.tgz", + "integrity": "sha512-sRSOVlLawAktpMvDyJIkdLI/c/kdRTOqo8t6ImVxg8yT7LQDUYV5Rp2FKeEosLr6ZCja9UjYAzyRSxGteSJPYg==", + "cpu": [ + "arm" + ], + "dev": true, + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/android-arm64": { + "version": "0.17.15", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.17.15.tgz", + "integrity": "sha512-0kOB6Y7Br3KDVgHeg8PRcvfLkq+AccreK///B4Z6fNZGr/tNHX0z2VywCc7PTeWp+bPvjA5WMvNXltHw5QjAIA==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/android-x64": { + "version": "0.17.15", + "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.17.15.tgz", + "integrity": "sha512-MzDqnNajQZ63YkaUWVl9uuhcWyEyh69HGpMIrf+acR4otMkfLJ4sUCxqwbCyPGicE9dVlrysI3lMcDBjGiBBcQ==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/darwin-arm64": { + "version": "0.17.15", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.17.15.tgz", + "integrity": "sha512-7siLjBc88Z4+6qkMDxPT2juf2e8SJxmsbNVKFY2ifWCDT72v5YJz9arlvBw5oB4W/e61H1+HDB/jnu8nNg0rLA==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/darwin-x64": { + "version": "0.17.15", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.17.15.tgz", + "integrity": "sha512-NbImBas2rXwYI52BOKTW342Tm3LTeVlaOQ4QPZ7XuWNKiO226DisFk/RyPk3T0CKZkKMuU69yOvlapJEmax7cg==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/freebsd-arm64": { + "version": "0.17.15", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.17.15.tgz", + "integrity": "sha512-Xk9xMDjBVG6CfgoqlVczHAdJnCs0/oeFOspFap5NkYAmRCT2qTn1vJWA2f419iMtsHSLm+O8B6SLV/HlY5cYKg==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/freebsd-x64": { + "version": "0.17.15", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.17.15.tgz", + "integrity": "sha512-3TWAnnEOdclvb2pnfsTWtdwthPfOz7qAfcwDLcfZyGJwm1SRZIMOeB5FODVhnM93mFSPsHB9b/PmxNNbSnd0RQ==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-arm": { + "version": "0.17.15", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.17.15.tgz", + "integrity": "sha512-MLTgiXWEMAMr8nmS9Gigx43zPRmEfeBfGCwxFQEMgJ5MC53QKajaclW6XDPjwJvhbebv+RzK05TQjvH3/aM4Xw==", + "cpu": [ + "arm" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-arm64": { + "version": "0.17.15", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.17.15.tgz", + "integrity": "sha512-T0MVnYw9KT6b83/SqyznTs/3Jg2ODWrZfNccg11XjDehIved2oQfrX/wVuev9N936BpMRaTR9I1J0tdGgUgpJA==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-ia32": { + "version": "0.17.15", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.17.15.tgz", + "integrity": "sha512-wp02sHs015T23zsQtU4Cj57WiteiuASHlD7rXjKUyAGYzlOKDAjqK6bk5dMi2QEl/KVOcsjwL36kD+WW7vJt8Q==", + "cpu": [ + "ia32" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-loong64": { + "version": "0.17.15", + "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.17.15.tgz", + "integrity": "sha512-k7FsUJjGGSxwnBmMh8d7IbObWu+sF/qbwc+xKZkBe/lTAF16RqxRCnNHA7QTd3oS2AfGBAnHlXL67shV5bBThQ==", + "cpu": [ + "loong64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-mips64el": { + "version": "0.17.15", + "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.17.15.tgz", + "integrity": "sha512-ZLWk6czDdog+Q9kE/Jfbilu24vEe/iW/Sj2d8EVsmiixQ1rM2RKH2n36qfxK4e8tVcaXkvuV3mU5zTZviE+NVQ==", + "cpu": [ + "mips64el" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-ppc64": { + "version": "0.17.15", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.17.15.tgz", + "integrity": "sha512-mY6dPkIRAiFHRsGfOYZC8Q9rmr8vOBZBme0/j15zFUKM99d4ILY4WpOC7i/LqoY+RE7KaMaSfvY8CqjJtuO4xg==", + "cpu": [ + "ppc64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-riscv64": { + "version": "0.17.15", + "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.17.15.tgz", + "integrity": "sha512-EcyUtxffdDtWjjwIH8sKzpDRLcVtqANooMNASO59y+xmqqRYBBM7xVLQhqF7nksIbm2yHABptoioS9RAbVMWVA==", + "cpu": [ + "riscv64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-s390x": { + "version": "0.17.15", + "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.17.15.tgz", + "integrity": "sha512-BuS6Jx/ezxFuHxgsfvz7T4g4YlVrmCmg7UAwboeyNNg0OzNzKsIZXpr3Sb/ZREDXWgt48RO4UQRDBxJN3B9Rbg==", + "cpu": [ + "s390x" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-x64": { + "version": "0.17.15", + "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.17.15.tgz", + "integrity": "sha512-JsdS0EgEViwuKsw5tiJQo9UdQdUJYuB+Mf6HxtJSPN35vez1hlrNb1KajvKWF5Sa35j17+rW1ECEO9iNrIXbNg==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/netbsd-x64": { + "version": "0.17.15", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.17.15.tgz", + "integrity": "sha512-R6fKjtUysYGym6uXf6qyNephVUQAGtf3n2RCsOST/neIwPqRWcnc3ogcielOd6pT+J0RDR1RGcy0ZY7d3uHVLA==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "netbsd" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/openbsd-x64": { + "version": "0.17.15", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.17.15.tgz", + "integrity": "sha512-mVD4PGc26b8PI60QaPUltYKeSX0wxuy0AltC+WCTFwvKCq2+OgLP4+fFd+hZXzO2xW1HPKcytZBdjqL6FQFa7w==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/sunos-x64": { + "version": "0.17.15", + "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.17.15.tgz", + "integrity": "sha512-U6tYPovOkw3459t2CBwGcFYfFRjivcJJc1WC8Q3funIwX8x4fP+R6xL/QuTPNGOblbq/EUDxj9GU+dWKX0oWlQ==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "sunos" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/win32-arm64": { + "version": "0.17.15", + "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.17.15.tgz", + "integrity": "sha512-W+Z5F++wgKAleDABemiyXVnzXgvRFs+GVKThSI+mGgleLWluv0D7Diz4oQpgdpNzh4i2nNDzQtWbjJiqutRp6Q==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/win32-ia32": { + "version": "0.17.15", + "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.17.15.tgz", + "integrity": "sha512-Muz/+uGgheShKGqSVS1KsHtCyEzcdOn/W/Xbh6H91Etm+wiIfwZaBn1W58MeGtfI8WA961YMHFYTthBdQs4t+w==", + "cpu": [ + "ia32" + ], + "dev": true, + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/win32-x64": { + "version": "0.17.15", + "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.17.15.tgz", + "integrity": "sha512-DjDa9ywLUUmjhV2Y9wUTIF+1XsmuFGvZoCmOWkli1XcNAh5t25cc7fgsCx4Zi/Uurep3TTLyDiKATgGEg61pkA==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=12" + } + }, "node_modules/@jridgewell/resolve-uri": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.0.tgz", @@ -74,6 +427,41 @@ "@jridgewell/sourcemap-codec": "^1.4.10" } }, + "node_modules/@nodelib/fs.scandir": { + "version": "2.1.5", + "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz", + "integrity": "sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g==", + "dev": true, + "dependencies": { + "@nodelib/fs.stat": "2.0.5", + "run-parallel": "^1.1.9" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/@nodelib/fs.stat": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/@nodelib/fs.stat/-/fs.stat-2.0.5.tgz", + "integrity": "sha512-RkhPPp2zrqDAQA/2jNhnztcPAlv64XdhIp7a7454A5ovI7Bukxgt7MX7udwAu3zg1DcpPU0rz3VV1SeaqvY4+A==", + "dev": true, + "engines": { + "node": ">= 8" + } + }, + "node_modules/@nodelib/fs.walk": { + "version": "1.2.8", + "resolved": "https://registry.npmjs.org/@nodelib/fs.walk/-/fs.walk-1.2.8.tgz", + "integrity": "sha512-oGB+UxlgWcgQkgwo8GcEGwemoTFt3FIO9ababBmaGwXIoBKZ+GTy0pP185beGg7Llih/NSHSV2XAs1lnznocSg==", + "dev": true, + "dependencies": { + "@nodelib/fs.scandir": "2.1.5", + "fastq": "^1.6.0" + }, + "engines": { + "node": ">= 8" + } + }, "node_modules/@sinonjs/commons": { "version": "1.8.3", "resolved": "https://registry.npmjs.org/@sinonjs/commons/-/commons-1.8.3.tgz", @@ -257,6 +645,12 @@ "url": "https://github.com/chalk/ansi-styles?sponsor=1" } }, + "node_modules/any-promise": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/any-promise/-/any-promise-1.3.0.tgz", + "integrity": "sha512-7UvmKalWRt1wgjL1RrGxoSJW/0QZFIegpeGvZG9kjp8vrRu55XTHbwnqq2GpXm9uLbcuhxm3IqX9OB4MZR1b2A==", + "dev": true + }, "node_modules/anymatch": { "version": "3.1.2", "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.2.tgz", @@ -282,6 +676,15 @@ "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==", "dev": true }, + "node_modules/array-union": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/array-union/-/array-union-2.1.0.tgz", + "integrity": "sha512-HGyxoOTYUyCM6stUe6EJgnd4EoewAI7zMdfqO+kGjnlZmBDz/cR5pf8r/cR4Wq60sL/p0IkcjUEEPwS3GFrIyw==", + "dev": true, + "engines": { + "node": ">=8" + } + }, "node_modules/assertion-error": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-1.1.0.tgz", @@ -355,6 +758,30 @@ "node": ">=6.14.2" } }, + "node_modules/bundle-require": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/bundle-require/-/bundle-require-4.0.1.tgz", + "integrity": "sha512-9NQkRHlNdNpDBGmLpngF3EFDcwodhMUuLz9PaWYciVcQF9SE4LFjM2DB/xV1Li5JiuDMv7ZUWuC3rGbqR0MAXQ==", + "dev": true, + "dependencies": { + "load-tsconfig": "^0.2.3" + }, + "engines": { + "node": "^12.20.0 || ^14.13.1 || >=16.0.0" + }, + "peerDependencies": { + "esbuild": ">=0.17" + } + }, + "node_modules/cac": { + "version": "6.7.14", + "resolved": "https://registry.npmjs.org/cac/-/cac-6.7.14.tgz", + "integrity": "sha512-b6Ilus+c3RrdDk+JhLKUAQfzzgLEPy6wcXqS7f/xe1EETvsDP6GORG7SFuOs6cID5YkqchW/LXZbX5bc8j7ZcQ==", + "dev": true, + "engines": { + "node": ">=8" + } + }, "node_modules/camelcase": { "version": "6.2.1", "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-6.2.1.tgz", @@ -618,6 +1045,18 @@ "node": ">=0.3.1" } }, + "node_modules/dir-glob": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/dir-glob/-/dir-glob-3.0.1.tgz", + "integrity": "sha512-WkrWp9GR4KXfKGYzOLmTuGVi1UWFfws377n9cc55/tb6DuqyF6pcQ5AbiHEshaDpY9v6oaSr2XCDidGmMwdzIA==", + "dev": true, + "dependencies": { + "path-type": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, "node_modules/emoji-regex": { "version": "8.0.0", "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", @@ -665,6 +1104,43 @@ "ext": "^1.1.2" } }, + "node_modules/esbuild": { + "version": "0.17.15", + "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.17.15.tgz", + "integrity": "sha512-LBUV2VsUIc/iD9ME75qhT4aJj0r75abCVS0jakhFzOtR7TQsqQA5w0tZ+KTKnwl3kXE0MhskNdHDh/I5aCR1Zw==", + "dev": true, + "hasInstallScript": true, + "bin": { + "esbuild": "bin/esbuild" + }, + "engines": { + "node": ">=12" + }, + "optionalDependencies": { + "@esbuild/android-arm": "0.17.15", + "@esbuild/android-arm64": "0.17.15", + "@esbuild/android-x64": "0.17.15", + "@esbuild/darwin-arm64": "0.17.15", + "@esbuild/darwin-x64": "0.17.15", + "@esbuild/freebsd-arm64": "0.17.15", + "@esbuild/freebsd-x64": "0.17.15", + "@esbuild/linux-arm": "0.17.15", + "@esbuild/linux-arm64": "0.17.15", + "@esbuild/linux-ia32": "0.17.15", + "@esbuild/linux-loong64": "0.17.15", + "@esbuild/linux-mips64el": "0.17.15", + "@esbuild/linux-ppc64": "0.17.15", + "@esbuild/linux-riscv64": "0.17.15", + "@esbuild/linux-s390x": "0.17.15", + "@esbuild/linux-x64": "0.17.15", + "@esbuild/netbsd-x64": "0.17.15", + "@esbuild/openbsd-x64": "0.17.15", + "@esbuild/sunos-x64": "0.17.15", + "@esbuild/win32-arm64": "0.17.15", + "@esbuild/win32-ia32": "0.17.15", + "@esbuild/win32-x64": "0.17.15" + } + }, "node_modules/escalade": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.1.1.tgz", @@ -722,6 +1198,31 @@ "resolved": "https://registry.npmjs.org/type/-/type-2.5.0.tgz", "integrity": "sha512-180WMDQaIMm3+7hGXWf12GtdniDEy7nYcyFMKJn/eZz/6tSLXrUN9V0wKSbMjej0I1WHWbpREDEKHtqPQa9NNw==" }, + "node_modules/fast-glob": { + "version": "3.2.12", + "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.2.12.tgz", + "integrity": "sha512-DVj4CQIYYow0BlaelwK1pHl5n5cRSJfM60UA0zK891sVInoPri2Ekj7+e1CT3/3qxXenpI+nBBmQAcJPJgaj4w==", + "dev": true, + "dependencies": { + "@nodelib/fs.stat": "^2.0.2", + "@nodelib/fs.walk": "^1.2.3", + "glob-parent": "^5.1.2", + "merge2": "^1.3.0", + "micromatch": "^4.0.4" + }, + "engines": { + "node": ">=8.6.0" + } + }, + "node_modules/fastq": { + "version": "1.15.0", + "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.15.0.tgz", + "integrity": "sha512-wBrocU2LCXXa+lWBt8RoIRD89Fi8OdABODa/kEnyeyjS5aZO5/GNvI5sEINADqP/h8M29UHTHUb53sUu5Ihqdw==", + "dev": true, + "dependencies": { + "reusify": "^1.0.4" + } + }, "node_modules/fill-range": { "version": "7.0.1", "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", @@ -849,6 +1350,26 @@ "node": ">= 6" } }, + "node_modules/globby": { + "version": "11.1.0", + "resolved": "https://registry.npmjs.org/globby/-/globby-11.1.0.tgz", + "integrity": "sha512-jhIXaOzy1sb8IyocaruWSn1TjmnBVs8Ayhcy83rmxNJ8q2uWKCAj3CnJY+KpGSXCueAPc0i05kVvVKtP1t9S3g==", + "dev": true, + "dependencies": { + "array-union": "^2.1.0", + "dir-glob": "^3.0.1", + "fast-glob": "^3.2.9", + "ignore": "^5.2.0", + "merge2": "^1.4.1", + "slash": "^3.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/growl": { "version": "1.10.5", "resolved": "https://registry.npmjs.org/growl/-/growl-1.10.5.tgz", @@ -900,6 +1421,15 @@ "url": "https://github.com/sponsors/typicode" } }, + "node_modules/ignore": { + "version": "5.2.4", + "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.2.4.tgz", + "integrity": "sha512-MAb38BcSbH0eHNBxn7ql2NH/kX33OkB3lZ1BNdh7ENeRChHTYsTvWrMubiIAMNS2llXEEgZ1MUOBtXChP3kaFQ==", + "dev": true, + "engines": { + "node": ">= 4" + } + }, "node_modules/indent-string": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/indent-string/-/indent-string-4.0.0.tgz", @@ -1026,6 +1556,15 @@ "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=", "dev": true }, + "node_modules/joycon": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/joycon/-/joycon-3.1.1.tgz", + "integrity": "sha512-34wB/Y7MW7bzjKRjUKTa46I2Z7eV62Rkhva+KkopW7Qvv/OSWBqvkSY7vusOPrNuZcUG3tApvdVgNB8POj3SPw==", + "dev": true, + "engines": { + "node": ">=10" + } + }, "node_modules/js-yaml": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz", @@ -1059,6 +1598,12 @@ "node": ">=10" } }, + "node_modules/lines-and-columns": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/lines-and-columns/-/lines-and-columns-1.2.4.tgz", + "integrity": "sha512-7ylylesZQ/PV29jhEDl3Ufjo6ZX7gCqJr5F7PKrqc93v7fzSymt1BpwEU8nAUXs8qzzvqhbjhK5QZg6Mt/HkBg==", + "dev": true + }, "node_modules/lint-staged": { "version": "12.1.2", "resolved": "https://registry.npmjs.org/lint-staged/-/lint-staged-12.1.2.tgz", @@ -1235,6 +1780,15 @@ } } }, + "node_modules/load-tsconfig": { + "version": "0.2.5", + "resolved": "https://registry.npmjs.org/load-tsconfig/-/load-tsconfig-0.2.5.tgz", + "integrity": "sha512-IXO6OCs9yg8tMKzfPZ1YmheJbZCiEsnBdcB03l0OcfK9prKnJb96siuHCr5Fl37/yo9DnKU+TLpxzTUspw9shg==", + "dev": true, + "engines": { + "node": "^12.20.0 || ^14.13.1 || >=16.0.0" + } + }, "node_modules/locate-path": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz", @@ -1256,6 +1810,12 @@ "integrity": "sha1-LRd/ZS+jHpObRDjVNBSZ36OCXpk=", "dev": true }, + "node_modules/lodash.sortby": { + "version": "4.7.0", + "resolved": "https://registry.npmjs.org/lodash.sortby/-/lodash.sortby-4.7.0.tgz", + "integrity": "sha512-HDWXG8isMntAyRF5vZ7xKuEvOhT4AhlRt/3czTSjvGUxjYCBVRQY48ViDHyfYz9VIoBkW4TMGQNapx+l3RUwdA==", + "dev": true + }, "node_modules/log-symbols": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-4.1.0.tgz", @@ -1351,6 +1911,15 @@ "integrity": "sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w==", "dev": true }, + "node_modules/merge2": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/merge2/-/merge2-1.4.1.tgz", + "integrity": "sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg==", + "dev": true, + "engines": { + "node": ">= 8" + } + }, "node_modules/micromatch": { "version": "4.0.4", "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.4.tgz", @@ -1467,6 +2036,17 @@ "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", "dev": true }, + "node_modules/mz": { + "version": "2.7.0", + "resolved": "https://registry.npmjs.org/mz/-/mz-2.7.0.tgz", + "integrity": "sha512-z81GNO7nnYMEhrGh9LeymoE4+Yr0Wn5McHIZMK5cfQCl+NDX08sCZgUc9/6MHni9IWuFLm1Z3HTCXu2z9fN62Q==", + "dev": true, + "dependencies": { + "any-promise": "^1.0.0", + "object-assign": "^4.0.1", + "thenify-all": "^1.0.0" + } + }, "node_modules/nanoid": { "version": "3.3.1", "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.1.tgz", @@ -1547,6 +2127,15 @@ "node": ">=8" } }, + "node_modules/object-assign": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", + "integrity": "sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/object-inspect": { "version": "1.11.1", "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.11.1.tgz", @@ -1661,6 +2250,15 @@ "isarray": "0.0.1" } }, + "node_modules/path-type": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/path-type/-/path-type-4.0.0.tgz", + "integrity": "sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==", + "dev": true, + "engines": { + "node": ">=8" + } + }, "node_modules/pathval": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/pathval/-/pathval-1.1.1.tgz", @@ -1682,6 +2280,53 @@ "url": "https://github.com/sponsors/jonschlinkert" } }, + "node_modules/pirates": { + "version": "4.0.5", + "resolved": "https://registry.npmjs.org/pirates/-/pirates-4.0.5.tgz", + "integrity": "sha512-8V9+HQPupnaXMA23c5hvl69zXvTwTzyAYasnkb0Tts4XvO4CliqONMOnvlq26rkhLC3nWDFBJf73LU1e1VZLaQ==", + "dev": true, + "engines": { + "node": ">= 6" + } + }, + "node_modules/postcss-load-config": { + "version": "3.1.4", + "resolved": "https://registry.npmjs.org/postcss-load-config/-/postcss-load-config-3.1.4.tgz", + "integrity": "sha512-6DiM4E7v4coTE4uzA8U//WhtPwyhiim3eyjEMFCnUpzbrkK9wJHgKDT2mR+HbtSrd/NubVaYTOpSpjUl8NQeRg==", + "dev": true, + "dependencies": { + "lilconfig": "^2.0.5", + "yaml": "^1.10.2" + }, + "engines": { + "node": ">= 10" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/postcss/" + }, + "peerDependencies": { + "postcss": ">=8.0.9", + "ts-node": ">=9.0.0" + }, + "peerDependenciesMeta": { + "postcss": { + "optional": true + }, + "ts-node": { + "optional": true + } + } + }, + "node_modules/postcss-load-config/node_modules/lilconfig": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/lilconfig/-/lilconfig-2.1.0.tgz", + "integrity": "sha512-utWOt/GHzuUxnLKxB6dk81RoOeoNeHgbrXiuGk4yyF5qlRz+iIVWu56E2fqGHFrXz0QNUhLB/8nKqvRH66JKGQ==", + "dev": true, + "engines": { + "node": ">=10" + } + }, "node_modules/prettier": { "version": "2.5.1", "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.5.1.tgz", @@ -1694,6 +2339,15 @@ "node": ">=10.13.0" } }, + "node_modules/punycode": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.0.tgz", + "integrity": "sha512-rRV+zQD8tVFys26lAGR9WUuS4iUAngJScM+ZRSKtvl5tKeZ2t5bvdNFdNHBW9FWR4guGHlgmsZ1G7BSm2wTbuA==", + "dev": true, + "engines": { + "node": ">=6" + } + }, "node_modules/query-string": { "version": "7.0.1", "resolved": "https://registry.npmjs.org/query-string/-/query-string-7.0.1.tgz", @@ -1711,6 +2365,26 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/queue-microtask": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/queue-microtask/-/queue-microtask-1.2.3.tgz", + "integrity": "sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ] + }, "node_modules/randombytes": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.1.0.tgz", @@ -1741,6 +2415,15 @@ "node": ">=0.10.0" } }, + "node_modules/resolve-from": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-5.0.0.tgz", + "integrity": "sha512-qYg9KP24dD5qka9J47d0aVky0N+b4fTU89LN9iDnjB5waksiC49rvMB0PrUJQGoTmH50XPiqOvAjDfaijGxYZw==", + "dev": true, + "engines": { + "node": ">=8" + } + }, "node_modules/restore-cursor": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/restore-cursor/-/restore-cursor-3.1.0.tgz", @@ -1754,12 +2437,61 @@ "node": ">=8" } }, + "node_modules/reusify": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/reusify/-/reusify-1.0.4.tgz", + "integrity": "sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw==", + "dev": true, + "engines": { + "iojs": ">=1.0.0", + "node": ">=0.10.0" + } + }, "node_modules/rfdc": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/rfdc/-/rfdc-1.3.0.tgz", "integrity": "sha512-V2hovdzFbOi77/WajaSMXk2OLm+xNIeQdMMuB7icj7bk6zi2F8GGAxigcnDFpJHbNyNcgyJDiP+8nOrY5cZGrA==", "dev": true }, + "node_modules/rollup": { + "version": "3.20.2", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-3.20.2.tgz", + "integrity": "sha512-3zwkBQl7Ai7MFYQE0y1MeQ15+9jsi7XxfrqwTb/9EK8D9C9+//EBR4M+CuA1KODRaNbFez/lWxA5vhEGZp4MUg==", + "dev": true, + "bin": { + "rollup": "dist/bin/rollup" + }, + "engines": { + "node": ">=14.18.0", + "npm": ">=8.0.0" + }, + "optionalDependencies": { + "fsevents": "~2.3.2" + } + }, + "node_modules/run-parallel": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/run-parallel/-/run-parallel-1.2.0.tgz", + "integrity": "sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "dependencies": { + "queue-microtask": "^1.2.2" + } + }, "node_modules/rxjs": { "version": "7.4.0", "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-7.4.0.tgz", @@ -1863,6 +2595,15 @@ "@sinonjs/commons": "^1.7.0" } }, + "node_modules/slash": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/slash/-/slash-3.0.0.tgz", + "integrity": "sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==", + "dev": true, + "engines": { + "node": ">=8" + } + }, "node_modules/slice-ansi": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/slice-ansi/-/slice-ansi-3.0.0.tgz", @@ -1877,6 +2618,44 @@ "node": ">=8" } }, + "node_modules/source-map": { + "version": "0.8.0-beta.0", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.8.0-beta.0.tgz", + "integrity": "sha512-2ymg6oRBpebeZi9UUNsgQ89bhx01TcTkmNTGnNO88imTmbSgy4nfujrgVEFKWpMTEGA11EDkTt7mqObTPdigIA==", + "dev": true, + "dependencies": { + "whatwg-url": "^7.0.0" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/source-map/node_modules/tr46": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/tr46/-/tr46-1.0.1.tgz", + "integrity": "sha512-dTpowEjclQ7Kgx5SdBkqRzVhERQXov8/l9Ft9dVM9fmg0W0KQSVaXX9T4i6twCPNtYiZM53lpSSUAwJbFPOHxA==", + "dev": true, + "dependencies": { + "punycode": "^2.1.0" + } + }, + "node_modules/source-map/node_modules/webidl-conversions": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-4.0.2.tgz", + "integrity": "sha512-YQ+BmxuTgd6UXZW3+ICGfyqRyHXVlD5GtQr5+qjiNW7bF0cqrzX500HVXPBOvgXb5YnzDd+h0zqyv61KUD7+Sg==", + "dev": true + }, + "node_modules/source-map/node_modules/whatwg-url": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-7.1.0.tgz", + "integrity": "sha512-WUu7Rg1DroM7oQvGWfOiAK21n74Gg+T4elXEQYkOhtyLeWiJFoOGLXPKI/9gzIie9CtwVLm8wtw6YJdKyxSjeg==", + "dev": true, + "dependencies": { + "lodash.sortby": "^4.7.0", + "tr46": "^1.0.1", + "webidl-conversions": "^4.0.2" + } + }, "node_modules/split-on-first": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/split-on-first/-/split-on-first-1.1.0.tgz", @@ -1946,7 +2725,57 @@ "node": ">=8" }, "funding": { - "url": "https://github.com/sponsors/sindresorhus" + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/sucrase": { + "version": "3.31.0", + "resolved": "https://registry.npmjs.org/sucrase/-/sucrase-3.31.0.tgz", + "integrity": "sha512-6QsHnkqyVEzYcaiHsOKkzOtOgdJcb8i54x6AV2hDwyZcY9ZyykGZVw6L/YN98xC0evwTP6utsWWrKRaa8QlfEQ==", + "dev": true, + "dependencies": { + "commander": "^4.0.0", + "glob": "7.1.6", + "lines-and-columns": "^1.1.6", + "mz": "^2.7.0", + "pirates": "^4.0.1", + "ts-interface-checker": "^0.1.9" + }, + "bin": { + "sucrase": "bin/sucrase", + "sucrase-node": "bin/sucrase-node" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/sucrase/node_modules/commander": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/commander/-/commander-4.1.1.tgz", + "integrity": "sha512-NOKm8xhkzAjzFx8B2v5OAHT+u5pRQc2UCa2Vq9jYL/31o2wi9mxBA7LIFs3sV5VSC49z6pEhfbMULvShKj26WA==", + "dev": true, + "engines": { + "node": ">= 6" + } + }, + "node_modules/sucrase/node_modules/glob": { + "version": "7.1.6", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.6.tgz", + "integrity": "sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA==", + "dev": true, + "dependencies": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + }, + "engines": { + "node": "*" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" } }, "node_modules/supports-color": { @@ -1961,6 +2790,27 @@ "node": ">=8" } }, + "node_modules/thenify": { + "version": "3.3.1", + "resolved": "https://registry.npmjs.org/thenify/-/thenify-3.3.1.tgz", + "integrity": "sha512-RVZSIV5IG10Hk3enotrhvz0T9em6cyHBLkH/YAZuKqd8hRkKhSfCGIcP2KUY0EPxndzANBmNllzWPwak+bheSw==", + "dev": true, + "dependencies": { + "any-promise": "^1.0.0" + } + }, + "node_modules/thenify-all": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/thenify-all/-/thenify-all-1.6.0.tgz", + "integrity": "sha512-RNxQH/qI8/t3thXJDwcstUO4zeqo64+Uy/+sNVRBx4Xn2OX+OZ9oP+iJnNFqplFra2ZUVeKCSa2oVWi3T4uVmA==", + "dev": true, + "dependencies": { + "thenify": ">= 3.1.0 < 4" + }, + "engines": { + "node": ">=0.8" + } + }, "node_modules/through": { "version": "2.3.8", "resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz", @@ -1984,6 +2834,21 @@ "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", "integrity": "sha1-gYT9NH2snNwYWZLzpmIuFLnZq2o=" }, + "node_modules/tree-kill": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/tree-kill/-/tree-kill-1.2.2.tgz", + "integrity": "sha512-L0Orpi8qGpRG//Nd+H90vFB+3iHnue1zSSGmNOOCh1GLJ7rUKVwV2HvijphGQS2UmhUZewS9VgvxYIdgr+fG1A==", + "dev": true, + "bin": { + "tree-kill": "cli.js" + } + }, + "node_modules/ts-interface-checker": { + "version": "0.1.13", + "resolved": "https://registry.npmjs.org/ts-interface-checker/-/ts-interface-checker-0.1.13.tgz", + "integrity": "sha512-Y/arvbn+rrz3JCKl9C4kVNfTfSm2/mEp5FSz5EsZSANGPSlQrpRI5M4PKF+mJnE52jOO90PnPSc3Ur3bTQw0gA==", + "dev": true + }, "node_modules/ts-node": { "version": "10.9.1", "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.9.1.tgz", @@ -2042,6 +2907,51 @@ "integrity": "sha512-hcVC3wYEziELGGmEEXue7D75zbwIIVUMWAVbHItGPx0ziyXxrOMQx4rQEVEV45Ut/1IotuEvwqPopzIOkDMf0A==", "dev": true }, + "node_modules/tsup": { + "version": "6.7.0", + "resolved": "https://registry.npmjs.org/tsup/-/tsup-6.7.0.tgz", + "integrity": "sha512-L3o8hGkaHnu5TdJns+mCqFsDBo83bJ44rlK7e6VdanIvpea4ArPcU3swWGsLVbXak1PqQx/V+SSmFPujBK+zEQ==", + "dev": true, + "dependencies": { + "bundle-require": "^4.0.0", + "cac": "^6.7.12", + "chokidar": "^3.5.1", + "debug": "^4.3.1", + "esbuild": "^0.17.6", + "execa": "^5.0.0", + "globby": "^11.0.3", + "joycon": "^3.0.1", + "postcss-load-config": "^3.0.1", + "resolve-from": "^5.0.0", + "rollup": "^3.2.5", + "source-map": "0.8.0-beta.0", + "sucrase": "^3.20.3", + "tree-kill": "^1.2.2" + }, + "bin": { + "tsup": "dist/cli-default.js", + "tsup-node": "dist/cli-node.js" + }, + "engines": { + "node": ">=14.18" + }, + "peerDependencies": { + "@swc/core": "^1", + "postcss": "^8.4.12", + "typescript": ">=4.1.0" + }, + "peerDependenciesMeta": { + "@swc/core": { + "optional": true + }, + "postcss": { + "optional": true + }, + "typescript": { + "optional": true + } + } + }, "node_modules/type": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/type/-/type-1.2.0.tgz", @@ -2338,6 +3248,160 @@ "@jridgewell/trace-mapping": "0.3.9" } }, + "@esbuild/android-arm": { + "version": "0.17.15", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.17.15.tgz", + "integrity": "sha512-sRSOVlLawAktpMvDyJIkdLI/c/kdRTOqo8t6ImVxg8yT7LQDUYV5Rp2FKeEosLr6ZCja9UjYAzyRSxGteSJPYg==", + "dev": true, + "optional": true + }, + "@esbuild/android-arm64": { + "version": "0.17.15", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.17.15.tgz", + "integrity": "sha512-0kOB6Y7Br3KDVgHeg8PRcvfLkq+AccreK///B4Z6fNZGr/tNHX0z2VywCc7PTeWp+bPvjA5WMvNXltHw5QjAIA==", + "dev": true, + "optional": true + }, + "@esbuild/android-x64": { + "version": "0.17.15", + "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.17.15.tgz", + "integrity": "sha512-MzDqnNajQZ63YkaUWVl9uuhcWyEyh69HGpMIrf+acR4otMkfLJ4sUCxqwbCyPGicE9dVlrysI3lMcDBjGiBBcQ==", + "dev": true, + "optional": true + }, + "@esbuild/darwin-arm64": { + "version": "0.17.15", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.17.15.tgz", + "integrity": "sha512-7siLjBc88Z4+6qkMDxPT2juf2e8SJxmsbNVKFY2ifWCDT72v5YJz9arlvBw5oB4W/e61H1+HDB/jnu8nNg0rLA==", + "dev": true, + "optional": true + }, + "@esbuild/darwin-x64": { + "version": "0.17.15", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.17.15.tgz", + "integrity": "sha512-NbImBas2rXwYI52BOKTW342Tm3LTeVlaOQ4QPZ7XuWNKiO226DisFk/RyPk3T0CKZkKMuU69yOvlapJEmax7cg==", + "dev": true, + "optional": true + }, + "@esbuild/freebsd-arm64": { + "version": "0.17.15", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.17.15.tgz", + "integrity": "sha512-Xk9xMDjBVG6CfgoqlVczHAdJnCs0/oeFOspFap5NkYAmRCT2qTn1vJWA2f419iMtsHSLm+O8B6SLV/HlY5cYKg==", + "dev": true, + "optional": true + }, + "@esbuild/freebsd-x64": { + "version": "0.17.15", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.17.15.tgz", + "integrity": "sha512-3TWAnnEOdclvb2pnfsTWtdwthPfOz7qAfcwDLcfZyGJwm1SRZIMOeB5FODVhnM93mFSPsHB9b/PmxNNbSnd0RQ==", + "dev": true, + "optional": true + }, + "@esbuild/linux-arm": { + "version": "0.17.15", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.17.15.tgz", + "integrity": "sha512-MLTgiXWEMAMr8nmS9Gigx43zPRmEfeBfGCwxFQEMgJ5MC53QKajaclW6XDPjwJvhbebv+RzK05TQjvH3/aM4Xw==", + "dev": true, + "optional": true + }, + "@esbuild/linux-arm64": { + "version": "0.17.15", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.17.15.tgz", + "integrity": "sha512-T0MVnYw9KT6b83/SqyznTs/3Jg2ODWrZfNccg11XjDehIved2oQfrX/wVuev9N936BpMRaTR9I1J0tdGgUgpJA==", + "dev": true, + "optional": true + }, + "@esbuild/linux-ia32": { + "version": "0.17.15", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.17.15.tgz", + "integrity": "sha512-wp02sHs015T23zsQtU4Cj57WiteiuASHlD7rXjKUyAGYzlOKDAjqK6bk5dMi2QEl/KVOcsjwL36kD+WW7vJt8Q==", + "dev": true, + "optional": true + }, + "@esbuild/linux-loong64": { + "version": "0.17.15", + "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.17.15.tgz", + "integrity": "sha512-k7FsUJjGGSxwnBmMh8d7IbObWu+sF/qbwc+xKZkBe/lTAF16RqxRCnNHA7QTd3oS2AfGBAnHlXL67shV5bBThQ==", + "dev": true, + "optional": true + }, + "@esbuild/linux-mips64el": { + "version": "0.17.15", + "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.17.15.tgz", + "integrity": "sha512-ZLWk6czDdog+Q9kE/Jfbilu24vEe/iW/Sj2d8EVsmiixQ1rM2RKH2n36qfxK4e8tVcaXkvuV3mU5zTZviE+NVQ==", + "dev": true, + "optional": true + }, + "@esbuild/linux-ppc64": { + "version": "0.17.15", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.17.15.tgz", + "integrity": "sha512-mY6dPkIRAiFHRsGfOYZC8Q9rmr8vOBZBme0/j15zFUKM99d4ILY4WpOC7i/LqoY+RE7KaMaSfvY8CqjJtuO4xg==", + "dev": true, + "optional": true + }, + "@esbuild/linux-riscv64": { + "version": "0.17.15", + "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.17.15.tgz", + "integrity": "sha512-EcyUtxffdDtWjjwIH8sKzpDRLcVtqANooMNASO59y+xmqqRYBBM7xVLQhqF7nksIbm2yHABptoioS9RAbVMWVA==", + "dev": true, + "optional": true + }, + "@esbuild/linux-s390x": { + "version": "0.17.15", + "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.17.15.tgz", + "integrity": "sha512-BuS6Jx/ezxFuHxgsfvz7T4g4YlVrmCmg7UAwboeyNNg0OzNzKsIZXpr3Sb/ZREDXWgt48RO4UQRDBxJN3B9Rbg==", + "dev": true, + "optional": true + }, + "@esbuild/linux-x64": { + "version": "0.17.15", + "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.17.15.tgz", + "integrity": "sha512-JsdS0EgEViwuKsw5tiJQo9UdQdUJYuB+Mf6HxtJSPN35vez1hlrNb1KajvKWF5Sa35j17+rW1ECEO9iNrIXbNg==", + "dev": true, + "optional": true + }, + "@esbuild/netbsd-x64": { + "version": "0.17.15", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.17.15.tgz", + "integrity": "sha512-R6fKjtUysYGym6uXf6qyNephVUQAGtf3n2RCsOST/neIwPqRWcnc3ogcielOd6pT+J0RDR1RGcy0ZY7d3uHVLA==", + "dev": true, + "optional": true + }, + "@esbuild/openbsd-x64": { + "version": "0.17.15", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.17.15.tgz", + "integrity": "sha512-mVD4PGc26b8PI60QaPUltYKeSX0wxuy0AltC+WCTFwvKCq2+OgLP4+fFd+hZXzO2xW1HPKcytZBdjqL6FQFa7w==", + "dev": true, + "optional": true + }, + "@esbuild/sunos-x64": { + "version": "0.17.15", + "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.17.15.tgz", + "integrity": "sha512-U6tYPovOkw3459t2CBwGcFYfFRjivcJJc1WC8Q3funIwX8x4fP+R6xL/QuTPNGOblbq/EUDxj9GU+dWKX0oWlQ==", + "dev": true, + "optional": true + }, + "@esbuild/win32-arm64": { + "version": "0.17.15", + "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.17.15.tgz", + "integrity": "sha512-W+Z5F++wgKAleDABemiyXVnzXgvRFs+GVKThSI+mGgleLWluv0D7Diz4oQpgdpNzh4i2nNDzQtWbjJiqutRp6Q==", + "dev": true, + "optional": true + }, + "@esbuild/win32-ia32": { + "version": "0.17.15", + "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.17.15.tgz", + "integrity": "sha512-Muz/+uGgheShKGqSVS1KsHtCyEzcdOn/W/Xbh6H91Etm+wiIfwZaBn1W58MeGtfI8WA961YMHFYTthBdQs4t+w==", + "dev": true, + "optional": true + }, + "@esbuild/win32-x64": { + "version": "0.17.15", + "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.17.15.tgz", + "integrity": "sha512-DjDa9ywLUUmjhV2Y9wUTIF+1XsmuFGvZoCmOWkli1XcNAh5t25cc7fgsCx4Zi/Uurep3TTLyDiKATgGEg61pkA==", + "dev": true, + "optional": true + }, "@jridgewell/resolve-uri": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.0.tgz", @@ -2360,6 +3424,32 @@ "@jridgewell/sourcemap-codec": "^1.4.10" } }, + "@nodelib/fs.scandir": { + "version": "2.1.5", + "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz", + "integrity": "sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g==", + "dev": true, + "requires": { + "@nodelib/fs.stat": "2.0.5", + "run-parallel": "^1.1.9" + } + }, + "@nodelib/fs.stat": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/@nodelib/fs.stat/-/fs.stat-2.0.5.tgz", + "integrity": "sha512-RkhPPp2zrqDAQA/2jNhnztcPAlv64XdhIp7a7454A5ovI7Bukxgt7MX7udwAu3zg1DcpPU0rz3VV1SeaqvY4+A==", + "dev": true + }, + "@nodelib/fs.walk": { + "version": "1.2.8", + "resolved": "https://registry.npmjs.org/@nodelib/fs.walk/-/fs.walk-1.2.8.tgz", + "integrity": "sha512-oGB+UxlgWcgQkgwo8GcEGwemoTFt3FIO9ababBmaGwXIoBKZ+GTy0pP185beGg7Llih/NSHSV2XAs1lnznocSg==", + "dev": true, + "requires": { + "@nodelib/fs.scandir": "2.1.5", + "fastq": "^1.6.0" + } + }, "@sinonjs/commons": { "version": "1.8.3", "resolved": "https://registry.npmjs.org/@sinonjs/commons/-/commons-1.8.3.tgz", @@ -2513,6 +3603,12 @@ "color-convert": "^2.0.1" } }, + "any-promise": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/any-promise/-/any-promise-1.3.0.tgz", + "integrity": "sha512-7UvmKalWRt1wgjL1RrGxoSJW/0QZFIegpeGvZG9kjp8vrRu55XTHbwnqq2GpXm9uLbcuhxm3IqX9OB4MZR1b2A==", + "dev": true + }, "anymatch": { "version": "3.1.2", "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.2.tgz", @@ -2535,6 +3631,12 @@ "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==", "dev": true }, + "array-union": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/array-union/-/array-union-2.1.0.tgz", + "integrity": "sha512-HGyxoOTYUyCM6stUe6EJgnd4EoewAI7zMdfqO+kGjnlZmBDz/cR5pf8r/cR4Wq60sL/p0IkcjUEEPwS3GFrIyw==", + "dev": true + }, "assertion-error": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-1.1.0.tgz", @@ -2592,6 +3694,21 @@ "node-gyp-build": "^4.3.0" } }, + "bundle-require": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/bundle-require/-/bundle-require-4.0.1.tgz", + "integrity": "sha512-9NQkRHlNdNpDBGmLpngF3EFDcwodhMUuLz9PaWYciVcQF9SE4LFjM2DB/xV1Li5JiuDMv7ZUWuC3rGbqR0MAXQ==", + "dev": true, + "requires": { + "load-tsconfig": "^0.2.3" + } + }, + "cac": { + "version": "6.7.14", + "resolved": "https://registry.npmjs.org/cac/-/cac-6.7.14.tgz", + "integrity": "sha512-b6Ilus+c3RrdDk+JhLKUAQfzzgLEPy6wcXqS7f/xe1EETvsDP6GORG7SFuOs6cID5YkqchW/LXZbX5bc8j7ZcQ==", + "dev": true + }, "camelcase": { "version": "6.2.1", "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-6.2.1.tgz", @@ -2782,6 +3899,15 @@ "integrity": "sha512-/VTCrvm5Z0JGty/BWHljh+BAiw3IK+2j87NGMu8Nwc/f48WoDAC395uomO9ZD117ZOBaHmkX1oyLvkVM/aIT3w==", "dev": true }, + "dir-glob": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/dir-glob/-/dir-glob-3.0.1.tgz", + "integrity": "sha512-WkrWp9GR4KXfKGYzOLmTuGVi1UWFfws377n9cc55/tb6DuqyF6pcQ5AbiHEshaDpY9v6oaSr2XCDidGmMwdzIA==", + "dev": true, + "requires": { + "path-type": "^4.0.0" + } + }, "emoji-regex": { "version": "8.0.0", "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", @@ -2826,6 +3952,36 @@ "ext": "^1.1.2" } }, + "esbuild": { + "version": "0.17.15", + "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.17.15.tgz", + "integrity": "sha512-LBUV2VsUIc/iD9ME75qhT4aJj0r75abCVS0jakhFzOtR7TQsqQA5w0tZ+KTKnwl3kXE0MhskNdHDh/I5aCR1Zw==", + "dev": true, + "requires": { + "@esbuild/android-arm": "0.17.15", + "@esbuild/android-arm64": "0.17.15", + "@esbuild/android-x64": "0.17.15", + "@esbuild/darwin-arm64": "0.17.15", + "@esbuild/darwin-x64": "0.17.15", + "@esbuild/freebsd-arm64": "0.17.15", + "@esbuild/freebsd-x64": "0.17.15", + "@esbuild/linux-arm": "0.17.15", + "@esbuild/linux-arm64": "0.17.15", + "@esbuild/linux-ia32": "0.17.15", + "@esbuild/linux-loong64": "0.17.15", + "@esbuild/linux-mips64el": "0.17.15", + "@esbuild/linux-ppc64": "0.17.15", + "@esbuild/linux-riscv64": "0.17.15", + "@esbuild/linux-s390x": "0.17.15", + "@esbuild/linux-x64": "0.17.15", + "@esbuild/netbsd-x64": "0.17.15", + "@esbuild/openbsd-x64": "0.17.15", + "@esbuild/sunos-x64": "0.17.15", + "@esbuild/win32-arm64": "0.17.15", + "@esbuild/win32-ia32": "0.17.15", + "@esbuild/win32-x64": "0.17.15" + } + }, "escalade": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.1.1.tgz", @@ -2870,6 +4026,28 @@ } } }, + "fast-glob": { + "version": "3.2.12", + "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.2.12.tgz", + "integrity": "sha512-DVj4CQIYYow0BlaelwK1pHl5n5cRSJfM60UA0zK891sVInoPri2Ekj7+e1CT3/3qxXenpI+nBBmQAcJPJgaj4w==", + "dev": true, + "requires": { + "@nodelib/fs.stat": "^2.0.2", + "@nodelib/fs.walk": "^1.2.3", + "glob-parent": "^5.1.2", + "merge2": "^1.3.0", + "micromatch": "^4.0.4" + } + }, + "fastq": { + "version": "1.15.0", + "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.15.0.tgz", + "integrity": "sha512-wBrocU2LCXXa+lWBt8RoIRD89Fi8OdABODa/kEnyeyjS5aZO5/GNvI5sEINADqP/h8M29UHTHUb53sUu5Ihqdw==", + "dev": true, + "requires": { + "reusify": "^1.0.4" + } + }, "fill-range": { "version": "7.0.1", "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", @@ -2954,6 +4132,20 @@ "is-glob": "^4.0.1" } }, + "globby": { + "version": "11.1.0", + "resolved": "https://registry.npmjs.org/globby/-/globby-11.1.0.tgz", + "integrity": "sha512-jhIXaOzy1sb8IyocaruWSn1TjmnBVs8Ayhcy83rmxNJ8q2uWKCAj3CnJY+KpGSXCueAPc0i05kVvVKtP1t9S3g==", + "dev": true, + "requires": { + "array-union": "^2.1.0", + "dir-glob": "^3.0.1", + "fast-glob": "^3.2.9", + "ignore": "^5.2.0", + "merge2": "^1.4.1", + "slash": "^3.0.0" + } + }, "growl": { "version": "1.10.5", "resolved": "https://registry.npmjs.org/growl/-/growl-1.10.5.tgz", @@ -2984,6 +4176,12 @@ "integrity": "sha512-vbaCKN2QLtP/vD4yvs6iz6hBEo6wkSzs8HpRah1Z6aGmF2KW5PdYuAd7uX5a+OyBZHBhd+TFLqgjUgytQr4RvQ==", "dev": true }, + "ignore": { + "version": "5.2.4", + "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.2.4.tgz", + "integrity": "sha512-MAb38BcSbH0eHNBxn7ql2NH/kX33OkB3lZ1BNdh7ENeRChHTYsTvWrMubiIAMNS2llXEEgZ1MUOBtXChP3kaFQ==", + "dev": true + }, "indent-string": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/indent-string/-/indent-string-4.0.0.tgz", @@ -3077,6 +4275,12 @@ "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=", "dev": true }, + "joycon": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/joycon/-/joycon-3.1.1.tgz", + "integrity": "sha512-34wB/Y7MW7bzjKRjUKTa46I2Z7eV62Rkhva+KkopW7Qvv/OSWBqvkSY7vusOPrNuZcUG3tApvdVgNB8POj3SPw==", + "dev": true + }, "js-yaml": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz", @@ -3104,6 +4308,12 @@ "integrity": "sha512-bfTIN7lEsiooCocSISTWXkiWJkRqtL9wYtYy+8EK3Y41qh3mpwPU0ycTOgjdY9ErwXCc8QyrQp82bdL0Xkm9yA==", "dev": true }, + "lines-and-columns": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/lines-and-columns/-/lines-and-columns-1.2.4.tgz", + "integrity": "sha512-7ylylesZQ/PV29jhEDl3Ufjo6ZX7gCqJr5F7PKrqc93v7fzSymt1BpwEU8nAUXs8qzzvqhbjhK5QZg6Mt/HkBg==", + "dev": true + }, "lint-staged": { "version": "12.1.2", "resolved": "https://registry.npmjs.org/lint-staged/-/lint-staged-12.1.2.tgz", @@ -3214,6 +4424,12 @@ "wrap-ansi": "^7.0.0" } }, + "load-tsconfig": { + "version": "0.2.5", + "resolved": "https://registry.npmjs.org/load-tsconfig/-/load-tsconfig-0.2.5.tgz", + "integrity": "sha512-IXO6OCs9yg8tMKzfPZ1YmheJbZCiEsnBdcB03l0OcfK9prKnJb96siuHCr5Fl37/yo9DnKU+TLpxzTUspw9shg==", + "dev": true + }, "locate-path": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz", @@ -3229,6 +4445,12 @@ "integrity": "sha1-LRd/ZS+jHpObRDjVNBSZ36OCXpk=", "dev": true }, + "lodash.sortby": { + "version": "4.7.0", + "resolved": "https://registry.npmjs.org/lodash.sortby/-/lodash.sortby-4.7.0.tgz", + "integrity": "sha512-HDWXG8isMntAyRF5vZ7xKuEvOhT4AhlRt/3czTSjvGUxjYCBVRQY48ViDHyfYz9VIoBkW4TMGQNapx+l3RUwdA==", + "dev": true + }, "log-symbols": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-4.1.0.tgz", @@ -3299,6 +4521,12 @@ "integrity": "sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w==", "dev": true }, + "merge2": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/merge2/-/merge2-1.4.1.tgz", + "integrity": "sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg==", + "dev": true + }, "micromatch": { "version": "4.0.4", "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.4.tgz", @@ -3388,6 +4616,17 @@ "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", "dev": true }, + "mz": { + "version": "2.7.0", + "resolved": "https://registry.npmjs.org/mz/-/mz-2.7.0.tgz", + "integrity": "sha512-z81GNO7nnYMEhrGh9LeymoE4+Yr0Wn5McHIZMK5cfQCl+NDX08sCZgUc9/6MHni9IWuFLm1Z3HTCXu2z9fN62Q==", + "dev": true, + "requires": { + "any-promise": "^1.0.0", + "object-assign": "^4.0.1", + "thenify-all": "^1.0.0" + } + }, "nanoid": { "version": "3.3.1", "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.1.tgz", @@ -3440,6 +4679,12 @@ "path-key": "^3.0.0" } }, + "object-assign": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", + "integrity": "sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==", + "dev": true + }, "object-inspect": { "version": "1.11.1", "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.11.1.tgz", @@ -3518,6 +4763,12 @@ "isarray": "0.0.1" } }, + "path-type": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/path-type/-/path-type-4.0.0.tgz", + "integrity": "sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==", + "dev": true + }, "pathval": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/pathval/-/pathval-1.1.1.tgz", @@ -3530,12 +4781,42 @@ "integrity": "sha512-lY1Q/PiJGC2zOv/z391WOTD+Z02bCgsFfvxoXXf6h7kv9o+WmsmzYqrAwY63sNgOxE4xEdq0WyUnXfKeBrSvYw==", "dev": true }, + "pirates": { + "version": "4.0.5", + "resolved": "https://registry.npmjs.org/pirates/-/pirates-4.0.5.tgz", + "integrity": "sha512-8V9+HQPupnaXMA23c5hvl69zXvTwTzyAYasnkb0Tts4XvO4CliqONMOnvlq26rkhLC3nWDFBJf73LU1e1VZLaQ==", + "dev": true + }, + "postcss-load-config": { + "version": "3.1.4", + "resolved": "https://registry.npmjs.org/postcss-load-config/-/postcss-load-config-3.1.4.tgz", + "integrity": "sha512-6DiM4E7v4coTE4uzA8U//WhtPwyhiim3eyjEMFCnUpzbrkK9wJHgKDT2mR+HbtSrd/NubVaYTOpSpjUl8NQeRg==", + "dev": true, + "requires": { + "lilconfig": "^2.0.5", + "yaml": "^1.10.2" + }, + "dependencies": { + "lilconfig": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/lilconfig/-/lilconfig-2.1.0.tgz", + "integrity": "sha512-utWOt/GHzuUxnLKxB6dk81RoOeoNeHgbrXiuGk4yyF5qlRz+iIVWu56E2fqGHFrXz0QNUhLB/8nKqvRH66JKGQ==", + "dev": true + } + } + }, "prettier": { "version": "2.5.1", "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.5.1.tgz", "integrity": "sha512-vBZcPRUR5MZJwoyi3ZoyQlc1rXeEck8KgeC9AwwOn+exuxLxq5toTRDTSaVrXHxelDMHy9zlicw8u66yxoSUFg==", "dev": true }, + "punycode": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.0.tgz", + "integrity": "sha512-rRV+zQD8tVFys26lAGR9WUuS4iUAngJScM+ZRSKtvl5tKeZ2t5bvdNFdNHBW9FWR4guGHlgmsZ1G7BSm2wTbuA==", + "dev": true + }, "query-string": { "version": "7.0.1", "resolved": "https://registry.npmjs.org/query-string/-/query-string-7.0.1.tgz", @@ -3547,6 +4828,12 @@ "strict-uri-encode": "^2.0.0" } }, + "queue-microtask": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/queue-microtask/-/queue-microtask-1.2.3.tgz", + "integrity": "sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==", + "dev": true + }, "randombytes": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.1.0.tgz", @@ -3571,6 +4858,12 @@ "integrity": "sha1-jGStX9MNqxyXbiNE/+f3kqam30I=", "dev": true }, + "resolve-from": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-5.0.0.tgz", + "integrity": "sha512-qYg9KP24dD5qka9J47d0aVky0N+b4fTU89LN9iDnjB5waksiC49rvMB0PrUJQGoTmH50XPiqOvAjDfaijGxYZw==", + "dev": true + }, "restore-cursor": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/restore-cursor/-/restore-cursor-3.1.0.tgz", @@ -3581,12 +4874,36 @@ "signal-exit": "^3.0.2" } }, + "reusify": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/reusify/-/reusify-1.0.4.tgz", + "integrity": "sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw==", + "dev": true + }, "rfdc": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/rfdc/-/rfdc-1.3.0.tgz", "integrity": "sha512-V2hovdzFbOi77/WajaSMXk2OLm+xNIeQdMMuB7icj7bk6zi2F8GGAxigcnDFpJHbNyNcgyJDiP+8nOrY5cZGrA==", "dev": true }, + "rollup": { + "version": "3.20.2", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-3.20.2.tgz", + "integrity": "sha512-3zwkBQl7Ai7MFYQE0y1MeQ15+9jsi7XxfrqwTb/9EK8D9C9+//EBR4M+CuA1KODRaNbFez/lWxA5vhEGZp4MUg==", + "dev": true, + "requires": { + "fsevents": "~2.3.2" + } + }, + "run-parallel": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/run-parallel/-/run-parallel-1.2.0.tgz", + "integrity": "sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA==", + "dev": true, + "requires": { + "queue-microtask": "^1.2.2" + } + }, "rxjs": { "version": "7.4.0", "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-7.4.0.tgz", @@ -3668,6 +4985,12 @@ } } }, + "slash": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/slash/-/slash-3.0.0.tgz", + "integrity": "sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==", + "dev": true + }, "slice-ansi": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/slice-ansi/-/slice-ansi-3.0.0.tgz", @@ -3679,6 +5002,43 @@ "is-fullwidth-code-point": "^3.0.0" } }, + "source-map": { + "version": "0.8.0-beta.0", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.8.0-beta.0.tgz", + "integrity": "sha512-2ymg6oRBpebeZi9UUNsgQ89bhx01TcTkmNTGnNO88imTmbSgy4nfujrgVEFKWpMTEGA11EDkTt7mqObTPdigIA==", + "dev": true, + "requires": { + "whatwg-url": "^7.0.0" + }, + "dependencies": { + "tr46": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/tr46/-/tr46-1.0.1.tgz", + "integrity": "sha512-dTpowEjclQ7Kgx5SdBkqRzVhERQXov8/l9Ft9dVM9fmg0W0KQSVaXX9T4i6twCPNtYiZM53lpSSUAwJbFPOHxA==", + "dev": true, + "requires": { + "punycode": "^2.1.0" + } + }, + "webidl-conversions": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-4.0.2.tgz", + "integrity": "sha512-YQ+BmxuTgd6UXZW3+ICGfyqRyHXVlD5GtQr5+qjiNW7bF0cqrzX500HVXPBOvgXb5YnzDd+h0zqyv61KUD7+Sg==", + "dev": true + }, + "whatwg-url": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-7.1.0.tgz", + "integrity": "sha512-WUu7Rg1DroM7oQvGWfOiAK21n74Gg+T4elXEQYkOhtyLeWiJFoOGLXPKI/9gzIie9CtwVLm8wtw6YJdKyxSjeg==", + "dev": true, + "requires": { + "lodash.sortby": "^4.7.0", + "tr46": "^1.0.1", + "webidl-conversions": "^4.0.2" + } + } + } + }, "split-on-first": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/split-on-first/-/split-on-first-1.1.0.tgz", @@ -3727,6 +5087,42 @@ "integrity": "sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==", "dev": true }, + "sucrase": { + "version": "3.31.0", + "resolved": "https://registry.npmjs.org/sucrase/-/sucrase-3.31.0.tgz", + "integrity": "sha512-6QsHnkqyVEzYcaiHsOKkzOtOgdJcb8i54x6AV2hDwyZcY9ZyykGZVw6L/YN98xC0evwTP6utsWWrKRaa8QlfEQ==", + "dev": true, + "requires": { + "commander": "^4.0.0", + "glob": "7.1.6", + "lines-and-columns": "^1.1.6", + "mz": "^2.7.0", + "pirates": "^4.0.1", + "ts-interface-checker": "^0.1.9" + }, + "dependencies": { + "commander": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/commander/-/commander-4.1.1.tgz", + "integrity": "sha512-NOKm8xhkzAjzFx8B2v5OAHT+u5pRQc2UCa2Vq9jYL/31o2wi9mxBA7LIFs3sV5VSC49z6pEhfbMULvShKj26WA==", + "dev": true + }, + "glob": { + "version": "7.1.6", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.6.tgz", + "integrity": "sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA==", + "dev": true, + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + } + } + } + }, "supports-color": { "version": "7.2.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", @@ -3736,6 +5132,24 @@ "has-flag": "^4.0.0" } }, + "thenify": { + "version": "3.3.1", + "resolved": "https://registry.npmjs.org/thenify/-/thenify-3.3.1.tgz", + "integrity": "sha512-RVZSIV5IG10Hk3enotrhvz0T9em6cyHBLkH/YAZuKqd8hRkKhSfCGIcP2KUY0EPxndzANBmNllzWPwak+bheSw==", + "dev": true, + "requires": { + "any-promise": "^1.0.0" + } + }, + "thenify-all": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/thenify-all/-/thenify-all-1.6.0.tgz", + "integrity": "sha512-RNxQH/qI8/t3thXJDwcstUO4zeqo64+Uy/+sNVRBx4Xn2OX+OZ9oP+iJnNFqplFra2ZUVeKCSa2oVWi3T4uVmA==", + "dev": true, + "requires": { + "thenify": ">= 3.1.0 < 4" + } + }, "through": { "version": "2.3.8", "resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz", @@ -3756,6 +5170,18 @@ "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", "integrity": "sha1-gYT9NH2snNwYWZLzpmIuFLnZq2o=" }, + "tree-kill": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/tree-kill/-/tree-kill-1.2.2.tgz", + "integrity": "sha512-L0Orpi8qGpRG//Nd+H90vFB+3iHnue1zSSGmNOOCh1GLJ7rUKVwV2HvijphGQS2UmhUZewS9VgvxYIdgr+fG1A==", + "dev": true + }, + "ts-interface-checker": { + "version": "0.1.13", + "resolved": "https://registry.npmjs.org/ts-interface-checker/-/ts-interface-checker-0.1.13.tgz", + "integrity": "sha512-Y/arvbn+rrz3JCKl9C4kVNfTfSm2/mEp5FSz5EsZSANGPSlQrpRI5M4PKF+mJnE52jOO90PnPSc3Ur3bTQw0gA==", + "dev": true + }, "ts-node": { "version": "10.9.1", "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.9.1.tgz", @@ -3791,6 +5217,28 @@ "integrity": "sha512-hcVC3wYEziELGGmEEXue7D75zbwIIVUMWAVbHItGPx0ziyXxrOMQx4rQEVEV45Ut/1IotuEvwqPopzIOkDMf0A==", "dev": true }, + "tsup": { + "version": "6.7.0", + "resolved": "https://registry.npmjs.org/tsup/-/tsup-6.7.0.tgz", + "integrity": "sha512-L3o8hGkaHnu5TdJns+mCqFsDBo83bJ44rlK7e6VdanIvpea4ArPcU3swWGsLVbXak1PqQx/V+SSmFPujBK+zEQ==", + "dev": true, + "requires": { + "bundle-require": "^4.0.0", + "cac": "^6.7.12", + "chokidar": "^3.5.1", + "debug": "^4.3.1", + "esbuild": "^0.17.6", + "execa": "^5.0.0", + "globby": "^11.0.3", + "joycon": "^3.0.1", + "postcss-load-config": "^3.0.1", + "resolve-from": "^5.0.0", + "rollup": "^3.2.5", + "source-map": "0.8.0-beta.0", + "sucrase": "^3.20.3", + "tree-kill": "^1.2.2" + } + }, "type": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/type/-/type-1.2.0.tgz", diff --git a/package.json b/package.json index 5134d96..4441de0 100644 --- a/package.json +++ b/package.json @@ -1,15 +1,19 @@ { "name": "@polygon.io/client-js", - "version": "7.1.1", + "version": "7.2.0", "description": "Isomorphic Javascript client for Polygon.io Stocks, Forex, and Crypto APIs", - "main": "lib/main.js", - "types": "lib/main.d.ts", + "main": "dist/main.js", + "types": "dist/main.d.ts", "type": "module", + "exports": { + "import": "./dist/main.js", + "require": "./dist/main.cjs" + }, "scripts": { "test": "mocha", "test:watch": "mocha --watch", "format": "prettier --write '**/*.ts'", - "build": "rm -rf ./lib && ./node_modules/.bin/tsc", + "build": "rm -rf ./dist && tsup src/main.ts --dts --format cjs,esm --minify", "generate-doc": "typedoc src/main.ts" }, "repository": { @@ -60,6 +64,7 @@ "prettier": "^2.5.1", "sinon": "^12.0.1", "ts-node": "^10.9.1", + "tsup": "^6.7.0", "typedoc": "^0.22.10", "typescript": "^4.5.2" }, @@ -75,7 +80,7 @@ ] }, "workspaces": [ - "./lib/*", + "./dist/*", "./sandbox" ], "engines": { diff --git a/tsconfig.json b/tsconfig.json index 8636d5a..c004d13 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -7,7 +7,7 @@ "moduleResolution": "node", "esModuleInterop": true, "declaration": true /* Generates corresponding '.d.ts' file. */, - "outDir": "lib" /* Redirect output structure to the directory. */, + "outDir": "dist" /* Redirect output structure to the directory. */, "typeRoots": [ "node_modules/@types" ] /* List of folders to include type definitions from. */ From 1ff04b5f992d4c10d1103fe9562e4f7c3986dd5d Mon Sep 17 00:00:00 2001 From: justinpolygon <123573436+justinpolygon@users.noreply.github.com> Date: Tue, 11 Apr 2023 07:43:23 -0700 Subject: [PATCH 04/39] Add example for crypto, forex, indices, options, and stocks (#145) * Add example for crypto, forex, indices, options, and stocks * Added new line to end of file * Updated syntax * Update syntax (missed crypto-conditions.js) --- examples/rest/crypto-aggregates_bars.js | 9 +++++++++ examples/rest/crypto-conditions.js | 9 +++++++++ examples/rest/crypto-daily_open_close.js | 9 +++++++++ examples/rest/crypto-exchanges.js | 9 +++++++++ examples/rest/crypto-grouped_daily_bars.js | 9 +++++++++ .../rest/crypto-last_trade_for_a_crypto_pair.js | 9 +++++++++ examples/rest/crypto-market_holidays.js | 9 +++++++++ examples/rest/crypto-market_status.js | 9 +++++++++ examples/rest/crypto-previous_close.js | 9 +++++++++ examples/rest/crypto-snapshots_all_tickers.js | 9 +++++++++ .../rest/crypto-snapshots_gainers_losers.js | 17 +++++++++++++++++ examples/rest/crypto-snapshots_ticker.js | 9 +++++++++ .../crypto-snapshots_ticker_full_book_l2.js | 9 +++++++++ .../rest/crypto-technical_indicators_ema.js | 9 +++++++++ .../rest/crypto-technical_indicators_macd.js | 9 +++++++++ .../rest/crypto-technical_indicators_rsi.js | 9 +++++++++ .../rest/crypto-technical_indicators_sma.js | 9 +++++++++ examples/rest/crypto-tickers.js | 9 +++++++++ examples/rest/crypto-trades.js | 9 +++++++++ examples/rest/forex-aggregates_bars.js | 9 +++++++++ examples/rest/forex-conditions.js | 9 +++++++++ examples/rest/forex-exchanges.js | 9 +++++++++ examples/rest/forex-grouped_daily_bars.js | 9 +++++++++ .../forex-last_quote_for_a_currency_pair.js | 9 +++++++++ examples/rest/forex-market_holidays.js | 9 +++++++++ examples/rest/forex-market_status.js | 9 +++++++++ examples/rest/forex-previous_close.js | 9 +++++++++ examples/rest/forex-quotes.js | 9 +++++++++ .../rest/forex-real-time_currency_conversion.js | 9 +++++++++ examples/rest/forex-snapshots_all_tickers.js | 9 +++++++++ examples/rest/forex-snapshots_gainers_losers.js | 17 +++++++++++++++++ examples/rest/forex-snapshots_ticker.js | 9 +++++++++ examples/rest/forex-technical_indicators_ema.js | 16 ++++++++++++++++ .../rest/forex-technical_indicators_macd.js | 9 +++++++++ examples/rest/forex-technical_indicators_rsi.js | 9 +++++++++ examples/rest/forex-technical_indicators_sma.js | 9 +++++++++ examples/rest/forex-tickers.js | 9 +++++++++ examples/rest/indices-aggregates_bars.js | 9 +++++++++ examples/rest/indices-daily_open_close.js | 9 +++++++++ examples/rest/indices-market_holidays.js | 9 +++++++++ examples/rest/indices-market_status.js | 9 +++++++++ examples/rest/indices-previous_close.js | 9 +++++++++ examples/rest/indices-snapshots.js | 9 +++++++++ .../rest/indices-technical_indicators_ema.js | 9 +++++++++ .../rest/indices-technical_indicators_macd.js | 9 +++++++++ .../rest/indices-technical_indicators_rsi.js | 9 +++++++++ .../rest/indices-technical_indicators_sma.js | 9 +++++++++ examples/rest/indices-ticker_types.js | 9 +++++++++ examples/rest/indices-tickers.js | 9 +++++++++ examples/rest/options-aggregates_bars.js | 9 +++++++++ examples/rest/options-conditions.js | 9 +++++++++ examples/rest/options-contract.js | 9 +++++++++ examples/rest/options-contracts.js | 9 +++++++++ examples/rest/options-daily_open_close.js | 9 +++++++++ examples/rest/options-exchanges.js | 9 +++++++++ examples/rest/options-last_trade.js | 9 +++++++++ examples/rest/options-market_holidays.js | 9 +++++++++ examples/rest/options-market_status.js | 9 +++++++++ examples/rest/options-previous_close.js | 9 +++++++++ examples/rest/options-quotes.js | 9 +++++++++ .../rest/options-snapshots_option_contract.js | 9 +++++++++ .../rest/options-snapshots_options_chain.js | 9 +++++++++ .../rest/options-technical_indicators_ema.js | 9 +++++++++ .../rest/options-technical_indicators_macd.js | 9 +++++++++ .../rest/options-technical_indicators_rsi.js | 9 +++++++++ .../rest/options-technical_indicators_sma.js | 9 +++++++++ examples/rest/options-ticker_details.js | 9 +++++++++ examples/rest/options-ticker_news.js | 9 +++++++++ examples/rest/options-tickers.js | 9 +++++++++ examples/rest/options-trades.js | 9 +++++++++ examples/rest/stocks-aggregates_bars.js | 9 +++++++++ examples/rest/stocks-conditions.js | 9 +++++++++ examples/rest/stocks-daily_open_close.js | 9 +++++++++ examples/rest/stocks-dividends.js | 9 +++++++++ examples/rest/stocks-exchanges.js | 9 +++++++++ examples/rest/stocks-grouped_daily_bars.js | 9 +++++++++ examples/rest/stocks-last_quote.js | 9 +++++++++ examples/rest/stocks-last_trade.js | 9 +++++++++ examples/rest/stocks-market_holidays.js | 9 +++++++++ examples/rest/stocks-market_status.js | 9 +++++++++ examples/rest/stocks-previous_close.js | 9 +++++++++ examples/rest/stocks-quotes.js | 9 +++++++++ examples/rest/stocks-snapshots_all.js | 9 +++++++++ .../rest/stocks-snapshots_gainers_losers.js | 17 +++++++++++++++++ examples/rest/stocks-snapshots_ticker.js | 9 +++++++++ examples/rest/stocks-stock_financials.js | 9 +++++++++ examples/rest/stocks-stock_splits.js | 9 +++++++++ .../rest/stocks-technical_indicators_ema.js | 9 +++++++++ .../rest/stocks-technical_indicators_macd.js | 9 +++++++++ .../rest/stocks-technical_indicators_rsi.js | 9 +++++++++ .../rest/stocks-technical_indicators_sma.js | 9 +++++++++ examples/rest/stocks-ticker_details.js | 9 +++++++++ examples/rest/stocks-ticker_news.js | 9 +++++++++ examples/rest/stocks-ticker_types.js | 9 +++++++++ examples/rest/stocks-tickers.js | 9 +++++++++ examples/rest/stocks-trades.js | 9 +++++++++ 96 files changed, 895 insertions(+) create mode 100644 examples/rest/crypto-aggregates_bars.js create mode 100644 examples/rest/crypto-conditions.js create mode 100644 examples/rest/crypto-daily_open_close.js create mode 100644 examples/rest/crypto-exchanges.js create mode 100644 examples/rest/crypto-grouped_daily_bars.js create mode 100644 examples/rest/crypto-last_trade_for_a_crypto_pair.js create mode 100644 examples/rest/crypto-market_holidays.js create mode 100644 examples/rest/crypto-market_status.js create mode 100644 examples/rest/crypto-previous_close.js create mode 100644 examples/rest/crypto-snapshots_all_tickers.js create mode 100644 examples/rest/crypto-snapshots_gainers_losers.js create mode 100644 examples/rest/crypto-snapshots_ticker.js create mode 100644 examples/rest/crypto-snapshots_ticker_full_book_l2.js create mode 100644 examples/rest/crypto-technical_indicators_ema.js create mode 100644 examples/rest/crypto-technical_indicators_macd.js create mode 100644 examples/rest/crypto-technical_indicators_rsi.js create mode 100644 examples/rest/crypto-technical_indicators_sma.js create mode 100644 examples/rest/crypto-tickers.js create mode 100644 examples/rest/crypto-trades.js create mode 100644 examples/rest/forex-aggregates_bars.js create mode 100644 examples/rest/forex-conditions.js create mode 100644 examples/rest/forex-exchanges.js create mode 100644 examples/rest/forex-grouped_daily_bars.js create mode 100644 examples/rest/forex-last_quote_for_a_currency_pair.js create mode 100644 examples/rest/forex-market_holidays.js create mode 100644 examples/rest/forex-market_status.js create mode 100644 examples/rest/forex-previous_close.js create mode 100644 examples/rest/forex-quotes.js create mode 100644 examples/rest/forex-real-time_currency_conversion.js create mode 100644 examples/rest/forex-snapshots_all_tickers.js create mode 100644 examples/rest/forex-snapshots_gainers_losers.js create mode 100644 examples/rest/forex-snapshots_ticker.js create mode 100644 examples/rest/forex-technical_indicators_ema.js create mode 100644 examples/rest/forex-technical_indicators_macd.js create mode 100644 examples/rest/forex-technical_indicators_rsi.js create mode 100644 examples/rest/forex-technical_indicators_sma.js create mode 100644 examples/rest/forex-tickers.js create mode 100644 examples/rest/indices-aggregates_bars.js create mode 100644 examples/rest/indices-daily_open_close.js create mode 100644 examples/rest/indices-market_holidays.js create mode 100644 examples/rest/indices-market_status.js create mode 100644 examples/rest/indices-previous_close.js create mode 100644 examples/rest/indices-snapshots.js create mode 100644 examples/rest/indices-technical_indicators_ema.js create mode 100644 examples/rest/indices-technical_indicators_macd.js create mode 100644 examples/rest/indices-technical_indicators_rsi.js create mode 100644 examples/rest/indices-technical_indicators_sma.js create mode 100644 examples/rest/indices-ticker_types.js create mode 100644 examples/rest/indices-tickers.js create mode 100644 examples/rest/options-aggregates_bars.js create mode 100644 examples/rest/options-conditions.js create mode 100644 examples/rest/options-contract.js create mode 100644 examples/rest/options-contracts.js create mode 100644 examples/rest/options-daily_open_close.js create mode 100644 examples/rest/options-exchanges.js create mode 100644 examples/rest/options-last_trade.js create mode 100644 examples/rest/options-market_holidays.js create mode 100644 examples/rest/options-market_status.js create mode 100644 examples/rest/options-previous_close.js create mode 100644 examples/rest/options-quotes.js create mode 100644 examples/rest/options-snapshots_option_contract.js create mode 100644 examples/rest/options-snapshots_options_chain.js create mode 100644 examples/rest/options-technical_indicators_ema.js create mode 100644 examples/rest/options-technical_indicators_macd.js create mode 100644 examples/rest/options-technical_indicators_rsi.js create mode 100644 examples/rest/options-technical_indicators_sma.js create mode 100644 examples/rest/options-ticker_details.js create mode 100644 examples/rest/options-ticker_news.js create mode 100644 examples/rest/options-tickers.js create mode 100644 examples/rest/options-trades.js create mode 100644 examples/rest/stocks-aggregates_bars.js create mode 100644 examples/rest/stocks-conditions.js create mode 100644 examples/rest/stocks-daily_open_close.js create mode 100644 examples/rest/stocks-dividends.js create mode 100644 examples/rest/stocks-exchanges.js create mode 100644 examples/rest/stocks-grouped_daily_bars.js create mode 100644 examples/rest/stocks-last_quote.js create mode 100644 examples/rest/stocks-last_trade.js create mode 100644 examples/rest/stocks-market_holidays.js create mode 100644 examples/rest/stocks-market_status.js create mode 100644 examples/rest/stocks-previous_close.js create mode 100644 examples/rest/stocks-quotes.js create mode 100644 examples/rest/stocks-snapshots_all.js create mode 100644 examples/rest/stocks-snapshots_gainers_losers.js create mode 100644 examples/rest/stocks-snapshots_ticker.js create mode 100644 examples/rest/stocks-stock_financials.js create mode 100644 examples/rest/stocks-stock_splits.js create mode 100644 examples/rest/stocks-technical_indicators_ema.js create mode 100644 examples/rest/stocks-technical_indicators_macd.js create mode 100644 examples/rest/stocks-technical_indicators_rsi.js create mode 100644 examples/rest/stocks-technical_indicators_sma.js create mode 100644 examples/rest/stocks-ticker_details.js create mode 100644 examples/rest/stocks-ticker_news.js create mode 100644 examples/rest/stocks-ticker_types.js create mode 100644 examples/rest/stocks-tickers.js create mode 100644 examples/rest/stocks-trades.js diff --git a/examples/rest/crypto-aggregates_bars.js b/examples/rest/crypto-aggregates_bars.js new file mode 100644 index 0000000..f7daef8 --- /dev/null +++ b/examples/rest/crypto-aggregates_bars.js @@ -0,0 +1,9 @@ +const { restClient } = require('@polygon.io/client-js'); +const rest = restClient("API KEY", "https://api.polygon.io"); + +// 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) => { + console.log(data); +}).catch(e => { + console.error('An error happened:', e); +}); diff --git a/examples/rest/crypto-conditions.js b/examples/rest/crypto-conditions.js new file mode 100644 index 0000000..7e22f78 --- /dev/null +++ b/examples/rest/crypto-conditions.js @@ -0,0 +1,9 @@ +const { restClient } = require('@polygon.io/client-js'); +const rest = restClient("API KEY", "https://api.polygon.io"); + +// https://polygon.io/docs/crypto/get_v3_reference_conditions +rest.reference.conditions({ asset_class: "crypto", limit: 1000 }).then((data) => { + console.log(data); +}).catch(e => { + console.error('An error happened:', e); +}); diff --git a/examples/rest/crypto-daily_open_close.js b/examples/rest/crypto-daily_open_close.js new file mode 100644 index 0000000..ad7faa7 --- /dev/null +++ b/examples/rest/crypto-daily_open_close.js @@ -0,0 +1,9 @@ +const { restClient } = require('@polygon.io/client-js'); +const rest = restClient("API KEY", "https://api.polygon.io"); + +// https://polygon.io/docs/crypto/get_v1_open-close_crypto__from___to___date +rest.crypto.dailyOpenClose("BTC", "USD", "2019-01-01").then((data) => { + console.log(data); +}).catch(e => { + console.error('An error happened:', e); +}); diff --git a/examples/rest/crypto-exchanges.js b/examples/rest/crypto-exchanges.js new file mode 100644 index 0000000..7ec6d93 --- /dev/null +++ b/examples/rest/crypto-exchanges.js @@ -0,0 +1,9 @@ +const { restClient } = require('@polygon.io/client-js'); +const rest = restClient("API KEY", "https://api.polygon.io"); + +// https://polygon.io/docs/crypto/get_v3_reference_exchanges +rest.reference.exchanges({ asset_class: "crypto", limit: 1000 }).then((data) => { + console.log(data); +}).catch(e => { + console.error('An error happened:', e); +}); diff --git a/examples/rest/crypto-grouped_daily_bars.js b/examples/rest/crypto-grouped_daily_bars.js new file mode 100644 index 0000000..46f0daa --- /dev/null +++ b/examples/rest/crypto-grouped_daily_bars.js @@ -0,0 +1,9 @@ +const { restClient } = require('@polygon.io/client-js'); +const rest = restClient("API KEY", "https://api.polygon.io"); + +// https://polygon.io/docs/crypto/get_v2_aggs_grouped_locale_global_market_crypto__date +rest.crypto.aggregatesGroupedDaily("2023-03-31").then((data) => { + console.log(data); +}).catch(e => { + console.error('An error happened:', e); +}); diff --git a/examples/rest/crypto-last_trade_for_a_crypto_pair.js b/examples/rest/crypto-last_trade_for_a_crypto_pair.js new file mode 100644 index 0000000..625a03c --- /dev/null +++ b/examples/rest/crypto-last_trade_for_a_crypto_pair.js @@ -0,0 +1,9 @@ +const { restClient } = require('@polygon.io/client-js'); +const rest = restClient("API KEY", "https://api.polygon.io"); + +// https://polygon.io/docs/crypto/get_v1_last_crypto__from___to +rest.crypto.lastTrade("BTC", "USD").then((data) => { + console.log(data); +}).catch(e => { + console.error('An error happened:', e); +}); diff --git a/examples/rest/crypto-market_holidays.js b/examples/rest/crypto-market_holidays.js new file mode 100644 index 0000000..6bff875 --- /dev/null +++ b/examples/rest/crypto-market_holidays.js @@ -0,0 +1,9 @@ +const { restClient } = require('@polygon.io/client-js'); +const rest = restClient("API KEY", "https://api.polygon.io"); + +// https://polygon.io/docs/crypto/get_v1_marketstatus_upcoming +rest.reference.marketHolidays().then((data) => { + console.log(data); +}).catch(e => { + console.error('An error happened:', e); +}); diff --git a/examples/rest/crypto-market_status.js b/examples/rest/crypto-market_status.js new file mode 100644 index 0000000..0f0e26d --- /dev/null +++ b/examples/rest/crypto-market_status.js @@ -0,0 +1,9 @@ +const { restClient } = require('@polygon.io/client-js'); +const rest = restClient("API KEY", "https://api.polygon.io"); + +// https://polygon.io/docs/crypto/get_v1_marketstatus_now +rest.reference.marketStatus().then((data) => { + console.log(data); +}).catch(e => { + console.error('An error happened:', e); +}); diff --git a/examples/rest/crypto-previous_close.js b/examples/rest/crypto-previous_close.js new file mode 100644 index 0000000..e63713c --- /dev/null +++ b/examples/rest/crypto-previous_close.js @@ -0,0 +1,9 @@ +const { restClient } = require('@polygon.io/client-js'); +const rest = restClient("API KEY", "https://api.polygon.io"); + +// https://polygon.io/docs/crypto/get_v2_aggs_ticker__cryptoticker__prev +rest.crypto.previousClose("X:BTCUSD").then((data) => { + console.log(data); +}).catch(e => { + console.error('An error happened:', e); +}); diff --git a/examples/rest/crypto-snapshots_all_tickers.js b/examples/rest/crypto-snapshots_all_tickers.js new file mode 100644 index 0000000..b703190 --- /dev/null +++ b/examples/rest/crypto-snapshots_all_tickers.js @@ -0,0 +1,9 @@ +const { restClient } = require('@polygon.io/client-js'); +const rest = restClient("API KEY", "https://api.polygon.io"); + +// https://polygon.io/docs/crypto/get_v2_snapshot_locale_global_markets_crypto_tickers +rest.crypto.snapshotAllTickers("").then((data) => { + console.log(data); +}).catch(e => { + console.error('An error happened:', e); +}); diff --git a/examples/rest/crypto-snapshots_gainers_losers.js b/examples/rest/crypto-snapshots_gainers_losers.js new file mode 100644 index 0000000..21a0fea --- /dev/null +++ b/examples/rest/crypto-snapshots_gainers_losers.js @@ -0,0 +1,17 @@ +const { restClient } = require('@polygon.io/client-js'); +const rest = restClient("API KEY", "https://api.polygon.io"); + +// https://polygon.io/docs/crypto/get_v2_snapshot_locale_global_markets_crypto__direction +// gainers +rest.crypto.snapshotGainersLosers("gainers").then((data) => { + console.log(data); +}).catch(e => { + console.error('An error happened:', e); +}); + +// losers +rest.crypto.snapshotGainersLosers("losers").then((data) => { + console.log(data); +}).catch(e => { + console.error('An error happened:', e); +}); diff --git a/examples/rest/crypto-snapshots_ticker.js b/examples/rest/crypto-snapshots_ticker.js new file mode 100644 index 0000000..6bae1d3 --- /dev/null +++ b/examples/rest/crypto-snapshots_ticker.js @@ -0,0 +1,9 @@ +const { restClient } = require('@polygon.io/client-js'); +const rest = restClient("API KEY", "https://api.polygon.io"); + +// https://polygon.io/docs/crypto/get_v2_snapshot_locale_global_markets_crypto_tickers__ticker +rest.crypto.snapshotTicker("X:BTCUSD").then((data) => { + console.log(data); +}).catch(e => { + console.error('An error happened:', e); +}); diff --git a/examples/rest/crypto-snapshots_ticker_full_book_l2.js b/examples/rest/crypto-snapshots_ticker_full_book_l2.js new file mode 100644 index 0000000..ca08f52 --- /dev/null +++ b/examples/rest/crypto-snapshots_ticker_full_book_l2.js @@ -0,0 +1,9 @@ +const { restClient } = require('@polygon.io/client-js'); +const rest = restClient("API KEY", "https://api.polygon.io"); + +// https://polygon.io/docs/crypto/get_v2_snapshot_locale_global_markets_crypto_tickers__ticker__book +rest.crypto.snapshotTickerFullBookL2("X:BTCUSD").then((data) => { + console.log(data); +}).catch(e => { + console.error('An error happened:', e); +}); diff --git a/examples/rest/crypto-technical_indicators_ema.js b/examples/rest/crypto-technical_indicators_ema.js new file mode 100644 index 0000000..09fffb3 --- /dev/null +++ b/examples/rest/crypto-technical_indicators_ema.js @@ -0,0 +1,9 @@ +const { restClient } = require('@polygon.io/client-js'); +const rest = restClient("API KEY", "https://api.polygon.io"); + +// https://polygon.io/docs/crypto/get_v1_indicators_ema__cryptoticker +rest.crypto.ema("X:BTCUSD").then((data) => { + console.log(data); +}).catch(e => { + console.error('An error happened:', e); +}); diff --git a/examples/rest/crypto-technical_indicators_macd.js b/examples/rest/crypto-technical_indicators_macd.js new file mode 100644 index 0000000..756db4a --- /dev/null +++ b/examples/rest/crypto-technical_indicators_macd.js @@ -0,0 +1,9 @@ +const { restClient } = require('@polygon.io/client-js'); +const rest = restClient("API KEY", "https://api.polygon.io"); + +// https://polygon.io/docs/crypto/get_v1_indicators_macd__cryptoticker +rest.crypto.macd("X:BTCUSD").then((data) => { + console.log(data); +}).catch(e => { + console.error('An error happened:', e); +}); diff --git a/examples/rest/crypto-technical_indicators_rsi.js b/examples/rest/crypto-technical_indicators_rsi.js new file mode 100644 index 0000000..7f6a3d8 --- /dev/null +++ b/examples/rest/crypto-technical_indicators_rsi.js @@ -0,0 +1,9 @@ +const { restClient } = require('@polygon.io/client-js'); +const rest = restClient("API KEY", "https://api.polygon.io"); + +// hhttps://polygon.io/docs/crypto/get_v1_indicators_rsi__cryptoticker +rest.crypto.rsi("X:BTCUSD").then((data) => { + console.log(data); +}).catch(e => { + console.error('An error happened:', e); +}); diff --git a/examples/rest/crypto-technical_indicators_sma.js b/examples/rest/crypto-technical_indicators_sma.js new file mode 100644 index 0000000..9a1997d --- /dev/null +++ b/examples/rest/crypto-technical_indicators_sma.js @@ -0,0 +1,9 @@ +const { restClient } = require('@polygon.io/client-js'); +const rest = restClient("API KEY", "https://api.polygon.io"); + +// https://polygon.io/docs/crypto/get_v1_indicators_sma__cryptoticker +rest.crypto.sma("X:BTCUSD").then((data) => { + console.log(data); +}).catch(e => { + console.error('An error happened:', e); +}); diff --git a/examples/rest/crypto-tickers.js b/examples/rest/crypto-tickers.js new file mode 100644 index 0000000..7d5c9af --- /dev/null +++ b/examples/rest/crypto-tickers.js @@ -0,0 +1,9 @@ +const { restClient } = require('@polygon.io/client-js'); +const rest = restClient("API KEY", "https://api.polygon.io"); + +// https://polygon.io/docs/crypto/get_v3_reference_tickers +rest.reference.tickers({ market: "crypto", limit: 1000 }).then((data) => { + console.log(data); +}).catch(e => { + console.error('An error happened:', e); +}); diff --git a/examples/rest/crypto-trades.js b/examples/rest/crypto-trades.js new file mode 100644 index 0000000..468345a --- /dev/null +++ b/examples/rest/crypto-trades.js @@ -0,0 +1,9 @@ +const { restClient } = require('@polygon.io/client-js'); +const rest = restClient("API KEY", "https://api.polygon.io"); + +// https://polygon.io/docs/crypto/get_v3_trades__cryptoticker +rest.crypto.trades("X:BTCUSD").then((data) => { + console.log(data); +}).catch(e => { + console.error('An error happened:', e); +}); diff --git a/examples/rest/forex-aggregates_bars.js b/examples/rest/forex-aggregates_bars.js new file mode 100644 index 0000000..324125b --- /dev/null +++ b/examples/rest/forex-aggregates_bars.js @@ -0,0 +1,9 @@ +const { restClient } = require('@polygon.io/client-js'); +const rest = restClient("API KEY", "https://api.polygon.io"); + +// 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) => { + console.log(data); +}).catch(e => { + console.error('An error happened:', e); +}); diff --git a/examples/rest/forex-conditions.js b/examples/rest/forex-conditions.js new file mode 100644 index 0000000..1f658e0 --- /dev/null +++ b/examples/rest/forex-conditions.js @@ -0,0 +1,9 @@ +const { restClient } = require('@polygon.io/client-js'); +const rest = restClient("API KEY", "https://api.polygon.io"); + +// https://polygon.io/docs/forex/get_v3_reference_conditions +rest.reference.conditions({ asset_class: "fx", limit: 1000 }).then((data) => { + console.log(data); +}).catch(e => { + console.error('An error happened:', e); +}); diff --git a/examples/rest/forex-exchanges.js b/examples/rest/forex-exchanges.js new file mode 100644 index 0000000..7d158d5 --- /dev/null +++ b/examples/rest/forex-exchanges.js @@ -0,0 +1,9 @@ +const { restClient } = require('@polygon.io/client-js'); +const rest = restClient("API KEY", "https://api.polygon.io"); + +// https://polygon.io/docs/forex/get_v3_reference_exchanges +rest.reference.exchanges({ asset_class: "fx", limit: 1000 }).then((data) => { + console.log(data); +}).catch(e => { + console.error('An error happened:', e); +}); diff --git a/examples/rest/forex-grouped_daily_bars.js b/examples/rest/forex-grouped_daily_bars.js new file mode 100644 index 0000000..eb9740f --- /dev/null +++ b/examples/rest/forex-grouped_daily_bars.js @@ -0,0 +1,9 @@ +const { restClient } = require('@polygon.io/client-js'); +const rest = restClient("API KEY", "https://api.polygon.io"); + +// https://polygon.io/docs/forex/get_v2_aggs_grouped_locale_global_market_fx__date +rest.forex.aggregatesGroupedDaily("2023-03-31").then((data) => { + console.log(data); +}).catch(e => { + console.error('An error happened:', e); +}); diff --git a/examples/rest/forex-last_quote_for_a_currency_pair.js b/examples/rest/forex-last_quote_for_a_currency_pair.js new file mode 100644 index 0000000..715b9a3 --- /dev/null +++ b/examples/rest/forex-last_quote_for_a_currency_pair.js @@ -0,0 +1,9 @@ +const { restClient } = require('@polygon.io/client-js'); +const rest = restClient("API KEY", "https://api.polygon.io"); + +// https://polygon.io/docs/forex/get_v1_last_quote_currencies__from___to +rest.forex.lastQuote("AUD", "USD").then((data) => { + console.log(data); +}).catch(e => { + console.error('An error happened:', e); +}); diff --git a/examples/rest/forex-market_holidays.js b/examples/rest/forex-market_holidays.js new file mode 100644 index 0000000..40d48e0 --- /dev/null +++ b/examples/rest/forex-market_holidays.js @@ -0,0 +1,9 @@ +const { restClient } = require('@polygon.io/client-js'); +const rest = restClient("API KEY", "https://api.polygon.io"); + +// https://polygon.io/docs/forex/get_v1_marketstatus_upcoming +rest.reference.marketHolidays().then((data) => { + console.log(data); +}).catch(e => { + console.error('An error happened:', e); +}); diff --git a/examples/rest/forex-market_status.js b/examples/rest/forex-market_status.js new file mode 100644 index 0000000..7b54ac9 --- /dev/null +++ b/examples/rest/forex-market_status.js @@ -0,0 +1,9 @@ +const { restClient } = require('@polygon.io/client-js'); +const rest = restClient("API KEY", "https://api.polygon.io"); + +// https://polygon.io/docs/forex/get_v1_marketstatus_now +rest.reference.marketStatus().then((data) => { + console.log(data); +}).catch(e => { + console.error('An error happened:', e); +}); diff --git a/examples/rest/forex-previous_close.js b/examples/rest/forex-previous_close.js new file mode 100644 index 0000000..b14a0d6 --- /dev/null +++ b/examples/rest/forex-previous_close.js @@ -0,0 +1,9 @@ +const { restClient } = require('@polygon.io/client-js'); +const rest = restClient("API KEY", "https://api.polygon.io"); + +// https://polygon.io/docs/forex/get_v2_aggs_ticker__forexticker__prev +rest.forex.previousClose("C:EURUSD").then((data) => { + console.log(data); +}).catch(e => { + console.error('An error happened:', e); +}); diff --git a/examples/rest/forex-quotes.js b/examples/rest/forex-quotes.js new file mode 100644 index 0000000..8ecfb66 --- /dev/null +++ b/examples/rest/forex-quotes.js @@ -0,0 +1,9 @@ +const { restClient } = require('@polygon.io/client-js'); +const rest = restClient("API KEY", "https://api.polygon.io"); + +// https://polygon.io/docs/forex/get_v3_quotes__fxticker +rest.forex.quotes("C:EUR-USD").then((data) => { + console.log(data); +}).catch(e => { + console.error('An error happened:', e); +}); diff --git a/examples/rest/forex-real-time_currency_conversion.js b/examples/rest/forex-real-time_currency_conversion.js new file mode 100644 index 0000000..befd7ca --- /dev/null +++ b/examples/rest/forex-real-time_currency_conversion.js @@ -0,0 +1,9 @@ +const { restClient } = require('@polygon.io/client-js'); +const rest = restClient("API KEY", "https://api.polygon.io"); + +// https://polygon.io/docs/forex/get_v1_conversion__from___to +rest.forex.conversion("AUD", "USD").then((data) => { + console.log(data); +}).catch(e => { + console.error('An error happened:', e); +}); diff --git a/examples/rest/forex-snapshots_all_tickers.js b/examples/rest/forex-snapshots_all_tickers.js new file mode 100644 index 0000000..55fb4d7 --- /dev/null +++ b/examples/rest/forex-snapshots_all_tickers.js @@ -0,0 +1,9 @@ +const { restClient } = require('@polygon.io/client-js'); +const rest = restClient("API KEY", "https://api.polygon.io"); + +// https://polygon.io/docs/forex/get_v2_snapshot_locale_global_markets_forex_tickers +rest.forex.snapshotTicker("").then((data) => { + console.log(data); +}).catch(e => { + console.error('An error happened:', e); +}); diff --git a/examples/rest/forex-snapshots_gainers_losers.js b/examples/rest/forex-snapshots_gainers_losers.js new file mode 100644 index 0000000..c16d192 --- /dev/null +++ b/examples/rest/forex-snapshots_gainers_losers.js @@ -0,0 +1,17 @@ +const { restClient } = require('@polygon.io/client-js'); +const rest = restClient("API KEY", "https://api.polygon.io"); + +// https://polygon.io/docs/forex/get_v2_snapshot_locale_global_markets_forex__direction +// gainers +rest.forex.snapshotGainersLosers("gainers").then((data) => { + console.log(data); +}).catch(e => { + console.error('An error happened:', e); +}); + +// losers +rest.forex.snapshotGainersLosers("losers").then((data) => { + console.log(data); +}).catch(e => { + console.error('An error happened:', e); +}); diff --git a/examples/rest/forex-snapshots_ticker.js b/examples/rest/forex-snapshots_ticker.js new file mode 100644 index 0000000..511dd41 --- /dev/null +++ b/examples/rest/forex-snapshots_ticker.js @@ -0,0 +1,9 @@ +const { restClient } = require('@polygon.io/client-js'); +const rest = restClient("API KEY", "https://api.polygon.io"); + +// https://polygon.io/docs/forex/get_v2_snapshot_locale_global_markets_forex_tickers__ticker +rest.forex.snapshotTicker("C:EURUSD").then((data) => { + console.log(data); +}).catch(e => { + console.error('An error happened:', e); +}); diff --git a/examples/rest/forex-technical_indicators_ema.js b/examples/rest/forex-technical_indicators_ema.js new file mode 100644 index 0000000..1381a6f --- /dev/null +++ b/examples/rest/forex-technical_indicators_ema.js @@ -0,0 +1,16 @@ +const { restClient } = require('@polygon.io/client-js'); +const rest = restClient("API KEY", "https://api.polygon.io"); + +// https://polygon.io/docs/forex/get_v1_indicators_ema__fxticker +rest.forex.ema("C:EURUSD", + { + timespan: "day", + adjusted: true, + window: 50, + series_type: "close", + order: "desc" + }).then((data) => { + console.log(data); +}).catch(e => { + console.error('An error happened:', e); +}); diff --git a/examples/rest/forex-technical_indicators_macd.js b/examples/rest/forex-technical_indicators_macd.js new file mode 100644 index 0000000..43b3b90 --- /dev/null +++ b/examples/rest/forex-technical_indicators_macd.js @@ -0,0 +1,9 @@ +const { restClient } = require('@polygon.io/client-js'); +const rest = restClient("API KEY", "https://api.polygon.io"); + +// https://polygon.io/docs/forex/get_v1_indicators_macd__fxticker +rest.forex.macd("C:EURUSD").then((data) => { + console.log(data); +}).catch(e => { + console.error('An error happened:', e); +}); diff --git a/examples/rest/forex-technical_indicators_rsi.js b/examples/rest/forex-technical_indicators_rsi.js new file mode 100644 index 0000000..5c4a6ea --- /dev/null +++ b/examples/rest/forex-technical_indicators_rsi.js @@ -0,0 +1,9 @@ +const { restClient } = require('@polygon.io/client-js'); +const rest = restClient("API KEY", "https://api.polygon.io"); + +// https://polygon.io/docs/forex/get_v1_indicators_rsi__fxticker +rest.forex.rsi("C:EURUSD").then((data) => { + console.log(data); +}).catch(e => { + console.error('An error happened:', e); +}); diff --git a/examples/rest/forex-technical_indicators_sma.js b/examples/rest/forex-technical_indicators_sma.js new file mode 100644 index 0000000..4f39ac6 --- /dev/null +++ b/examples/rest/forex-technical_indicators_sma.js @@ -0,0 +1,9 @@ +const { restClient } = require('@polygon.io/client-js'); +const rest = restClient("API KEY", "https://api.polygon.io"); + +// https://polygon.io/docs/forex/get_v1_indicators_sma__fxticker +rest.forex.sma("C:EURUSD").then((data) => { + console.log(data); +}).catch(e => { + console.error('An error happened:', e); +}); diff --git a/examples/rest/forex-tickers.js b/examples/rest/forex-tickers.js new file mode 100644 index 0000000..aaca154 --- /dev/null +++ b/examples/rest/forex-tickers.js @@ -0,0 +1,9 @@ +const { restClient } = require('@polygon.io/client-js'); +const rest = restClient("API KEY", "https://api.polygon.io"); + +// https://polygon.io/docs/forex/get_v3_reference_tickers +rest.reference.tickers({ market: "fx", limit: 1000 }).then((data) => { + console.log(data); +}).catch(e => { + console.error('An error happened:', e); +}); diff --git a/examples/rest/indices-aggregates_bars.js b/examples/rest/indices-aggregates_bars.js new file mode 100644 index 0000000..77da2f4 --- /dev/null +++ b/examples/rest/indices-aggregates_bars.js @@ -0,0 +1,9 @@ +const { restClient } = require('@polygon.io/client-js'); +const rest = restClient("API KEY", "https://api.polygon.io"); + +// 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) => { + console.log(data); +}).catch(e => { + console.error('An error happened:', e); +}); diff --git a/examples/rest/indices-daily_open_close.js b/examples/rest/indices-daily_open_close.js new file mode 100644 index 0000000..f557194 --- /dev/null +++ b/examples/rest/indices-daily_open_close.js @@ -0,0 +1,9 @@ +const { restClient } = require('@polygon.io/client-js'); +const rest = restClient("API KEY", "https://api.polygon.io"); + +// https://polygon.io/docs/indices/get_v1_open-close__indicesticker___date +rest.indices.dailyOpenClose("I:SPX", "2023-03-31").then((data) => { + console.log(data); +}).catch(e => { + console.error('An error happened:', e); +}); diff --git a/examples/rest/indices-market_holidays.js b/examples/rest/indices-market_holidays.js new file mode 100644 index 0000000..520f715 --- /dev/null +++ b/examples/rest/indices-market_holidays.js @@ -0,0 +1,9 @@ +const { restClient } = require('@polygon.io/client-js'); +const rest = restClient("API KEY", "https://api.polygon.io"); + +// https://polygon.io/docs/indices/get_v1_marketstatus_upcoming +rest.reference.marketHolidays().then((data) => { + console.log(data); +}).catch(e => { + console.error('An error happened:', e); +}); diff --git a/examples/rest/indices-market_status.js b/examples/rest/indices-market_status.js new file mode 100644 index 0000000..3ff99e1 --- /dev/null +++ b/examples/rest/indices-market_status.js @@ -0,0 +1,9 @@ +const { restClient } = require('@polygon.io/client-js'); +const rest = restClient("API KEY", "https://api.polygon.io"); + +// https://polygon.io/docs/indices/get_v1_marketstatus_now +rest.reference.marketStatus().then((data) => { + console.log(data); +}).catch(e => { + console.error('An error happened:', e); +}); diff --git a/examples/rest/indices-previous_close.js b/examples/rest/indices-previous_close.js new file mode 100644 index 0000000..6be258d --- /dev/null +++ b/examples/rest/indices-previous_close.js @@ -0,0 +1,9 @@ +const { restClient } = require('@polygon.io/client-js'); +const rest = restClient("API KEY", "https://api.polygon.io"); + +// https://polygon.io/docs/indices/get_v2_aggs_ticker__indicesticker__prev +rest.indices.previousClose("I:SPX").then((data) => { + console.log(data); +}).catch(e => { + console.error('An error happened:', e); +}); diff --git a/examples/rest/indices-snapshots.js b/examples/rest/indices-snapshots.js new file mode 100644 index 0000000..14a0136 --- /dev/null +++ b/examples/rest/indices-snapshots.js @@ -0,0 +1,9 @@ +const { restClient } = require('@polygon.io/client-js'); +const rest = restClient("API KEY", "https://api.polygon.io"); + +// https://polygon.io/docs/indices/get_v3_snapshot_indices +rest.indices.snapshotTicker({ "ticker.any_of": "I:SPX" }).then((data) => { + console.log(data); +}).catch(e => { + console.error('An error happened:', e); +}); diff --git a/examples/rest/indices-technical_indicators_ema.js b/examples/rest/indices-technical_indicators_ema.js new file mode 100644 index 0000000..a02ef6a --- /dev/null +++ b/examples/rest/indices-technical_indicators_ema.js @@ -0,0 +1,9 @@ +const { restClient } = require('@polygon.io/client-js'); +const rest = restClient("API KEY", "https://api.polygon.io"); + +// https://polygon.io/docs/indices/get_v1_indicators_ema__indicesticker +rest.indices.ema("I:SPX").then((data) => { + console.log(data); +}).catch(e => { + console.error('An error happened:', e); +}); diff --git a/examples/rest/indices-technical_indicators_macd.js b/examples/rest/indices-technical_indicators_macd.js new file mode 100644 index 0000000..38e6484 --- /dev/null +++ b/examples/rest/indices-technical_indicators_macd.js @@ -0,0 +1,9 @@ +const { restClient } = require('@polygon.io/client-js'); +const rest = restClient("API KEY", "https://api.polygon.io"); + +// https://polygon.io/docs/indices/get_v1_indicators_macd__indicesticker +rest.indices.macd("I:SPX").then((data) => { + console.log(data); +}).catch(e => { + console.error('An error happened:', e); +}); diff --git a/examples/rest/indices-technical_indicators_rsi.js b/examples/rest/indices-technical_indicators_rsi.js new file mode 100644 index 0000000..054aacf --- /dev/null +++ b/examples/rest/indices-technical_indicators_rsi.js @@ -0,0 +1,9 @@ +const { restClient } = require('@polygon.io/client-js'); +const rest = restClient("API KEY", "https://api.polygon.io"); + +// https://polygon.io/docs/indices/get_v1_indicators_rsi__indicesticker +rest.indices.rsi("I:SPX").then((data) => { + console.log(data); +}).catch(e => { + console.error('An error happened:', e); +}); diff --git a/examples/rest/indices-technical_indicators_sma.js b/examples/rest/indices-technical_indicators_sma.js new file mode 100644 index 0000000..feca02c --- /dev/null +++ b/examples/rest/indices-technical_indicators_sma.js @@ -0,0 +1,9 @@ +const { restClient } = require('@polygon.io/client-js'); +const rest = restClient("API KEY", "https://api.polygon.io"); + +// https://polygon.io/docs/indices/get_v1_indicators_sma__indicesticker +rest.indices.sma("I:SPX").then((data) => { + console.log(data); +}).catch(e => { + console.error('An error happened:', e); +}); diff --git a/examples/rest/indices-ticker_types.js b/examples/rest/indices-ticker_types.js new file mode 100644 index 0000000..15cda70 --- /dev/null +++ b/examples/rest/indices-ticker_types.js @@ -0,0 +1,9 @@ +const { restClient } = require('@polygon.io/client-js'); +const rest = restClient("API KEY", "https://api.polygon.io"); + +// https://polygon.io/docs/indices/get_v3_reference_tickers_types +rest.reference.tickerTypes({ asset_class: "indices"}).then((data) => { + console.log(data); +}).catch(e => { + console.error('An error happened:', e); +}); diff --git a/examples/rest/indices-tickers.js b/examples/rest/indices-tickers.js new file mode 100644 index 0000000..88c35ec --- /dev/null +++ b/examples/rest/indices-tickers.js @@ -0,0 +1,9 @@ +const { restClient } = require('@polygon.io/client-js'); +const rest = restClient("API KEY", "https://api.polygon.io"); + +// https://polygon.io/docs/indices/get_v3_reference_tickers +rest.reference.tickers({ market: "indices", limit: 1000 }).then((data) => { + console.log(data); +}).catch(e => { + console.error('An error happened:', e); +}); diff --git a/examples/rest/options-aggregates_bars.js b/examples/rest/options-aggregates_bars.js new file mode 100644 index 0000000..1936302 --- /dev/null +++ b/examples/rest/options-aggregates_bars.js @@ -0,0 +1,9 @@ +const { restClient } = require('@polygon.io/client-js'); +const rest = restClient("API KEY", "https://api.polygon.io"); + +// https://polygon.io/docs/options/get_v2_aggs_ticker__optionsticker__range__multiplier___timespan___from___to +rest.options.aggregates("O:SPY251219C00650000", 1, "day", "2023-01-09", "2023-01-09").then((data) => { + console.log(data); +}).catch(e => { + console.error('An error happened:', e); +}); diff --git a/examples/rest/options-conditions.js b/examples/rest/options-conditions.js new file mode 100644 index 0000000..149a0c8 --- /dev/null +++ b/examples/rest/options-conditions.js @@ -0,0 +1,9 @@ +const { restClient } = require('@polygon.io/client-js'); +const rest = restClient("API KEY", "https://api.polygon.io"); + +// https://polygon.io/docs/options/get_v3_reference_conditions +rest.reference.conditions({ asset_class: "options", limit: 1000 }).then((data) => { + console.log(data); +}).catch(e => { + console.error('An error happened:', e); +}); diff --git a/examples/rest/options-contract.js b/examples/rest/options-contract.js new file mode 100644 index 0000000..697c21e --- /dev/null +++ b/examples/rest/options-contract.js @@ -0,0 +1,9 @@ +const { restClient } = require('@polygon.io/client-js'); +const rest = restClient("API KEY", "https://api.polygon.io"); + +// https://polygon.io/docs/options/get_v3_reference_options_contracts__options_ticker +rest.reference.optionsContract("O:EVRI240119C00002500").then((data) => { + console.log(data); +}).catch(e => { + console.error('An error happened:', e); +}); diff --git a/examples/rest/options-contracts.js b/examples/rest/options-contracts.js new file mode 100644 index 0000000..9e34371 --- /dev/null +++ b/examples/rest/options-contracts.js @@ -0,0 +1,9 @@ +const { restClient } = require('@polygon.io/client-js'); +const rest = restClient("API KEY", "https://api.polygon.io"); + +// https://polygon.io/docs/options/get_v3_reference_options_contracts +rest.reference.optionsContracts().then((data) => { + console.log(data); +}).catch(e => { + console.error('An error happened:', e); +}); diff --git a/examples/rest/options-daily_open_close.js b/examples/rest/options-daily_open_close.js new file mode 100644 index 0000000..e1ea0f7 --- /dev/null +++ b/examples/rest/options-daily_open_close.js @@ -0,0 +1,9 @@ +const { restClient } = require('@polygon.io/client-js'); +const rest = restClient("API KEY", "https://api.polygon.io"); + +// https://polygon.io/docs/options/get_v1_open-close__optionsticker___date +rest.options.dailyOpenClose("O:SPY251219C00650000", "2023-03-31").then((data) => { + console.log(data); +}).catch(e => { + console.error('An error happened:', e); +}); diff --git a/examples/rest/options-exchanges.js b/examples/rest/options-exchanges.js new file mode 100644 index 0000000..82ea17d --- /dev/null +++ b/examples/rest/options-exchanges.js @@ -0,0 +1,9 @@ +const { restClient } = require('@polygon.io/client-js'); +const rest = restClient("API KEY", "https://api.polygon.io"); + +// https://polygon.io/docs/options/get_v3_reference_exchanges +rest.reference.exchanges({ asset_class: "options", limit: 1000 }).then((data) => { + console.log(data); +}).catch(e => { + console.error('An error happened:', e); +}); diff --git a/examples/rest/options-last_trade.js b/examples/rest/options-last_trade.js new file mode 100644 index 0000000..3976a2b --- /dev/null +++ b/examples/rest/options-last_trade.js @@ -0,0 +1,9 @@ +const { restClient } = require('@polygon.io/client-js'); +const rest = restClient("API KEY", "https://api.polygon.io"); + +// https://polygon.io/docs/options/get_v2_last_trade__optionsticker +rest.options.lastTrade("O:TSLA210903C00700000").then((data) => { + console.log(data); +}).catch(e => { + console.error('An error happened:', e); +}); diff --git a/examples/rest/options-market_holidays.js b/examples/rest/options-market_holidays.js new file mode 100644 index 0000000..819e2d0 --- /dev/null +++ b/examples/rest/options-market_holidays.js @@ -0,0 +1,9 @@ +const { restClient } = require('@polygon.io/client-js'); +const rest = restClient("API KEY", "https://api.polygon.io"); + +// https://polygon.io/docs/options/get_v1_marketstatus_upcoming +rest.reference.marketHolidays().then((data) => { + console.log(data); +}).catch(e => { + console.error('An error happened:', e); +}); diff --git a/examples/rest/options-market_status.js b/examples/rest/options-market_status.js new file mode 100644 index 0000000..4039265 --- /dev/null +++ b/examples/rest/options-market_status.js @@ -0,0 +1,9 @@ +const { restClient } = require('@polygon.io/client-js'); +const rest = restClient("API KEY", "https://api.polygon.io"); + +// https://polygon.io/docs/options/get_v1_marketstatus_now +rest.reference.marketStatus().then((data) => { + console.log(data); +}).catch(e => { + console.error('An error happened:', e); +}); diff --git a/examples/rest/options-previous_close.js b/examples/rest/options-previous_close.js new file mode 100644 index 0000000..f0d3c4c --- /dev/null +++ b/examples/rest/options-previous_close.js @@ -0,0 +1,9 @@ +const { restClient } = require('@polygon.io/client-js'); +const rest = restClient("API KEY", "https://api.polygon.io"); + +// https://polygon.io/docs/options/get_v2_aggs_ticker__optionsticker__prev +rest.options.previousClose("O:SPY251219C00650000").then((data) => { + console.log(data); +}).catch(e => { + console.error('An error happened:', e); +}); diff --git a/examples/rest/options-quotes.js b/examples/rest/options-quotes.js new file mode 100644 index 0000000..36d49fd --- /dev/null +++ b/examples/rest/options-quotes.js @@ -0,0 +1,9 @@ +const { restClient } = require('@polygon.io/client-js'); +const rest = restClient("API KEY", "https://api.polygon.io"); + +// https://polygon.io/docs/options/get_v3_quotes__optionsticker +rest.options.quotes("O:SPY241220P00720000").then((data) => { + console.log(data); +}).catch(e => { + console.error('An error happened:', e); +}); diff --git a/examples/rest/options-snapshots_option_contract.js b/examples/rest/options-snapshots_option_contract.js new file mode 100644 index 0000000..8719097 --- /dev/null +++ b/examples/rest/options-snapshots_option_contract.js @@ -0,0 +1,9 @@ +const { restClient } = require('@polygon.io/client-js'); +const rest = restClient("API KEY", "https://api.polygon.io"); + +// https://polygon.io/docs/options/get_v3_snapshot_options__underlyingasset___optioncontract +rest.options.snapshotOptionContract("AAPL", "O:AAPL230616C00150000").then((data) => { + console.log(data); +}).catch(e => { + console.error('An error happened:', e); +}); diff --git a/examples/rest/options-snapshots_options_chain.js b/examples/rest/options-snapshots_options_chain.js new file mode 100644 index 0000000..faa6c74 --- /dev/null +++ b/examples/rest/options-snapshots_options_chain.js @@ -0,0 +1,9 @@ +const { restClient } = require('@polygon.io/client-js'); +const rest = restClient("API KEY", "https://api.polygon.io"); + +// https://polygon.io/docs/options/get_v3_snapshot_options__underlyingasset +rest.options.snapshotOptionChain("AAPL").then((data) => { + console.log(data); +}).catch(e => { + console.error('An error happened:', e); +}); diff --git a/examples/rest/options-technical_indicators_ema.js b/examples/rest/options-technical_indicators_ema.js new file mode 100644 index 0000000..2d964ae --- /dev/null +++ b/examples/rest/options-technical_indicators_ema.js @@ -0,0 +1,9 @@ +const { restClient } = require('@polygon.io/client-js'); +const rest = restClient("API KEY", "https://api.polygon.io"); + +// https://polygon.io/docs/options/get_v1_indicators_ema__optionsticker +rest.options.ema("AAPL").then((data) => { + console.log(data); +}).catch(e => { + console.error('An error happened:', e); +}); diff --git a/examples/rest/options-technical_indicators_macd.js b/examples/rest/options-technical_indicators_macd.js new file mode 100644 index 0000000..2cd9d59 --- /dev/null +++ b/examples/rest/options-technical_indicators_macd.js @@ -0,0 +1,9 @@ +const { restClient } = require('@polygon.io/client-js'); +const rest = restClient("API KEY", "https://api.polygon.io"); + +// https://polygon.io/docs/options/get_v1_indicators_macd__optionsticker +rest.options.macd("O:SPY241220P00720000").then((data) => { + console.log(data); +}).catch(e => { + console.error('An error happened:', e); +}); diff --git a/examples/rest/options-technical_indicators_rsi.js b/examples/rest/options-technical_indicators_rsi.js new file mode 100644 index 0000000..05a7ef4 --- /dev/null +++ b/examples/rest/options-technical_indicators_rsi.js @@ -0,0 +1,9 @@ +const { restClient } = require('@polygon.io/client-js'); +const rest = restClient("API KEY", "https://api.polygon.io"); + +// https://polygon.io/docs/options/get_v1_indicators_rsi__optionsticker +rest.options.rsi("O:SPY241220P00720000").then((data) => { + console.log(data); +}).catch(e => { + console.error('An error happened:', e); +}); diff --git a/examples/rest/options-technical_indicators_sma.js b/examples/rest/options-technical_indicators_sma.js new file mode 100644 index 0000000..3718614 --- /dev/null +++ b/examples/rest/options-technical_indicators_sma.js @@ -0,0 +1,9 @@ +const { restClient } = require('@polygon.io/client-js'); +const rest = restClient("API KEY", "https://api.polygon.io"); + +// https://polygon.io/docs/options/get_v1_indicators_sma__optionsticker +rest.options.sma("O:SPY241220P00720000").then((data) => { + console.log(data); +}).catch(e => { + console.error('An error happened:', e); +}); diff --git a/examples/rest/options-ticker_details.js b/examples/rest/options-ticker_details.js new file mode 100644 index 0000000..897e8aa --- /dev/null +++ b/examples/rest/options-ticker_details.js @@ -0,0 +1,9 @@ +const { restClient } = require('@polygon.io/client-js'); +const rest = restClient("API KEY", "https://api.polygon.io"); + +// https://polygon.io/docs/options/get_v3_reference_tickers__ticker +rest.reference.tickerDetails("AAPL").then((data) => { + console.log(data); +}).catch(e => { + console.error('An error happened:', e); +}); diff --git a/examples/rest/options-ticker_news.js b/examples/rest/options-ticker_news.js new file mode 100644 index 0000000..00a8e8a --- /dev/null +++ b/examples/rest/options-ticker_news.js @@ -0,0 +1,9 @@ +const { restClient } = require('@polygon.io/client-js'); +const rest = restClient("API KEY", "https://api.polygon.io"); + +// https://polygon.io/docs/options/get_v2_reference_news +rest.reference.tickerNews("AAPL").then((data) => { + console.log(data); +}).catch(e => { + console.error('An error happened:', e); +}); diff --git a/examples/rest/options-tickers.js b/examples/rest/options-tickers.js new file mode 100644 index 0000000..50c3471 --- /dev/null +++ b/examples/rest/options-tickers.js @@ -0,0 +1,9 @@ +const { restClient } = require('@polygon.io/client-js'); +const rest = restClient("API KEY", "https://api.polygon.io"); + +// https://polygon.io/docs/options/get_v3_reference_tickers +rest.reference.tickers({ market: "stocks", limit: 1000 }).then((data) => { + console.log(data); +}).catch(e => { + console.error('An error happened:', e); +}); diff --git a/examples/rest/options-trades.js b/examples/rest/options-trades.js new file mode 100644 index 0000000..d97070b --- /dev/null +++ b/examples/rest/options-trades.js @@ -0,0 +1,9 @@ +const { restClient } = require('@polygon.io/client-js'); +const rest = restClient("API KEY", "https://api.polygon.io"); + +// https://polygon.io/docs/options/get_v3_trades__optionsticker +rest.options.trades("O:TSLA210903C00700000").then((data) => { + console.log(data); +}).catch(e => { + console.error('An error happened:', e); +}); diff --git a/examples/rest/stocks-aggregates_bars.js b/examples/rest/stocks-aggregates_bars.js new file mode 100644 index 0000000..3e0463c --- /dev/null +++ b/examples/rest/stocks-aggregates_bars.js @@ -0,0 +1,9 @@ +const { restClient } = require('@polygon.io/client-js'); +const rest = restClient("API KEY", "https://api.polygon.io"); + +// https://polygon.io/docs/stocks/get_v2_aggs_ticker__stocksticker__range__multiplier___timespan___from___to +rest.stocks.aggregates("AAPL", 1, "day", "2019-01-01", "2019-02-01").then((data) => { + console.log(data); +}).catch(e => { + console.error('An error happened:', e); +}); diff --git a/examples/rest/stocks-conditions.js b/examples/rest/stocks-conditions.js new file mode 100644 index 0000000..eb3d9b4 --- /dev/null +++ b/examples/rest/stocks-conditions.js @@ -0,0 +1,9 @@ +const { restClient } = require('@polygon.io/client-js'); +const rest = restClient("API KEY", "https://api.polygon.io"); + +// https://polygon.io/docs/stocks/get_v3_reference_conditions +rest.reference.conditions({ asset_class: "stocks", limit: 1000 }).then((data) => { + console.log(data); +}).catch(e => { + console.error('An error happened:', e); +}); diff --git a/examples/rest/stocks-daily_open_close.js b/examples/rest/stocks-daily_open_close.js new file mode 100644 index 0000000..c8ac3d2 --- /dev/null +++ b/examples/rest/stocks-daily_open_close.js @@ -0,0 +1,9 @@ +const { restClient } = require('@polygon.io/client-js'); +const rest = restClient("API KEY", "https://api.polygon.io"); + +// https://polygon.io/docs/stocks/get_v1_open-close__stocksticker___date +rest.stocks.dailyOpenClose("AAPL", "2023-03-31").then((data) => { + console.log(data); +}).catch(e => { + console.error('An error happened:', e); +}); diff --git a/examples/rest/stocks-dividends.js b/examples/rest/stocks-dividends.js new file mode 100644 index 0000000..b66cd52 --- /dev/null +++ b/examples/rest/stocks-dividends.js @@ -0,0 +1,9 @@ +const { restClient } = require('@polygon.io/client-js'); +const rest = restClient("API KEY", "https://api.polygon.io"); + +// https://polygon.io/docs/stocks/get_v3_reference_dividends +rest.reference.dividends("AAPL").then((data) => { + console.log(data); +}).catch(e => { + console.error('An error happened:', e); +}); diff --git a/examples/rest/stocks-exchanges.js b/examples/rest/stocks-exchanges.js new file mode 100644 index 0000000..036b8c3 --- /dev/null +++ b/examples/rest/stocks-exchanges.js @@ -0,0 +1,9 @@ +const { restClient } = require('@polygon.io/client-js'); +const rest = restClient("API KEY", "https://api.polygon.io"); + +// https://polygon.io/docs/stocks/get_v3_reference_exchanges +rest.reference.exchanges({ asset_class: "stocks" }).then((data) => { + console.log(data); +}).catch(e => { + console.error('An error happened:', e); +}); diff --git a/examples/rest/stocks-grouped_daily_bars.js b/examples/rest/stocks-grouped_daily_bars.js new file mode 100644 index 0000000..95a94d1 --- /dev/null +++ b/examples/rest/stocks-grouped_daily_bars.js @@ -0,0 +1,9 @@ +const { restClient } = require('@polygon.io/client-js'); +const rest = restClient("API KEY", "https://api.polygon.io"); + +// https://polygon.io/docs/stocks/get_v2_aggs_grouped_locale_us_market_stocks__date +rest.stocks.aggregatesGroupedDaily("2023-03-31").then((data) => { + console.log(data); +}).catch(e => { + console.error('An error happened:', e); +}); diff --git a/examples/rest/stocks-last_quote.js b/examples/rest/stocks-last_quote.js new file mode 100644 index 0000000..c32f081 --- /dev/null +++ b/examples/rest/stocks-last_quote.js @@ -0,0 +1,9 @@ +const { restClient } = require('@polygon.io/client-js'); +const rest = restClient("API KEY", "https://api.polygon.io"); + +// https://polygon.io/docs/stocks/get_v2_last_nbbo__stocksticker +rest.stocks.lastQuote("AAPL").then((data) => { + console.log(data); +}).catch(e => { + console.error('An error happened:', e); +}); diff --git a/examples/rest/stocks-last_trade.js b/examples/rest/stocks-last_trade.js new file mode 100644 index 0000000..3676c3b --- /dev/null +++ b/examples/rest/stocks-last_trade.js @@ -0,0 +1,9 @@ +const { restClient } = require('@polygon.io/client-js'); +const rest = restClient("API KEY", "https://api.polygon.io"); + +// https://polygon.io/docs/stocks/get_v2_last_trade__stocksticker +rest.stocks.lastTrade("AAPL").then((data) => { + console.log(data); +}).catch(e => { + console.error('An error happened:', e); +}); diff --git a/examples/rest/stocks-market_holidays.js b/examples/rest/stocks-market_holidays.js new file mode 100644 index 0000000..d0d99ae --- /dev/null +++ b/examples/rest/stocks-market_holidays.js @@ -0,0 +1,9 @@ +const { restClient } = require('@polygon.io/client-js'); +const rest = restClient("API KEY", "https://api.polygon.io"); + +// https://polygon.io/docs/stocks/get_v1_marketstatus_upcoming +rest.reference.marketHolidays().then((data) => { + console.log(data); +}).catch(e => { + console.error('An error happened:', e); +}); diff --git a/examples/rest/stocks-market_status.js b/examples/rest/stocks-market_status.js new file mode 100644 index 0000000..01f5574 --- /dev/null +++ b/examples/rest/stocks-market_status.js @@ -0,0 +1,9 @@ +const { restClient } = require('@polygon.io/client-js'); +const rest = restClient("API KEY", "https://api.polygon.io"); + +// https://polygon.io/docs/stocks/get_v1_marketstatus_now +rest.reference.marketStatus().then((data) => { + console.log(data); +}).catch(e => { + console.error('An error happened:', e); +}); diff --git a/examples/rest/stocks-previous_close.js b/examples/rest/stocks-previous_close.js new file mode 100644 index 0000000..2db31d3 --- /dev/null +++ b/examples/rest/stocks-previous_close.js @@ -0,0 +1,9 @@ +const { restClient } = require('@polygon.io/client-js'); +const rest = restClient("API KEY", "https://api.polygon.io"); + +// https://polygon.io/docs/stocks/get_v2_aggs_ticker__stocksticker__prev +rest.stocks.previousClose("AAPL").then((data) => { + console.log(data); +}).catch(e => { + console.error('An error happened:', e); +}); diff --git a/examples/rest/stocks-quotes.js b/examples/rest/stocks-quotes.js new file mode 100644 index 0000000..f60dd7f --- /dev/null +++ b/examples/rest/stocks-quotes.js @@ -0,0 +1,9 @@ +const { restClient } = require('@polygon.io/client-js'); +const rest = restClient("API KEY", "https://api.polygon.io"); + +// https://polygon.io/docs/stocks/get_v3_quotes__stockticker +rest.stocks.quotes("HCP").then((data) => { + console.log(data); +}).catch(e => { + console.error('An error happened:', e); +}); diff --git a/examples/rest/stocks-snapshots_all.js b/examples/rest/stocks-snapshots_all.js new file mode 100644 index 0000000..7efc9dc --- /dev/null +++ b/examples/rest/stocks-snapshots_all.js @@ -0,0 +1,9 @@ +const { restClient } = require('@polygon.io/client-js'); +const rest = restClient("API KEY", "https://api.polygon.io"); + +// https://polygon.io/docs/stocks/get_v2_snapshot_locale_us_markets_stocks_tickers +rest.stocks.snapshotAllTickers().then((data) => { + console.log(data); +}).catch(e => { + console.error('An error happened:', e); +}); diff --git a/examples/rest/stocks-snapshots_gainers_losers.js b/examples/rest/stocks-snapshots_gainers_losers.js new file mode 100644 index 0000000..1b30f0a --- /dev/null +++ b/examples/rest/stocks-snapshots_gainers_losers.js @@ -0,0 +1,17 @@ +const { restClient } = require('@polygon.io/client-js'); +const rest = restClient("API KEY", "https://api.polygon.io"); + +// https://polygon.io/docs/stocks/get_v2_snapshot_locale_us_markets_stocks__direction +// gainers +rest.stocks.snapshotGainersLosers("gainers").then((data) => { + console.log(data); +}).catch(e => { + console.error('An error happened:', e); +}); + +// losers +rest.stocks.snapshotGainersLosers("losers").then((data) => { + console.log(data); +}).catch(e => { + console.error('An error happened:', e); +}); diff --git a/examples/rest/stocks-snapshots_ticker.js b/examples/rest/stocks-snapshots_ticker.js new file mode 100644 index 0000000..25083ad --- /dev/null +++ b/examples/rest/stocks-snapshots_ticker.js @@ -0,0 +1,9 @@ +const { restClient } = require('@polygon.io/client-js'); +const rest = restClient("API KEY", "https://api.polygon.io"); + +// https://polygon.io/docs/stocks/get_v2_snapshot_locale_us_markets_stocks_tickers__stocksticker +rest.stocks.snapshotTicker("AAPL").then((data) => { + console.log(data); +}).catch(e => { + console.error('An error happened:', e); +}); diff --git a/examples/rest/stocks-stock_financials.js b/examples/rest/stocks-stock_financials.js new file mode 100644 index 0000000..599dc96 --- /dev/null +++ b/examples/rest/stocks-stock_financials.js @@ -0,0 +1,9 @@ +const { restClient } = require('@polygon.io/client-js'); +const rest = restClient("API KEY", "https://api.polygon.io"); + +// https://polygon.io/docs/stocks/get_vx_reference_financials +rest.reference.stockFinancials("AAPL").then((data) => { + console.log(data); +}).catch(e => { + console.error('An error happened:', e); +}); diff --git a/examples/rest/stocks-stock_splits.js b/examples/rest/stocks-stock_splits.js new file mode 100644 index 0000000..4e2e6e8 --- /dev/null +++ b/examples/rest/stocks-stock_splits.js @@ -0,0 +1,9 @@ +const { restClient } = require('@polygon.io/client-js'); +const rest = restClient("API KEY", "https://api.polygon.io"); + +// https://polygon.io/docs/stocks/get_v3_reference_splits +rest.reference.stockSplits("AAPL").then((data) => { + console.log(data); +}).catch(e => { + console.error('An error happened:', e); +}); diff --git a/examples/rest/stocks-technical_indicators_ema.js b/examples/rest/stocks-technical_indicators_ema.js new file mode 100644 index 0000000..f8811aa --- /dev/null +++ b/examples/rest/stocks-technical_indicators_ema.js @@ -0,0 +1,9 @@ +const { restClient } = require('@polygon.io/client-js'); +const rest = restClient("API KEY", "https://api.polygon.io"); + +// https://polygon.io/docs/stocks/get_v1_indicators_ema__stockticker +rest.stocks.ema("AAPL").then((data) => { + console.log(data); +}).catch(e => { + console.error('An error happened:', e); +}); diff --git a/examples/rest/stocks-technical_indicators_macd.js b/examples/rest/stocks-technical_indicators_macd.js new file mode 100644 index 0000000..5f96c54 --- /dev/null +++ b/examples/rest/stocks-technical_indicators_macd.js @@ -0,0 +1,9 @@ +const { restClient } = require('@polygon.io/client-js'); +const rest = restClient("API KEY", "https://api.polygon.io"); + +// https://polygon.io/docs/stocks/get_v1_indicators_macd__stockticker +rest.stocks.macd("AAPL").then((data) => { + console.log(data); +}).catch(e => { + console.error('An error happened:', e); +}); diff --git a/examples/rest/stocks-technical_indicators_rsi.js b/examples/rest/stocks-technical_indicators_rsi.js new file mode 100644 index 0000000..90d90d0 --- /dev/null +++ b/examples/rest/stocks-technical_indicators_rsi.js @@ -0,0 +1,9 @@ +const { restClient } = require('@polygon.io/client-js'); +const rest = restClient("API KEY", "https://api.polygon.io"); + +// https://polygon.io/docs/stocks/get_v1_indicators_rsi__stockticker +rest.stocks.rsi("AAPL").then((data) => { + console.log(data); +}).catch(e => { + console.error('An error happened:', e); +}); diff --git a/examples/rest/stocks-technical_indicators_sma.js b/examples/rest/stocks-technical_indicators_sma.js new file mode 100644 index 0000000..e0e4909 --- /dev/null +++ b/examples/rest/stocks-technical_indicators_sma.js @@ -0,0 +1,9 @@ +const { restClient } = require('@polygon.io/client-js'); +const rest = restClient("API KEY", "https://api.polygon.io"); + +// https://polygon.io/docs/stocks/get_v1_indicators_sma__stockticker +rest.stocks.sma("AAPL").then((data) => { + console.log(data); +}).catch(e => { + console.error('An error happened:', e); +}); diff --git a/examples/rest/stocks-ticker_details.js b/examples/rest/stocks-ticker_details.js new file mode 100644 index 0000000..fca6cf0 --- /dev/null +++ b/examples/rest/stocks-ticker_details.js @@ -0,0 +1,9 @@ +const { restClient } = require('@polygon.io/client-js'); +const rest = restClient("API KEY", "https://api.polygon.io"); + +// https://polygon.io/docs/stocks/get_v3_reference_tickers__ticker +rest.reference.tickerDetails("AAPL").then((data) => { + console.log(data); +}).catch(e => { + console.error('An error happened:', e); +}); diff --git a/examples/rest/stocks-ticker_news.js b/examples/rest/stocks-ticker_news.js new file mode 100644 index 0000000..2a58e45 --- /dev/null +++ b/examples/rest/stocks-ticker_news.js @@ -0,0 +1,9 @@ +const { restClient } = require('@polygon.io/client-js'); +const rest = restClient("API KEY", "https://api.polygon.io"); + +// https://polygon.io/docs/stocks/get_v2_reference_news +rest.reference.tickerNews("AAPL").then((data) => { + console.log(data); +}).catch(e => { + console.error('An error happened:', e); +}); diff --git a/examples/rest/stocks-ticker_types.js b/examples/rest/stocks-ticker_types.js new file mode 100644 index 0000000..f264b03 --- /dev/null +++ b/examples/rest/stocks-ticker_types.js @@ -0,0 +1,9 @@ +const { restClient } = require('@polygon.io/client-js'); +const rest = restClient("API KEY", "https://api.polygon.io"); + +// https://polygon.io/docs/stocks/get_v3_reference_tickers_types +rest.reference.tickerTypes({ asset_class: "stocks"}).then((data) => { + console.log(data); +}).catch(e => { + console.error('An error happened:', e); +}); diff --git a/examples/rest/stocks-tickers.js b/examples/rest/stocks-tickers.js new file mode 100644 index 0000000..f4dc919 --- /dev/null +++ b/examples/rest/stocks-tickers.js @@ -0,0 +1,9 @@ +const { restClient } = require('@polygon.io/client-js'); +const rest = restClient("API KEY", "https://api.polygon.io"); + +// https://polygon.io/docs/stocks/get_v3_reference_tickers +rest.reference.tickers({ market: "stocks", limit: 1000 }).then((data) => { + console.log(data); +}).catch(e => { + console.error('An error happened:', e); +}); diff --git a/examples/rest/stocks-trades.js b/examples/rest/stocks-trades.js new file mode 100644 index 0000000..c2e507f --- /dev/null +++ b/examples/rest/stocks-trades.js @@ -0,0 +1,9 @@ +const { restClient } = require('@polygon.io/client-js'); +const rest = restClient("API KEY", "https://api.polygon.io"); + +// https://polygon.io/docs/stocks/get_v3_trades__stockticker +rest.stocks.trades("HCP").then((data) => { + console.log(data); +}).catch(e => { + console.error('An error happened:', e); +}); From 470a946230ba389949a4d8cce6bc541d387ddacf Mon Sep 17 00:00:00 2001 From: justinpolygon <123573436+justinpolygon@users.noreply.github.com> Date: Mon, 17 Apr 2023 06:38:03 -0700 Subject: [PATCH 05/39] Update README.md (#150) * Update README.md Updated the readme to: - Match the Python and Go client libraries - Link to the example code snippets - Provide more examples * Update README.md Updated header text and first example. --- README.md | 93 +++++++++++++++++++++++++++++-------------------------- 1 file changed, 49 insertions(+), 44 deletions(-) diff --git a/README.md b/README.md index 4bab0b2..5d86ca7 100644 --- a/README.md +++ b/README.md @@ -1,68 +1,76 @@ -# [polygon.io](https://polygon.io) +# Polygon JS Client [![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier) -## Upgrading to Version 7 +The official JS client library for the [Polygon](https://polygon.io/) REST and WebSocket API. Explore the [REST API](https://polygon.io/docs/stocks/getting-started) documentation and many example [code snippets](./examples/). Please see the [Release Notes](./CHANGELOG.md) for instructions on upgrading. To generate the package documentation please run `npm run generate-doc`. -See the [Release Notes](./CHANGELOG.md) for instructions on upgrading to Version 7. +## Getting the client -## Install +To get started, you'll need to install the client library: ```bash npm install --save @polygon.io/client-js ``` -## usage +Next, create a new client with your [API key](https://polygon.io/dashboard/signup). -### Authentication - -- call the desired client with your api key to initialize it - -```typescript -import { polygonClient, restClient, websocketClient } from "@polygon.io/client-js"; +```javascript +const { restClient } = require('@polygon.io/client-js'); const rest = restClient("API KEY"); - -// you can use the api now - -rest.forex - .previousClose("C:EURUSD") - .then(/* your success handler */) - .catch(/* your error handler*/); ``` -### [REST API](https://polygon.io/docs/stocks/getting-started) +## Using the client -- import the rest submodule - -```typescript -import { restClient } from "@polygon.io/client-js"; - -const rest = restClient("API KEY"); +After creating the client, making calls to the Polygon API is easy. For example, here's how to get aggregates (bars): -rest.forex.previousClose("C:EURUSD").then(/* your success handler */); +```javascript +rest.stocks.aggregates("AAPL", 1, "day", "2023-01-01", "2023-04-14").then((data) => { + console.log(data); +}).catch(e => { + console.error('An error happened:', e); +}); ``` -- import a specific submodule - -```typescript -import { referenceClient } from "@polygon.io/client-js"; +Or, maybe you want to get the last trades or quotes for a ticker: + +```javascript +// last trade +rest.stocks.lastTrade("AAPL").then((data) => { + console.log(data); +}).catch(e => { + console.error('An error happened:', e); +}); + +// last quote (NBBO) +rest.stocks.lastQuote("AAPL").then((data) => { + console.log(data); +}).catch(e => { + console.error('An error happened:', e); +}); +``` -const reference = referenceClient("API KEY"); +Finally, maybe you want a market-wide snapshot of all tickers: -reference.tickers().then(/* your success handler */); -reference.conditions({ asset_class: 'stocks', data_type: 'trades', sort: 'id' }).then(/* your success handler */) +```javascript +rest.stocks.snapshotAllTickers().then((data) => { + console.log(data); +}).catch(e => { + console.error('An error happened:', e); +}); ``` +See [full examples](./examples/rest/) for more details on how to use this client effectively. -#### [For Launchpad Examples and Usage, see Polygon Launchpad Examples](examples/rest/launchpad/README.md) +## Launchpad Usage -### [Websocket](https://polygon.io/docs/stocks/ws_getting-started) +Users of the Launchpad product will need to pass in certain headers in order to make API requests. Example can be found [here](./examples/rest/launchpad/README.md). -You can get preauthenticated [websocket clients](https://www.npmjs.com/package/websocket) for the 3 topics. +## WebSocket Client -```typescript -import { websocketClient } from "@polygon.io/client-js"; +Import the [Websocket](https://polygon.io/docs/stocks/ws_getting-started) client and models packages to get started. You can get preauthenticated [websocket clients](https://www.npmjs.com/package/websocket) for the 3 topics. +```javascript +import { websocketClient } from "@polygon.io/client-js"; const stocksWS = websocketClient("API KEY").stocks(); stocksWS.onmessage = ({data}) => { @@ -82,11 +90,8 @@ stocksWS.onmessage = ({data}) => { stocksWS.send({ action: "subscribe", params: "T.MSFT" }); ``` +See [full examples](./examples/websocket/) for more details on how to use this client effectively. -### documentation +## Contributing -- Generate the package documentation - -```bash -npm run generate-doc -``` +If you found a bug or have an idea for a new feature, please first discuss it with us by [submitting a new issue](https://github.com/polygon-io/client-js/issues/new/choose). We will respond to issues within at most 3 weeks. We're also open to volunteers if you want to submit a PR for any open issues but please discuss it with us beforehand. PRs that aren't linked to an existing issue or discussed with us ahead of time will generally be declined. If you have more general feedback or want to discuss using this client with other users, feel free to reach out on our [Slack channel](https://polygon-io.slack.com/archives/C03FCSBSAFL). From dec95b3088a11a6ddf29b9cc1218680e3e40c2d3 Mon Sep 17 00:00:00 2001 From: justinpolygon <123573436+justinpolygon@users.noreply.github.com> Date: Tue, 18 Apr 2023 11:30:00 -0700 Subject: [PATCH 06/39] Update README.md (#152) * Update README.md Updated the readme for better formatting and included a link to the new getting started tutorial. * Update README.md Fix examples path --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 5d86ca7..dc14f38 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,9 @@ [![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier) -The official JS client library for the [Polygon](https://polygon.io/) REST and WebSocket API. Explore the [REST API](https://polygon.io/docs/stocks/getting-started) documentation and many example [code snippets](./examples/). Please see the [Release Notes](./CHANGELOG.md) for instructions on upgrading. To generate the package documentation please run `npm run generate-doc`. +Welcome to the official JS client library for the [Polygon](https://polygon.io/) REST and WebSocket API. To get started, please see the [Getting Started](https://polygon.io/docs/stocks/getting-started) section in our documentation, view the [examples](./examples/) directory for code snippets, or the [blog post](https://polygon.io/blog/javascript-stock-market-data/) with video tutorials to learn more. To generate the package documentation please run `npm run generate-doc`. + +For upgrade instructions please see the [Release Notes](./CHANGELOG.md). ## Getting the client From 0dd343eb347fc1b37bd5b5f8f0f10583eb81deb1 Mon Sep 17 00:00:00 2001 From: justinpolygon <123573436+justinpolygon@users.noreply.github.com> Date: Wed, 19 Apr 2023 06:35:25 -0700 Subject: [PATCH 07/39] Update index.js (#151) Update the WebSocket example to support forex and stocks for aggregates, trades, and quotes. This is just stubbed in so people can turn on and off things as needed. --- examples/websocket/index.js | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/examples/websocket/index.js b/examples/websocket/index.js index 42f5fbc..3d531e9 100644 --- a/examples/websocket/index.js +++ b/examples/websocket/index.js @@ -1,14 +1,30 @@ - const WebSocket = require('ws') - const APIKEY = process.env.POLY_API_KEY || 'YOUR_API_KEY' -const ws = new WebSocket('wss://socket.polygon.io/forex') + +// Connection Type: +const ws = new WebSocket('wss://delayed.polygon.io/stocks') // stocks 15-min delay +//const ws = new WebSocket('wss://socket.polygon.io/stocks') // stocks real-time +//const ws = new WebSocket('wss://socket.polygon.io/forex') // forex // Connection Opened: ws.on('open', () => { console.log('Connected!') ws.send(`{"action":"auth","params":"${APIKEY}"}`) - ws.send(`{"action":"subscribe","params":"C.AUD/USD,C.USD/EUR,C.USD/JPY"}`) + + // forex + //ws.send(`{"action":"subscribe","params":"C.AUD/USD,C.USD/EUR,C.USD/JPY"}`) + + // aggregates + //ws.send(`{"action":"subscribe","params":"AM.*"}`) // min + ws.send(`{"action":"subscribe","params":"A.*"}`) // sec + + // trades + //ws.send(`{"action":"subscribe","params":"T.*"}`) + //ws.send(`{"action":"subscribe","params":"T.TSLA"}`) + + // quotes + //ws.send(`{"action":"subscribe","params":"Q.*"}`) + //ws.send(`{"action":"subscribe","params":"Q.TSLA"}`) }) // Per message packet: @@ -18,7 +34,7 @@ ws.on('message', ( data ) => { if( msg.ev === 'status' ){ return console.log('Status Update:', msg.message) } - console.log('Tick:', msg) + console.log(msg) }) }) From 645c7792cf90a7e58a6fd476559ebc7d31270173 Mon Sep 17 00:00:00 2001 From: WilliamConnatser <43946230+WilliamConnatser@users.noreply.github.com> Date: Wed, 19 Apr 2023 09:37:36 -0400 Subject: [PATCH 08/39] Updates options snapshot response type SnapshotInfo (#148) * update options snapshot response type SnapshotInfo * saved without formatting to match upstream repo format * changed SnapshotLastTrade to an interface for consistency * made all SnapshotLastTrade interface properties optional --- src/rest/options/snapshots.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/rest/options/snapshots.ts b/src/rest/options/snapshots.ts index 6499ba4..52b92a3 100644 --- a/src/rest/options/snapshots.ts +++ b/src/rest/options/snapshots.ts @@ -41,6 +41,15 @@ export interface SnapshotLastQuote { timeframe?: number; } +export interface SnapshotLastTrade { + conditions?: number[]; + exchange?: number; + price?: number; + sip_timestamp?: number; + size?: number; + timeframe?: string; +} + export interface SnapshotUnderlyingAsset { change_to_break_even?: number; last_updated?: number; @@ -57,6 +66,7 @@ export interface SnapshotInfo { greeks?: SnapshotGreeks; implied_volatility?: number; last_quote?: SnapshotLastQuote; + last_trade?: SnapshotLastTrade; open_interest?: number; underlying_asset?: SnapshotUnderlyingAsset; } From 666fa93dc44080f13137d5382032fa5da90aac34 Mon Sep 17 00:00:00 2001 From: Tyler Date: Wed, 19 Apr 2023 09:12:32 -0500 Subject: [PATCH 09/39] Prevents publishing examples to npm (#149) * fix: prevents /examples, .mocharc, CHANGELOG.md, and README.md from being published to npm to save some bytes * fix: removes CHANGELOG.md and README.md from npmignore since npm will always add them --- .npmignore | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.npmignore b/.npmignore index 8eaff8b..9218700 100644 --- a/.npmignore +++ b/.npmignore @@ -1,4 +1,6 @@ /src* /websocket_example* /.circleci* -tsconfig.json \ No newline at end of file +tsconfig.json +/examples +.mocharc.json \ No newline at end of file From d405c958c6cfc7103d04b5c87c11d4b312c3f7c7 Mon Sep 17 00:00:00 2001 From: Andrew Bailey Date: Wed, 19 Apr 2023 10:22:47 -0400 Subject: [PATCH 10/39] Bump version (#153) --- package-lock.json | 6 +++--- package.json | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/package-lock.json b/package-lock.json index 91e8b5e..c2a47bc 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,15 +1,15 @@ { "name": "@polygon.io/client-js", - "version": "7.2.0", + "version": "7.2.1", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@polygon.io/client-js", - "version": "7.2.0", + "version": "7.2.1", "license": "MIT", "workspaces": [ - "./lib/*", + "./dist/*", "./sandbox" ], "dependencies": { diff --git a/package.json b/package.json index 4441de0..25b186d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@polygon.io/client-js", - "version": "7.2.0", + "version": "7.2.1", "description": "Isomorphic Javascript client for Polygon.io Stocks, Forex, and Crypto APIs", "main": "dist/main.js", "types": "dist/main.d.ts", From 3189b1e636c3a31a9b647564045783a36557318e Mon Sep 17 00:00:00 2001 From: Andrew Bailey Date: Wed, 19 Apr 2023 10:30:28 -0400 Subject: [PATCH 11/39] Update .npmignore (#154) --- .npmignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.npmignore b/.npmignore index 9218700..b9a5912 100644 --- a/.npmignore +++ b/.npmignore @@ -1,4 +1,5 @@ /src* +/lib* /websocket_example* /.circleci* tsconfig.json From 856c83d0db086531c9f316b61513c7c1ba3bbcfe Mon Sep 17 00:00:00 2001 From: Andrew Bailey Date: Wed, 19 Apr 2023 10:32:37 -0400 Subject: [PATCH 12/39] 7.2.2 (#155) --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index c2a47bc..e78f068 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@polygon.io/client-js", - "version": "7.2.1", + "version": "7.2.2", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@polygon.io/client-js", - "version": "7.2.1", + "version": "7.2.2", "license": "MIT", "workspaces": [ "./dist/*", diff --git a/package.json b/package.json index 25b186d..589fde8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@polygon.io/client-js", - "version": "7.2.1", + "version": "7.2.2", "description": "Isomorphic Javascript client for Polygon.io Stocks, Forex, and Crypto APIs", "main": "dist/main.js", "types": "dist/main.d.ts", From 01698ae27aead407022f1da2729dd083136fc705 Mon Sep 17 00:00:00 2001 From: Katie Adams <64220601+timetraveler328@users.noreply.github.com> Date: Mon, 15 May 2023 13:57:42 -0400 Subject: [PATCH 13/39] Release/v7.2.3 (#159) * Update header types and export types from request file (#158) * Changelog * 7.2.3 --- CHANGELOG.md | 14 ++++++++++++++ package-lock.json | 4 ++-- package.json | 3 ++- src/rest/index.ts | 1 + src/rest/transport/request.ts | 10 +++++----- 5 files changed, 24 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a0fdb08..3307a61 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,17 @@ +## [7.2.3](https://github.com/polygon-io/client-js/compare/v7.2.2...v7.2.3) (2023-05-15) +### Bug Fixes +* Fix typing issue with optional headers Launchpad Typescript definitions +* Export types from requests file +* Make Launchpad Headers optional to support metered product + +## [7.2.2](https://github.com/polygon-io/client-js/compare/v7.2.1...v7.2.2) (2023-04-19) +### Bug Fixes +* Remove examples and unneccesary files from npm package + +## [7.2.1](https://github.com/polygon-io/client-js/compare/v7.2.0...v7.2.1) (2023-04-12) +### Bug Fixes +* Update snapshot response type to reflect recent additions + ## [7.2.0](https://github.com/polygon-io/client-js/compare/v7.1.1...v7.2.0) (2023-04-07) ### New Feature * Support Dual Module Formats so that this package can be used with CommonJS diff --git a/package-lock.json b/package-lock.json index e78f068..c0071dd 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@polygon.io/client-js", - "version": "7.2.2", + "version": "7.2.3", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@polygon.io/client-js", - "version": "7.2.2", + "version": "7.2.3", "license": "MIT", "workspaces": [ "./dist/*", diff --git a/package.json b/package.json index 589fde8..28765a4 100644 --- a/package.json +++ b/package.json @@ -1,11 +1,12 @@ { "name": "@polygon.io/client-js", - "version": "7.2.2", + "version": "7.2.3", "description": "Isomorphic Javascript client for Polygon.io Stocks, Forex, and Crypto APIs", "main": "dist/main.js", "types": "dist/main.d.ts", "type": "module", "exports": { + "types": "./dist/main.d.ts", "import": "./dist/main.js", "require": "./dist/main.cjs" }, diff --git a/src/rest/index.ts b/src/rest/index.ts index af3eeff..78a6304 100644 --- a/src/rest/index.ts +++ b/src/rest/index.ts @@ -11,6 +11,7 @@ export * from "./reference/index.js"; export * from "./options/index.js"; export * from "./stocks/index.js"; export * from "./indices/index.js"; +export * from "./transport/request.js"; // ensure types are exported export interface IRestClient { crypto: ICryptoClient; diff --git a/src/rest/transport/request.ts b/src/rest/transport/request.ts index 490b952..c517048 100644 --- a/src/rest/transport/request.ts +++ b/src/rest/transport/request.ts @@ -5,15 +5,15 @@ export interface IPolygonQuery { [key: string]: string | number | boolean | undefined; } -export interface IPolygonEdgeHeaders extends Record { - 'X-Polygon-Edge-ID': string; - 'X-Polygon-Edge-IP-Address': string; +export interface IPolygonEdgeHeaders extends Partial> { + 'X-Polygon-Edge-ID'?: string; + 'X-Polygon-Edge-IP-Address'?: string; 'X-Polygon-Edge-User-Agent'?: string; } -export type IHeaders = IPolygonEdgeHeaders | Record +export type IHeaders = IPolygonEdgeHeaders | HeadersInit -export interface IRequestInit extends RequestInit { +export interface IRequestInit extends Omit { headers?: IHeaders } From 28ad09de74271f9560dfc412558f71544949b21e Mon Sep 17 00:00:00 2001 From: justinpolygon <123573436+justinpolygon@users.noreply.github.com> Date: Mon, 22 May 2023 10:39:24 -0700 Subject: [PATCH 14/39] Update snapshot min to support n and t (#160) --- src/rest/crypto/snapshots.ts | 2 ++ src/rest/forex/snapshots.ts | 2 ++ src/rest/stocks/snapshots.ts | 2 ++ 3 files changed, 6 insertions(+) diff --git a/src/rest/crypto/snapshots.ts b/src/rest/crypto/snapshots.ts index c382ee4..bd21daf 100644 --- a/src/rest/crypto/snapshots.ts +++ b/src/rest/crypto/snapshots.ts @@ -25,6 +25,8 @@ export interface SnapshotMin { o?: number; v?: number; vw?: number; + t?: number; + n?: number; } export interface SnapshotPrevDay { diff --git a/src/rest/forex/snapshots.ts b/src/rest/forex/snapshots.ts index 68a4ade..4fcf9bc 100644 --- a/src/rest/forex/snapshots.ts +++ b/src/rest/forex/snapshots.ts @@ -21,6 +21,8 @@ export interface SnapshotMin { l?: number; o?: number; v?: number; + t?: number; + n?: number; } export interface SnapshotPrevDay { diff --git a/src/rest/stocks/snapshots.ts b/src/rest/stocks/snapshots.ts index 409f59f..7446a62 100644 --- a/src/rest/stocks/snapshots.ts +++ b/src/rest/stocks/snapshots.ts @@ -43,6 +43,8 @@ export interface SnapshotPrevDay { o?: number; v?: number; vw?: number; + t?: number; + n?: number; } export interface SnapshotInfo { From 23cdeda548d5664b94f61c8b49df55ab0d3ea583 Mon Sep 17 00:00:00 2001 From: WilliamConnatser <43946230+WilliamConnatser@users.noreply.github.com> Date: Wed, 31 May 2023 13:58:17 -0400 Subject: [PATCH 15/39] export and update options types (#156) --- src/websockets/index.ts | 3 ++- src/websockets/options/index.ts | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/websockets/index.ts b/src/websockets/index.ts index 158d02f..93350d4 100644 --- a/src/websockets/index.ts +++ b/src/websockets/index.ts @@ -1,7 +1,7 @@ import * as websocket from "websocket"; import { getCryptoWebsocket } from "./crypto/index.js"; import { getForexWebsocket } from "./forex/index.js"; -import { getIndicesWebsocket } from "./indices/index.js" +import { getIndicesWebsocket } from "./indices/index.js"; import { getOptionsWebsocket } from "./options/index.js"; import { getStocksWebsocket } from "./stocks/index.js"; @@ -9,6 +9,7 @@ export * from "./forex/index.js"; export * from "./indices/index.js"; export * from "./stocks/index.js"; export * from "./crypto/index.js"; +export * from "./options/index.js"; export interface IWebsocketClient { crypto: () => websocket.w3cwebsocket; diff --git a/src/websockets/options/index.ts b/src/websockets/options/index.ts index 9720e7e..25d69e6 100644 --- a/src/websockets/options/index.ts +++ b/src/websockets/options/index.ts @@ -27,8 +27,22 @@ export interface ITradeOptionsEvent { s: number; // Trade Size c: number[]; // Trade Conditions t: number; // Trade Timestamp ( Unix MS ) + q: number; // Sequence Number ( The sequence in which events ocurred ) } +export type IQuoteOptionsEvent = { + ev: string; // Event Type + sym: string; // Symbol Ticker + bx: number; // Bid Exchange ID + ax: number; // Ask Exchange ID + bp: number; // Bid Price + ap: number; // Ask Price + bs: number; // Bid Size + as: number; // Ask size + t: number; // Quote Timestamp ( Unix MS ) + q: number; // Sequence Number ( The sequence in which events ocurred ) +}; + export const getOptionsWebsocket = ( apiKey: string, apiBase = "wss://socket.polygon.io" From 8ed0fb95917f91ae58f6cf9594a7e68b886a0d44 Mon Sep 17 00:00:00 2001 From: Katie Adams <64220601+timetraveler328@users.noreply.github.com> Date: Wed, 14 Jun 2023 10:44:29 -0400 Subject: [PATCH 16/39] Universal snapshot (#162) * Added Universal Snapshot support * Clean up demo with correct docs * Fix linting on example * Move universal snapshot to price data clients --------- Co-authored-by: justinpolygon <123573436+justinpolygon@users.noreply.github.com> --- examples/rest/universal-snapshot.js | 32 ++++++++ src/rest/crypto/index.test.ts | 10 +++ src/rest/crypto/index.ts | 6 +- src/rest/forex/index.test.ts | 10 +++ src/rest/forex/index.ts | 6 +- src/rest/options/index.test.ts | 10 +++ src/rest/options/index.ts | 6 +- src/rest/reference/index.ts | 2 +- src/rest/stocks/index.test.ts | 10 +++ src/rest/stocks/index.ts | 6 +- src/rest/universal/universalSnapshot.ts | 98 +++++++++++++++++++++++++ 11 files changed, 191 insertions(+), 5 deletions(-) create mode 100644 examples/rest/universal-snapshot.js create mode 100644 src/rest/universal/universalSnapshot.ts diff --git a/examples/rest/universal-snapshot.js b/examples/rest/universal-snapshot.js new file mode 100644 index 0000000..a2bd4df --- /dev/null +++ b/examples/rest/universal-snapshot.js @@ -0,0 +1,32 @@ +const { restClient } = require('@polygon.io/client-js'); +const rest = restClient("API KEY", "https://api.polygon.io"); + +// You can access the universal snapshot endpoint from any asset class client + +// https://polygon.io/docs/stocks/get_v3_snapshot +rest.stocks.universalSnapshot({ "ticker.any_of": "NCLH,O:SPY250321C00380000,C:EURUSD,X:BTCUSD,I:SPX" }).then((data) => { + console.log(data); +}).catch(e => { + console.error('An error happened:', e); +}); + +// https://polygon.io/docs/crypto/get_v3_snapshot +rest.crypto.universalSnapshot({ "ticker.any_of": "NCLH,O:SPY250321C00380000,C:EURUSD,X:BTCUSD,I:SPX" }).then((data) => { + console.log(data); +}).catch(e => { + console.error('An error happened:', e); +}); + +// https://polygon.io/docs/options/get_v3_snapshot +rest.options.universalSnapshot({ "ticker.any_of": "NCLH,O:SPY250321C00380000,C:EURUSD,X:BTCUSD,I:SPX" }).then((data) => { + console.log(data); +}).catch(e => { + console.error('An error happened:', e); +}); + +// https://polygon.io/docs/forex/get_v3_snapshot +rest.forex.universalSnapshot({ "ticker.any_of": "NCLH,O:SPY250321C00380000,C:EURUSD,X:BTCUSD,I:SPX" }).then((data) => { + console.log(data); +}).catch(e => { + console.error('An error happened:', e); +}); \ No newline at end of file diff --git a/src/rest/crypto/index.test.ts b/src/rest/crypto/index.test.ts index af05935..6e0f165 100644 --- a/src/rest/crypto/index.test.ts +++ b/src/rest/crypto/index.test.ts @@ -151,6 +151,16 @@ describe("[REST] Crypto", () => { fetchStub.getCalls()[0].args[1].headers.header1.should.eql(mocks.globalOptions.headers.header1); }); + it("snapshot - universal snapshot /v3/snapshot", async () => { + const query = {'ticker.any_of': 'NCLH,O:SPY250321C00380000,C:EURUSD,X:BTCUSD,I:SPX'} + await crypto.universalSnapshot(query, mocks.overrideOptions); + fetchStub.callCount.should.eql(1); + getPath(fetchStub.getCalls()[0].args[0]).should.eql("/v3/snapshot"); + fetchStub.getCalls()[0].args[0].indexOf('ticker.any_of').should.be.gt(-1); + fetchStub.getCalls()[0].args[1].referrer.should.eql(mocks.overrideOptions.referrer); + fetchStub.getCalls()[0].args[1].headers.header1.should.eql(mocks.globalOptions.headers.header1); + }); + it("sma call /v1/indicators/sma/{cryptoTicker}", async () => { await crypto.sma("X:BTC-USD", mocks.query, mocks.overrideOptions); fetchStub.callCount.should.eql(1); diff --git a/src/rest/crypto/index.ts b/src/rest/crypto/index.ts index f7732bd..137cd65 100644 --- a/src/rest/crypto/index.ts +++ b/src/rest/crypto/index.ts @@ -37,6 +37,7 @@ import { ISma, sma } from "./sma.js"; import { IEma, ema } from "./ema.js"; import { IMacd, macd } from "./macd.js"; import { IRsi, rsi } from "./rsi.js"; +import { IUniversalSnapshot, IUniversalSnapshotQuery, universalSnapshot } from "../universal/universalSnapshot.js"; export { ICryptoDailyOpenCloseQuery, @@ -55,6 +56,7 @@ export { ISma, ITechnicalIndicatorsQuery } from '../stocks/sma'; export { IEma } from '../stocks/ema'; export { IMacd } from '../stocks/macd'; export { IRsi } from '../stocks/rsi'; +export { IUniversalSnapshot, IUniversalSnapshotQuery } from "../universal/universalSnapshot.js"; export interface ICryptoClient { aggregates: ( @@ -107,6 +109,7 @@ export interface ICryptoClient { ema: (symbol: string, query?: ITechnicalIndicatorsQuery, options?: IRequestOptions) => Promise; macd: (symbol: string, query?: ITechnicalIndicatorsQuery, options?: IRequestOptions) => Promise; rsi: (symbol: string, query?: ITechnicalIndicatorsQuery, options?: IRequestOptions) => Promise; + universalSnapshot: (query?: IUniversalSnapshotQuery, options?: IRequestOptions) => Promise; } export const cryptoClient = ( @@ -131,7 +134,8 @@ export const cryptoClient = ( sma: (...args) => sma(get, ...args), ema: (...args) => ema(get, ...args), macd: (...args) => macd(get, ...args), - rsi: (...args) => rsi(get, ...args) + rsi: (...args) => rsi(get, ...args), + universalSnapshot: (...args) => universalSnapshot(get, ...args) }); } export default cryptoClient; diff --git a/src/rest/forex/index.test.ts b/src/rest/forex/index.test.ts index 7b6b128..fc3ea0f 100644 --- a/src/rest/forex/index.test.ts +++ b/src/rest/forex/index.test.ts @@ -139,6 +139,16 @@ describe("[REST] Forex / Currencies", () => { fetchStub.getCalls()[0].args[1].headers.header1.should.eql(mocks.globalOptions.headers.header1); }); + it("snapshot - universal snapshot /v3/snapshot", async () => { + const query = {'ticker.any_of': 'NCLH,O:SPY250321C00380000,C:EURUSD,X:BTCUSD,I:SPX'} + await fx.universalSnapshot(query, mocks.overrideOptions); + fetchStub.callCount.should.eql(1); + getPath(fetchStub.getCalls()[0].args[0]).should.eql("/v3/snapshot"); + fetchStub.getCalls()[0].args[0].indexOf('ticker.any_of').should.be.gt(-1); + fetchStub.getCalls()[0].args[1].referrer.should.eql(mocks.overrideOptions.referrer); + fetchStub.getCalls()[0].args[1].headers.header1.should.eql(mocks.globalOptions.headers.header1); + }); + it("sma call /v1/indicators/sma/{fxTicker}", async () => { await fx.sma("C:EUR-USD", mocks.query, mocks.overrideOptions); fetchStub.callCount.should.eql(1); diff --git a/src/rest/forex/index.ts b/src/rest/forex/index.ts index 30b87ac..a81ea2e 100644 --- a/src/rest/forex/index.ts +++ b/src/rest/forex/index.ts @@ -31,6 +31,7 @@ import { ISma, sma } from "./sma.js"; import { IEma, ema } from "./ema.js"; import { IMacd, macd } from "./macd.js"; import { IRsi, rsi } from "./rsi.js"; +import { IUniversalSnapshot, IUniversalSnapshotQuery, universalSnapshot } from "../universal/universalSnapshot.js"; export { IConversionQuery, IConversion } from "./conversion.js"; export { IForexQuotes } from "./quotes.js"; @@ -49,6 +50,7 @@ export { ISma, ITechnicalIndicatorsQuery } from '../stocks/sma.js'; export { IEma } from '../stocks/ema.js'; export { IMacd } from '../stocks/macd.js'; export { IRsi } from '../stocks/rsi.js'; +export { IUniversalSnapshot, IUniversalSnapshotQuery } from "../universal/universalSnapshot.js"; export interface IForexClient { aggregates: ( @@ -97,6 +99,7 @@ export interface IForexClient { ema: (symbol: string, query?: ITechnicalIndicatorsQuery, options?: IRequestOptions) => Promise; macd: (symbol: string, query?: ITechnicalIndicatorsQuery, options?: IRequestOptions) => Promise; rsi: (symbol: string, query?: ITechnicalIndicatorsQuery, options?: IRequestOptions) => Promise; + universalSnapshot: (query?: IUniversalSnapshotQuery, options?: IRequestOptions) => Promise; } export const forexClient = ( @@ -120,7 +123,8 @@ export const forexClient = ( sma: (...args) => sma(get, ...args), ema: (...args) => ema(get, ...args), macd: (...args) => macd(get, ...args), - rsi: (...args) => rsi(get, ...args) + rsi: (...args) => rsi(get, ...args), + universalSnapshot: (...args) => universalSnapshot(get, ...args) }) }; diff --git a/src/rest/options/index.test.ts b/src/rest/options/index.test.ts index ede48e2..304e62a 100644 --- a/src/rest/options/index.test.ts +++ b/src/rest/options/index.test.ts @@ -113,6 +113,16 @@ describe("[REST] Options", () => { fetchStub.getCalls()[0].args[1].headers.header1.should.eql(mocks.globalOptions.headers.header1); }); + it("snapshot - universal snapshot /v3/snapshot", async () => { + const query = {'ticker.any_of': 'NCLH,O:SPY250321C00380000,C:EURUSD,X:BTCUSD,I:SPX'} + await options.universalSnapshot(query, mocks.overrideOptions); + fetchStub.callCount.should.eql(1); + getPath(fetchStub.getCalls()[0].args[0]).should.eql("/v3/snapshot"); + fetchStub.getCalls()[0].args[0].indexOf('ticker.any_of').should.be.gt(-1); + fetchStub.getCalls()[0].args[1].referrer.should.eql(mocks.overrideOptions.referrer); + fetchStub.getCalls()[0].args[1].headers.header1.should.eql(mocks.globalOptions.headers.header1); + }); + it("sma call /v1/indicators/sma/{optionTicker}", async () => { await options.sma("O:AAPL230616C00150000", mocks.query, mocks.overrideOptions); fetchStub.callCount.should.eql(1); diff --git a/src/rest/options/index.ts b/src/rest/options/index.ts index cad744e..f46197b 100644 --- a/src/rest/options/index.ts +++ b/src/rest/options/index.ts @@ -29,6 +29,7 @@ import { ISma, sma } from "./sma.js"; import { IEma, ema } from "./ema.js"; import { IMacd, macd } from "./macd.js"; import { IRsi, rsi } from "./rsi.js"; +import { IUniversalSnapshot, IUniversalSnapshotQuery, universalSnapshot } from "../universal/universalSnapshot.js"; export { IOptionsDailyOpenCloseQuery, @@ -49,6 +50,7 @@ export { ISma, ITechnicalIndicatorsQuery } from '../stocks/sma.js'; export { IEma } from '../stocks/ema.js'; export { IMacd } from '../stocks/macd.js'; export { IRsi } from '../stocks/rsi.js'; +export { IUniversalSnapshot, IUniversalSnapshotQuery } from "../universal/universalSnapshot.js"; export interface IOptionsClient { aggregates: ( @@ -98,6 +100,7 @@ export interface IOptionsClient { ema: (symbol: string, query?: ITechnicalIndicatorsQuery, options?: IRequestOptions) => Promise; macd: (symbol: string, query?: ITechnicalIndicatorsQuery, options?: IRequestOptions) => Promise; rsi: (symbol: string, query?: ITechnicalIndicatorsQuery, options?: IRequestOptions) => Promise; + universalSnapshot: (query?: IUniversalSnapshotQuery, options?: IRequestOptions) => Promise; } export const optionsClient = ( @@ -120,7 +123,8 @@ export const optionsClient = ( sma: (...args) => sma(get, ...args), ema: (...args) => ema(get, ...args), macd: (...args) => macd(get, ...args), - rsi: (...args) => rsi(get, ...args) + rsi: (...args) => rsi(get, ...args), + universalSnapshot: (...args) => universalSnapshot(get, ...args) }) }; diff --git a/src/rest/reference/index.ts b/src/rest/reference/index.ts index 94d317d..3bf0452 100644 --- a/src/rest/reference/index.ts +++ b/src/rest/reference/index.ts @@ -77,7 +77,7 @@ const get = getWithGlobals(apiKey, apiBase, options); tickerDetails: (...args) => tickerDetails(get, ...args), tickerNews: (...args) => tickerNews(get, ...args), tickers: (...args) => tickers(get, ...args), - tickerTypes: (...args) => tickerTypes(get, ...args), + tickerTypes: (...args) => tickerTypes(get, ...args) }); } export default referenceClient; diff --git a/src/rest/stocks/index.test.ts b/src/rest/stocks/index.test.ts index 74d3d13..2846ff7 100644 --- a/src/rest/stocks/index.test.ts +++ b/src/rest/stocks/index.test.ts @@ -143,6 +143,16 @@ describe("[REST] Stocks", () => { fetchStub.getCalls()[0].args[1].headers.header1.should.eql(mocks.globalOptions.headers.header1); }); + it("snapshot - universal snapshot /v3/snapshot", async () => { + const query = {'ticker.any_of': 'NCLH,O:SPY250321C00380000,C:EURUSD,X:BTCUSD,I:SPX'} + await stocks.universalSnapshot(query, mocks.overrideOptions); + fetchStub.callCount.should.eql(1); + getPath(fetchStub.getCalls()[0].args[0]).should.eql("/v3/snapshot"); + fetchStub.getCalls()[0].args[0].indexOf('ticker.any_of').should.be.gt(-1); + fetchStub.getCalls()[0].args[1].referrer.should.eql(mocks.overrideOptions.referrer); + fetchStub.getCalls()[0].args[1].headers.header1.should.eql(mocks.globalOptions.headers.header1); + }); + it("sma call /v1/indicators/sma/{stockTicker}", async () => { await stocks.sma("AAPL", mocks.query, mocks.overrideOptions); fetchStub.callCount.should.eql(1); diff --git a/src/rest/stocks/index.ts b/src/rest/stocks/index.ts index f6b7585..e813070 100644 --- a/src/rest/stocks/index.ts +++ b/src/rest/stocks/index.ts @@ -33,6 +33,7 @@ import { ISma, ITechnicalIndicatorsQuery, sma } from "./sma.js"; import { IEma, ema } from "./ema.js"; import { IMacd, macd } from "./macd.js"; import { IRsi, rsi } from "./rsi.js"; +import { IUniversalSnapshot, IUniversalSnapshotQuery, universalSnapshot } from "../universal/universalSnapshot.js"; export { IAggsQuery, IAggs } from "./aggregates.js"; export { @@ -55,6 +56,7 @@ export { ISma, ITechnicalIndicatorsQuery } from './sma.js'; export { IEma } from './ema.js'; export { IMacd } from './macd.js'; export { IRsi } from './rsi.js'; +export { IUniversalSnapshot, IUniversalSnapshotQuery } from "../universal/universalSnapshot.js"; export interface IStocksClient { aggregates: ( @@ -101,6 +103,7 @@ export interface IStocksClient { macd: (symbol: string, query?: ITechnicalIndicatorsQuery, options?: IRequestOptions) => Promise; rsi: (symbol: string, query?: ITechnicalIndicatorsQuery, options?: IRequestOptions) => Promise; trades: (stockTicker: string, query?: ITradesQuotesQuery, options?: IRequestOptions) => Promise; + universalSnapshot: (query?: IUniversalSnapshotQuery, options?: IRequestOptions) => Promise; } export const stocksClient = ( @@ -126,7 +129,8 @@ export const stocksClient = ( ema: (...args) => ema(get, ...args), macd: (...args) => macd(get, ...args), rsi: (...args) => rsi(get, ...args), - trades: (...args) => trades(get, ...args) + trades: (...args) => trades(get, ...args), + universalSnapshot: (...args) => universalSnapshot(get, ...args) }) } diff --git a/src/rest/universal/universalSnapshot.ts b/src/rest/universal/universalSnapshot.ts new file mode 100644 index 0000000..c5525c6 --- /dev/null +++ b/src/rest/universal/universalSnapshot.ts @@ -0,0 +1,98 @@ +import { IGet, IRequestOptions, IPolygonQuery } from "../transport/request.js"; + +export interface UniversalSnapshotSession { + change?: number; + change_percent?: number; + early_trading_change?: number; + early_trading_change_percent?: number; + late_trading_change?: number; + late_trading_change_percent?: number; + close?: number; + high?: number; + low?: number; + open?: number; + volume?: number; + previous_close?: number; + price?: number; +} + +export interface UniversalSnapshotLastQuote { + last_updated?: number; + timeframe?: string; + ask?: number; + ask_size?: number; + bid?: number; + bid_size?: number; + midpoint?: number; + exchange?: number; +} + +export interface UniversalSnapshotLastTrade { + last_updated?: number; + timeframe?: string; + id?: string; + price?: number; + size?: number; + exchange?: number; + conditions?: number[]; + participant_timestamp?: number; + sip_timestamp?: number; +} + +export interface UniversalSnapshotDetails { + contract_type?: string; + exercise_style?: string; + expiration_date?: string; + shares_per_contract?: number; + strike_price?: number; +} + +export interface UniversalSnapshotGreeks { + delta?: number; + gamma?: number; + theta?: number; + vega?: number; +} + +export interface UniversalSnapshotUnderlyingAsset { + change_to_break_even?: number; + last_updated?: number; + price?: number; + ticker?: string; + timeframe?: string; +} + +export interface UniversalSnapshotInfo { + market_status?: string; + name?: string; + ticker?: string; + type?: string; + session?: UniversalSnapshotSession; + last_quote?: UniversalSnapshotLastQuote; + last_trade?: UniversalSnapshotLastTrade; + details?: UniversalSnapshotDetails; + greeks?: UniversalSnapshotGreeks; + implied_volatility?: number; + open_interest?: number; + underlying_asset?: UniversalSnapshotUnderlyingAsset; + value?: number; + break_even_price?: number; +} + +export interface IUniversalSnapshotQuery extends IPolygonQuery { + "ticker.any_of"?: string; +} + +export interface IUniversalSnapshot { + status?: string; + request_id?: string; + results?: UniversalSnapshotInfo[]; +} + +// CF: https://api.polygon.io/v3/snapshot?ticker.any_of=NCLH,O:SPY250321C00380000,C:EURUSD,X:BTCUSD,I:SPX&apiKey=XXX +export const universalSnapshot = async ( + get: IGet, + query?: IUniversalSnapshotQuery, + options?: IRequestOptions +): Promise => + get(`/v3/snapshot`, query, options); From 1a68f0309ac86be6e4da71e1ca735a31f67e8581 Mon Sep 17 00:00:00 2001 From: Meekit Patel <36168387+mpatel18@users.noreply.github.com> Date: Wed, 14 Jun 2023 11:03:08 -0400 Subject: [PATCH 17/39] Release/7.2.4 (#163) * 7.2.4 * update changelog * clean changelog --- CHANGELOG.md | 6 ++++++ package-lock.json | 4 ++-- package.json | 2 +- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3307a61..662f90a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +## [7.2.4](https://github.com/polygon-io/client-js/compare/v7.2.3...v7.2.4) (2023-06-14) +### Bug Fixes +* Update snapshot min to support n and t +* Exports and Updates Options WebSocket Event Types +* Universal snapshot + ## [7.2.3](https://github.com/polygon-io/client-js/compare/v7.2.2...v7.2.3) (2023-05-15) ### Bug Fixes * Fix typing issue with optional headers Launchpad Typescript definitions diff --git a/package-lock.json b/package-lock.json index c0071dd..ae79a4c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@polygon.io/client-js", - "version": "7.2.3", + "version": "7.2.4", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@polygon.io/client-js", - "version": "7.2.3", + "version": "7.2.4", "license": "MIT", "workspaces": [ "./dist/*", diff --git a/package.json b/package.json index 28765a4..6c83c21 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@polygon.io/client-js", - "version": "7.2.3", + "version": "7.2.4", "description": "Isomorphic Javascript client for Polygon.io Stocks, Forex, and Crypto APIs", "main": "dist/main.js", "types": "dist/main.d.ts", From 11d2340eaea7885ed6d3ab406c9fe20fecf89561 Mon Sep 17 00:00:00 2001 From: Katie Adams <64220601+timetraveler328@users.noreply.github.com> Date: Tue, 20 Jun 2023 13:56:48 -0400 Subject: [PATCH 18/39] 7.2.5 (#166) --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index ae79a4c..97ecaed 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@polygon.io/client-js", - "version": "7.2.4", + "version": "7.2.5", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@polygon.io/client-js", - "version": "7.2.4", + "version": "7.2.5", "license": "MIT", "workspaces": [ "./dist/*", diff --git a/package.json b/package.json index 6c83c21..f993512 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@polygon.io/client-js", - "version": "7.2.4", + "version": "7.2.5", "description": "Isomorphic Javascript client for Polygon.io Stocks, Forex, and Crypto APIs", "main": "dist/main.js", "types": "dist/main.d.ts", From c50f9c4500f4f5ed699e5c3f8625a2f42f5a28a3 Mon Sep 17 00:00:00 2001 From: Travis Groth Date: Fri, 11 Aug 2023 09:22:45 -0400 Subject: [PATCH 19/39] Update exports to include universal snapshot types (#171) --- src/rest/index.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/rest/index.ts b/src/rest/index.ts index 78a6304..b4a552e 100644 --- a/src/rest/index.ts +++ b/src/rest/index.ts @@ -11,6 +11,7 @@ export * from "./reference/index.js"; export * from "./options/index.js"; export * from "./stocks/index.js"; export * from "./indices/index.js"; +export * from "./universal/universalSnapshot.js"; export * from "./transport/request.js"; // ensure types are exported export interface IRestClient { From bd098db67b874f853f29ed74b19df28a76682645 Mon Sep 17 00:00:00 2001 From: Katie Adams <64220601+timetraveler328@users.noreply.github.com> Date: Fri, 11 Aug 2023 17:02:04 -0400 Subject: [PATCH 20/39] Add next_url to Aggs Response interface (#174) --- src/rest/stocks/aggregates.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/rest/stocks/aggregates.ts b/src/rest/stocks/aggregates.ts index 468feac..613de3a 100644 --- a/src/rest/stocks/aggregates.ts +++ b/src/rest/stocks/aggregates.ts @@ -28,6 +28,7 @@ export interface IAggs { resultsCount?: number; status?: string; results?: IAggsResults[]; + next_url?: string; } export const aggregates = async ( From ef439905e3533a92600aabe9d6469a9c0e95dcd1 Mon Sep 17 00:00:00 2001 From: Katie Adams <64220601+timetraveler328@users.noreply.github.com> Date: Fri, 11 Aug 2023 17:02:23 -0400 Subject: [PATCH 21/39] 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) --- README.md | 9 +-- examples/rest/configuration.js | 4 +- examples/rest/crypto-aggregates_bars.js | 4 +- examples/rest/crypto-conditions.js | 4 +- examples/rest/crypto-daily_open_close.js | 4 +- examples/rest/crypto-exchanges.js | 4 +- examples/rest/crypto-grouped_daily_bars.js | 4 +- .../crypto-last_trade_for_a_crypto_pair.js | 4 +- examples/rest/crypto-market_holidays.js | 4 +- examples/rest/crypto-market_status.js | 4 +- examples/rest/crypto-previous_close.js | 4 +- examples/rest/crypto-snapshots_all_tickers.js | 4 +- .../rest/crypto-snapshots_gainers_losers.js | 4 +- examples/rest/crypto-snapshots_ticker.js | 4 +- .../crypto-snapshots_ticker_full_book_l2.js | 4 +- .../rest/crypto-technical_indicators_ema.js | 4 +- .../rest/crypto-technical_indicators_macd.js | 4 +- .../rest/crypto-technical_indicators_rsi.js | 4 +- .../rest/crypto-technical_indicators_sma.js | 4 +- examples/rest/crypto-tickers.js | 4 +- examples/rest/crypto-trades.js | 4 +- examples/rest/forex-aggregates_bars.js | 4 +- examples/rest/forex-conditions.js | 4 +- examples/rest/forex-exchanges.js | 4 +- examples/rest/forex-grouped_daily_bars.js | 4 +- .../forex-last_quote_for_a_currency_pair.js | 4 +- examples/rest/forex-market_holidays.js | 4 +- examples/rest/forex-market_status.js | 4 +- examples/rest/forex-previous_close.js | 4 +- examples/rest/forex-quotes.js | 4 +- .../forex-real-time_currency_conversion.js | 4 +- examples/rest/forex-snapshots_all_tickers.js | 4 +- .../rest/forex-snapshots_gainers_losers.js | 4 +- examples/rest/forex-snapshots_ticker.js | 4 +- .../rest/forex-technical_indicators_ema.js | 4 +- .../rest/forex-technical_indicators_macd.js | 4 +- .../rest/forex-technical_indicators_rsi.js | 4 +- .../rest/forex-technical_indicators_sma.js | 4 +- examples/rest/forex-tickers.js | 4 +- examples/rest/indices-aggregates_bars.js | 4 +- examples/rest/indices-daily_open_close.js | 4 +- examples/rest/indices-market_holidays.js | 4 +- examples/rest/indices-market_status.js | 4 +- examples/rest/indices-previous_close.js | 4 +- examples/rest/indices-snapshots.js | 4 +- .../rest/indices-technical_indicators_ema.js | 4 +- .../rest/indices-technical_indicators_macd.js | 4 +- .../rest/indices-technical_indicators_rsi.js | 4 +- .../rest/indices-technical_indicators_sma.js | 4 +- examples/rest/indices-ticker_types.js | 4 +- examples/rest/indices-tickers.js | 4 +- examples/rest/launchpad/README.md | 4 +- examples/rest/launchpad/index.js | 4 +- examples/rest/options-aggregates_bars.js | 4 +- examples/rest/options-conditions.js | 4 +- examples/rest/options-contract.js | 4 +- examples/rest/options-contracts.js | 4 +- examples/rest/options-daily_open_close.js | 4 +- examples/rest/options-exchanges.js | 4 +- examples/rest/options-last_trade.js | 4 +- examples/rest/options-market_holidays.js | 4 +- examples/rest/options-market_status.js | 4 +- examples/rest/options-previous_close.js | 4 +- examples/rest/options-quotes.js | 4 +- .../rest/options-snapshots_option_contract.js | 4 +- .../rest/options-snapshots_options_chain.js | 4 +- .../rest/options-technical_indicators_ema.js | 4 +- .../rest/options-technical_indicators_macd.js | 4 +- .../rest/options-technical_indicators_rsi.js | 4 +- .../rest/options-technical_indicators_sma.js | 4 +- examples/rest/options-ticker_details.js | 4 +- examples/rest/options-ticker_news.js | 4 +- examples/rest/options-tickers.js | 4 +- examples/rest/options-trades.js | 4 +- examples/rest/stocks-aggregates_bars.js | 4 +- examples/rest/stocks-conditions.js | 4 +- examples/rest/stocks-daily_open_close.js | 4 +- examples/rest/stocks-dividends.js | 4 +- examples/rest/stocks-exchanges.js | 4 +- examples/rest/stocks-grouped_daily_bars.js | 4 +- examples/rest/stocks-last_quote.js | 4 +- examples/rest/stocks-last_trade.js | 4 +- examples/rest/stocks-market_holidays.js | 4 +- examples/rest/stocks-market_status.js | 4 +- examples/rest/stocks-previous_close.js | 4 +- examples/rest/stocks-quotes.js | 4 +- examples/rest/stocks-snapshots_all.js | 4 +- .../rest/stocks-snapshots_gainers_losers.js | 4 +- examples/rest/stocks-snapshots_ticker.js | 4 +- examples/rest/stocks-stock_financials.js | 4 +- examples/rest/stocks-stock_splits.js | 4 +- .../rest/stocks-technical_indicators_ema.js | 4 +- .../rest/stocks-technical_indicators_macd.js | 4 +- .../rest/stocks-technical_indicators_rsi.js | 4 +- .../rest/stocks-technical_indicators_sma.js | 4 +- examples/rest/stocks-ticker_details.js | 4 +- examples/rest/stocks-ticker_news.js | 4 +- examples/rest/stocks-ticker_types.js | 4 +- examples/rest/stocks-tickers.js | 4 +- examples/rest/stocks-trades.js | 4 +- examples/rest/universal-snapshot.js | 4 +- examples/websocket/advanced.js | 7 ++- examples/websocket/index.js | 3 +- package-lock.json | 60 ++++++++++++++++++- package.json | 5 +- 105 files changed, 274 insertions(+), 210 deletions(-) diff --git a/README.md b/README.md index dc14f38..6616404 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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 @@ -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); diff --git a/examples/rest/configuration.js b/examples/rest/configuration.js index 9662779..815be46 100644 --- a/examples/rest/configuration.js +++ b/examples/rest/configuration.js @@ -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 diff --git a/examples/rest/crypto-aggregates_bars.js b/examples/rest/crypto-aggregates_bars.js index f7daef8..4b8e09d 100644 --- a/examples/rest/crypto-aggregates_bars.js +++ b/examples/rest/crypto-aggregates_bars.js @@ -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) => { diff --git a/examples/rest/crypto-conditions.js b/examples/rest/crypto-conditions.js index 7e22f78..d0a4062 100644 --- a/examples/rest/crypto-conditions.js +++ b/examples/rest/crypto-conditions.js @@ -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) => { diff --git a/examples/rest/crypto-daily_open_close.js b/examples/rest/crypto-daily_open_close.js index ad7faa7..db01b9e 100644 --- a/examples/rest/crypto-daily_open_close.js +++ b/examples/rest/crypto-daily_open_close.js @@ -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) => { diff --git a/examples/rest/crypto-exchanges.js b/examples/rest/crypto-exchanges.js index 7ec6d93..f465058 100644 --- a/examples/rest/crypto-exchanges.js +++ b/examples/rest/crypto-exchanges.js @@ -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) => { diff --git a/examples/rest/crypto-grouped_daily_bars.js b/examples/rest/crypto-grouped_daily_bars.js index 46f0daa..2a7b1f7 100644 --- a/examples/rest/crypto-grouped_daily_bars.js +++ b/examples/rest/crypto-grouped_daily_bars.js @@ -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) => { diff --git a/examples/rest/crypto-last_trade_for_a_crypto_pair.js b/examples/rest/crypto-last_trade_for_a_crypto_pair.js index 625a03c..6f278dc 100644 --- a/examples/rest/crypto-last_trade_for_a_crypto_pair.js +++ b/examples/rest/crypto-last_trade_for_a_crypto_pair.js @@ -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) => { diff --git a/examples/rest/crypto-market_holidays.js b/examples/rest/crypto-market_holidays.js index 6bff875..2735531 100644 --- a/examples/rest/crypto-market_holidays.js +++ b/examples/rest/crypto-market_holidays.js @@ -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) => { diff --git a/examples/rest/crypto-market_status.js b/examples/rest/crypto-market_status.js index 0f0e26d..8e707f3 100644 --- a/examples/rest/crypto-market_status.js +++ b/examples/rest/crypto-market_status.js @@ -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) => { diff --git a/examples/rest/crypto-previous_close.js b/examples/rest/crypto-previous_close.js index e63713c..865cf84 100644 --- a/examples/rest/crypto-previous_close.js +++ b/examples/rest/crypto-previous_close.js @@ -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) => { diff --git a/examples/rest/crypto-snapshots_all_tickers.js b/examples/rest/crypto-snapshots_all_tickers.js index b703190..fb12ff5 100644 --- a/examples/rest/crypto-snapshots_all_tickers.js +++ b/examples/rest/crypto-snapshots_all_tickers.js @@ -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) => { diff --git a/examples/rest/crypto-snapshots_gainers_losers.js b/examples/rest/crypto-snapshots_gainers_losers.js index 21a0fea..eded0b0 100644 --- a/examples/rest/crypto-snapshots_gainers_losers.js +++ b/examples/rest/crypto-snapshots_gainers_losers.js @@ -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 diff --git a/examples/rest/crypto-snapshots_ticker.js b/examples/rest/crypto-snapshots_ticker.js index 6bae1d3..e327d1e 100644 --- a/examples/rest/crypto-snapshots_ticker.js +++ b/examples/rest/crypto-snapshots_ticker.js @@ -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) => { diff --git a/examples/rest/crypto-snapshots_ticker_full_book_l2.js b/examples/rest/crypto-snapshots_ticker_full_book_l2.js index ca08f52..72a9109 100644 --- a/examples/rest/crypto-snapshots_ticker_full_book_l2.js +++ b/examples/rest/crypto-snapshots_ticker_full_book_l2.js @@ -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) => { diff --git a/examples/rest/crypto-technical_indicators_ema.js b/examples/rest/crypto-technical_indicators_ema.js index 09fffb3..f5c8ce0 100644 --- a/examples/rest/crypto-technical_indicators_ema.js +++ b/examples/rest/crypto-technical_indicators_ema.js @@ -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) => { diff --git a/examples/rest/crypto-technical_indicators_macd.js b/examples/rest/crypto-technical_indicators_macd.js index 756db4a..9e31a7c 100644 --- a/examples/rest/crypto-technical_indicators_macd.js +++ b/examples/rest/crypto-technical_indicators_macd.js @@ -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) => { diff --git a/examples/rest/crypto-technical_indicators_rsi.js b/examples/rest/crypto-technical_indicators_rsi.js index 7f6a3d8..0b8d01f 100644 --- a/examples/rest/crypto-technical_indicators_rsi.js +++ b/examples/rest/crypto-technical_indicators_rsi.js @@ -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) => { diff --git a/examples/rest/crypto-technical_indicators_sma.js b/examples/rest/crypto-technical_indicators_sma.js index 9a1997d..d79a826 100644 --- a/examples/rest/crypto-technical_indicators_sma.js +++ b/examples/rest/crypto-technical_indicators_sma.js @@ -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) => { diff --git a/examples/rest/crypto-tickers.js b/examples/rest/crypto-tickers.js index 7d5c9af..6406a91 100644 --- a/examples/rest/crypto-tickers.js +++ b/examples/rest/crypto-tickers.js @@ -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) => { diff --git a/examples/rest/crypto-trades.js b/examples/rest/crypto-trades.js index 468345a..7aa2940 100644 --- a/examples/rest/crypto-trades.js +++ b/examples/rest/crypto-trades.js @@ -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) => { diff --git a/examples/rest/forex-aggregates_bars.js b/examples/rest/forex-aggregates_bars.js index 324125b..c38ea39 100644 --- a/examples/rest/forex-aggregates_bars.js +++ b/examples/rest/forex-aggregates_bars.js @@ -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) => { diff --git a/examples/rest/forex-conditions.js b/examples/rest/forex-conditions.js index 1f658e0..c82cda1 100644 --- a/examples/rest/forex-conditions.js +++ b/examples/rest/forex-conditions.js @@ -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) => { diff --git a/examples/rest/forex-exchanges.js b/examples/rest/forex-exchanges.js index 7d158d5..43b085d 100644 --- a/examples/rest/forex-exchanges.js +++ b/examples/rest/forex-exchanges.js @@ -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) => { diff --git a/examples/rest/forex-grouped_daily_bars.js b/examples/rest/forex-grouped_daily_bars.js index eb9740f..fa1e9e3 100644 --- a/examples/rest/forex-grouped_daily_bars.js +++ b/examples/rest/forex-grouped_daily_bars.js @@ -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) => { diff --git a/examples/rest/forex-last_quote_for_a_currency_pair.js b/examples/rest/forex-last_quote_for_a_currency_pair.js index 715b9a3..4f3cb39 100644 --- a/examples/rest/forex-last_quote_for_a_currency_pair.js +++ b/examples/rest/forex-last_quote_for_a_currency_pair.js @@ -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) => { diff --git a/examples/rest/forex-market_holidays.js b/examples/rest/forex-market_holidays.js index 40d48e0..903ad3d 100644 --- a/examples/rest/forex-market_holidays.js +++ b/examples/rest/forex-market_holidays.js @@ -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) => { diff --git a/examples/rest/forex-market_status.js b/examples/rest/forex-market_status.js index 7b54ac9..faa070c 100644 --- a/examples/rest/forex-market_status.js +++ b/examples/rest/forex-market_status.js @@ -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) => { diff --git a/examples/rest/forex-previous_close.js b/examples/rest/forex-previous_close.js index b14a0d6..37dd7de 100644 --- a/examples/rest/forex-previous_close.js +++ b/examples/rest/forex-previous_close.js @@ -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) => { diff --git a/examples/rest/forex-quotes.js b/examples/rest/forex-quotes.js index 8ecfb66..3e369b5 100644 --- a/examples/rest/forex-quotes.js +++ b/examples/rest/forex-quotes.js @@ -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) => { diff --git a/examples/rest/forex-real-time_currency_conversion.js b/examples/rest/forex-real-time_currency_conversion.js index befd7ca..263e394 100644 --- a/examples/rest/forex-real-time_currency_conversion.js +++ b/examples/rest/forex-real-time_currency_conversion.js @@ -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) => { diff --git a/examples/rest/forex-snapshots_all_tickers.js b/examples/rest/forex-snapshots_all_tickers.js index 55fb4d7..ee9aae1 100644 --- a/examples/rest/forex-snapshots_all_tickers.js +++ b/examples/rest/forex-snapshots_all_tickers.js @@ -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) => { diff --git a/examples/rest/forex-snapshots_gainers_losers.js b/examples/rest/forex-snapshots_gainers_losers.js index c16d192..f8c1a70 100644 --- a/examples/rest/forex-snapshots_gainers_losers.js +++ b/examples/rest/forex-snapshots_gainers_losers.js @@ -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 diff --git a/examples/rest/forex-snapshots_ticker.js b/examples/rest/forex-snapshots_ticker.js index 511dd41..8b824e9 100644 --- a/examples/rest/forex-snapshots_ticker.js +++ b/examples/rest/forex-snapshots_ticker.js @@ -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) => { diff --git a/examples/rest/forex-technical_indicators_ema.js b/examples/rest/forex-technical_indicators_ema.js index 1381a6f..9d0728f 100644 --- a/examples/rest/forex-technical_indicators_ema.js +++ b/examples/rest/forex-technical_indicators_ema.js @@ -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", diff --git a/examples/rest/forex-technical_indicators_macd.js b/examples/rest/forex-technical_indicators_macd.js index 43b3b90..5bf5e3f 100644 --- a/examples/rest/forex-technical_indicators_macd.js +++ b/examples/rest/forex-technical_indicators_macd.js @@ -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) => { diff --git a/examples/rest/forex-technical_indicators_rsi.js b/examples/rest/forex-technical_indicators_rsi.js index 5c4a6ea..ba779d8 100644 --- a/examples/rest/forex-technical_indicators_rsi.js +++ b/examples/rest/forex-technical_indicators_rsi.js @@ -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) => { diff --git a/examples/rest/forex-technical_indicators_sma.js b/examples/rest/forex-technical_indicators_sma.js index 4f39ac6..0a58acb 100644 --- a/examples/rest/forex-technical_indicators_sma.js +++ b/examples/rest/forex-technical_indicators_sma.js @@ -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) => { diff --git a/examples/rest/forex-tickers.js b/examples/rest/forex-tickers.js index aaca154..415ceb4 100644 --- a/examples/rest/forex-tickers.js +++ b/examples/rest/forex-tickers.js @@ -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) => { diff --git a/examples/rest/indices-aggregates_bars.js b/examples/rest/indices-aggregates_bars.js index 77da2f4..a5cea15 100644 --- a/examples/rest/indices-aggregates_bars.js +++ b/examples/rest/indices-aggregates_bars.js @@ -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) => { diff --git a/examples/rest/indices-daily_open_close.js b/examples/rest/indices-daily_open_close.js index f557194..b199a63 100644 --- a/examples/rest/indices-daily_open_close.js +++ b/examples/rest/indices-daily_open_close.js @@ -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) => { diff --git a/examples/rest/indices-market_holidays.js b/examples/rest/indices-market_holidays.js index 520f715..1daa16a 100644 --- a/examples/rest/indices-market_holidays.js +++ b/examples/rest/indices-market_holidays.js @@ -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) => { diff --git a/examples/rest/indices-market_status.js b/examples/rest/indices-market_status.js index 3ff99e1..53ac15a 100644 --- a/examples/rest/indices-market_status.js +++ b/examples/rest/indices-market_status.js @@ -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) => { diff --git a/examples/rest/indices-previous_close.js b/examples/rest/indices-previous_close.js index 6be258d..5bba48e 100644 --- a/examples/rest/indices-previous_close.js +++ b/examples/rest/indices-previous_close.js @@ -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) => { diff --git a/examples/rest/indices-snapshots.js b/examples/rest/indices-snapshots.js index 14a0136..92a8fcd 100644 --- a/examples/rest/indices-snapshots.js +++ b/examples/rest/indices-snapshots.js @@ -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) => { diff --git a/examples/rest/indices-technical_indicators_ema.js b/examples/rest/indices-technical_indicators_ema.js index a02ef6a..82ed3c8 100644 --- a/examples/rest/indices-technical_indicators_ema.js +++ b/examples/rest/indices-technical_indicators_ema.js @@ -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) => { diff --git a/examples/rest/indices-technical_indicators_macd.js b/examples/rest/indices-technical_indicators_macd.js index 38e6484..7fca4e8 100644 --- a/examples/rest/indices-technical_indicators_macd.js +++ b/examples/rest/indices-technical_indicators_macd.js @@ -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_macd__indicesticker rest.indices.macd("I:SPX").then((data) => { diff --git a/examples/rest/indices-technical_indicators_rsi.js b/examples/rest/indices-technical_indicators_rsi.js index 054aacf..6c81f9a 100644 --- a/examples/rest/indices-technical_indicators_rsi.js +++ b/examples/rest/indices-technical_indicators_rsi.js @@ -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_rsi__indicesticker rest.indices.rsi("I:SPX").then((data) => { diff --git a/examples/rest/indices-technical_indicators_sma.js b/examples/rest/indices-technical_indicators_sma.js index feca02c..d8362f4 100644 --- a/examples/rest/indices-technical_indicators_sma.js +++ b/examples/rest/indices-technical_indicators_sma.js @@ -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_sma__indicesticker rest.indices.sma("I:SPX").then((data) => { diff --git a/examples/rest/indices-ticker_types.js b/examples/rest/indices-ticker_types.js index 15cda70..f7d8e59 100644 --- a/examples/rest/indices-ticker_types.js +++ b/examples/rest/indices-ticker_types.js @@ -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_reference_tickers_types rest.reference.tickerTypes({ asset_class: "indices"}).then((data) => { diff --git a/examples/rest/indices-tickers.js b/examples/rest/indices-tickers.js index 88c35ec..d3753ac 100644 --- a/examples/rest/indices-tickers.js +++ b/examples/rest/indices-tickers.js @@ -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_reference_tickers rest.reference.tickers({ market: "indices", limit: 1000 }).then((data) => { diff --git a/examples/rest/launchpad/README.md b/examples/rest/launchpad/README.md index f84cbb7..c4184a7 100644 --- a/examples/rest/launchpad/README.md +++ b/examples/rest/launchpad/README.md @@ -18,9 +18,9 @@ const edgeHeaders = { 'X-Polygon-Edge-User-Agent': useragent } -const rest = restClient("API KEY", "https://api.polygon.io"); +const rest = restClient(process.env.POLY_API_KEY); rest.forex.previousClose("C:EURUSD", {}, { headers: edgeHeaders }).then(/* your success handler */); -const reference = referenceClient("API KEY", "https://api.polygon.io"); +const reference = referenceClient(process.env.POLY_API_KEY); reference.tickers({}, { headers: edgeHeaders }).then(/* your success handler */); ``` \ No newline at end of file diff --git a/examples/rest/launchpad/index.js b/examples/rest/launchpad/index.js index b0f9951..e9c21b6 100644 --- a/examples/rest/launchpad/index.js +++ b/examples/rest/launchpad/index.js @@ -11,8 +11,8 @@ const edgeHeaders = { 'X-Polygon-Edge-User-Agent': 'useragent' } -const rest = restClient("API KEY", "https://api.polygon.io"); +const rest = restClient(process.env.POLY_API_KEY); rest.forex.previousClose("C:EURUSD", {}, { headers: edgeHeaders }).then(/* your success handler */); -const reference = referenceClient("API KEY", "https://api.polygon.io"); +const reference = referenceClient(process.env.POLY_API_KEY); reference.tickers({}, { headers: edgeHeaders }).then(/* your success handler */); \ No newline at end of file diff --git a/examples/rest/options-aggregates_bars.js b/examples/rest/options-aggregates_bars.js index 1936302..3606b65 100644 --- a/examples/rest/options-aggregates_bars.js +++ b/examples/rest/options-aggregates_bars.js @@ -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/options/get_v2_aggs_ticker__optionsticker__range__multiplier___timespan___from___to rest.options.aggregates("O:SPY251219C00650000", 1, "day", "2023-01-09", "2023-01-09").then((data) => { diff --git a/examples/rest/options-conditions.js b/examples/rest/options-conditions.js index 149a0c8..08fe254 100644 --- a/examples/rest/options-conditions.js +++ b/examples/rest/options-conditions.js @@ -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/options/get_v3_reference_conditions rest.reference.conditions({ asset_class: "options", limit: 1000 }).then((data) => { diff --git a/examples/rest/options-contract.js b/examples/rest/options-contract.js index 697c21e..9f0a2ff 100644 --- a/examples/rest/options-contract.js +++ b/examples/rest/options-contract.js @@ -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/options/get_v3_reference_options_contracts__options_ticker rest.reference.optionsContract("O:EVRI240119C00002500").then((data) => { diff --git a/examples/rest/options-contracts.js b/examples/rest/options-contracts.js index 9e34371..93cb0d2 100644 --- a/examples/rest/options-contracts.js +++ b/examples/rest/options-contracts.js @@ -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/options/get_v3_reference_options_contracts rest.reference.optionsContracts().then((data) => { diff --git a/examples/rest/options-daily_open_close.js b/examples/rest/options-daily_open_close.js index e1ea0f7..e24b565 100644 --- a/examples/rest/options-daily_open_close.js +++ b/examples/rest/options-daily_open_close.js @@ -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/options/get_v1_open-close__optionsticker___date rest.options.dailyOpenClose("O:SPY251219C00650000", "2023-03-31").then((data) => { diff --git a/examples/rest/options-exchanges.js b/examples/rest/options-exchanges.js index 82ea17d..e2a3cdc 100644 --- a/examples/rest/options-exchanges.js +++ b/examples/rest/options-exchanges.js @@ -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/options/get_v3_reference_exchanges rest.reference.exchanges({ asset_class: "options", limit: 1000 }).then((data) => { diff --git a/examples/rest/options-last_trade.js b/examples/rest/options-last_trade.js index 3976a2b..c0553bc 100644 --- a/examples/rest/options-last_trade.js +++ b/examples/rest/options-last_trade.js @@ -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/options/get_v2_last_trade__optionsticker rest.options.lastTrade("O:TSLA210903C00700000").then((data) => { diff --git a/examples/rest/options-market_holidays.js b/examples/rest/options-market_holidays.js index 819e2d0..1485bd8 100644 --- a/examples/rest/options-market_holidays.js +++ b/examples/rest/options-market_holidays.js @@ -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/options/get_v1_marketstatus_upcoming rest.reference.marketHolidays().then((data) => { diff --git a/examples/rest/options-market_status.js b/examples/rest/options-market_status.js index 4039265..037caba 100644 --- a/examples/rest/options-market_status.js +++ b/examples/rest/options-market_status.js @@ -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/options/get_v1_marketstatus_now rest.reference.marketStatus().then((data) => { diff --git a/examples/rest/options-previous_close.js b/examples/rest/options-previous_close.js index f0d3c4c..9a7d4eb 100644 --- a/examples/rest/options-previous_close.js +++ b/examples/rest/options-previous_close.js @@ -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/options/get_v2_aggs_ticker__optionsticker__prev rest.options.previousClose("O:SPY251219C00650000").then((data) => { diff --git a/examples/rest/options-quotes.js b/examples/rest/options-quotes.js index 36d49fd..69dcaff 100644 --- a/examples/rest/options-quotes.js +++ b/examples/rest/options-quotes.js @@ -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/options/get_v3_quotes__optionsticker rest.options.quotes("O:SPY241220P00720000").then((data) => { diff --git a/examples/rest/options-snapshots_option_contract.js b/examples/rest/options-snapshots_option_contract.js index 8719097..bd719f8 100644 --- a/examples/rest/options-snapshots_option_contract.js +++ b/examples/rest/options-snapshots_option_contract.js @@ -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/options/get_v3_snapshot_options__underlyingasset___optioncontract rest.options.snapshotOptionContract("AAPL", "O:AAPL230616C00150000").then((data) => { diff --git a/examples/rest/options-snapshots_options_chain.js b/examples/rest/options-snapshots_options_chain.js index faa6c74..1433d76 100644 --- a/examples/rest/options-snapshots_options_chain.js +++ b/examples/rest/options-snapshots_options_chain.js @@ -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/options/get_v3_snapshot_options__underlyingasset rest.options.snapshotOptionChain("AAPL").then((data) => { diff --git a/examples/rest/options-technical_indicators_ema.js b/examples/rest/options-technical_indicators_ema.js index 2d964ae..75aaf83 100644 --- a/examples/rest/options-technical_indicators_ema.js +++ b/examples/rest/options-technical_indicators_ema.js @@ -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/options/get_v1_indicators_ema__optionsticker rest.options.ema("AAPL").then((data) => { diff --git a/examples/rest/options-technical_indicators_macd.js b/examples/rest/options-technical_indicators_macd.js index 2cd9d59..807f214 100644 --- a/examples/rest/options-technical_indicators_macd.js +++ b/examples/rest/options-technical_indicators_macd.js @@ -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/options/get_v1_indicators_macd__optionsticker rest.options.macd("O:SPY241220P00720000").then((data) => { diff --git a/examples/rest/options-technical_indicators_rsi.js b/examples/rest/options-technical_indicators_rsi.js index 05a7ef4..7600855 100644 --- a/examples/rest/options-technical_indicators_rsi.js +++ b/examples/rest/options-technical_indicators_rsi.js @@ -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/options/get_v1_indicators_rsi__optionsticker rest.options.rsi("O:SPY241220P00720000").then((data) => { diff --git a/examples/rest/options-technical_indicators_sma.js b/examples/rest/options-technical_indicators_sma.js index 3718614..8be34e1 100644 --- a/examples/rest/options-technical_indicators_sma.js +++ b/examples/rest/options-technical_indicators_sma.js @@ -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/options/get_v1_indicators_sma__optionsticker rest.options.sma("O:SPY241220P00720000").then((data) => { diff --git a/examples/rest/options-ticker_details.js b/examples/rest/options-ticker_details.js index 897e8aa..5fe964c 100644 --- a/examples/rest/options-ticker_details.js +++ b/examples/rest/options-ticker_details.js @@ -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/options/get_v3_reference_tickers__ticker rest.reference.tickerDetails("AAPL").then((data) => { diff --git a/examples/rest/options-ticker_news.js b/examples/rest/options-ticker_news.js index 00a8e8a..c5ee709 100644 --- a/examples/rest/options-ticker_news.js +++ b/examples/rest/options-ticker_news.js @@ -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/options/get_v2_reference_news rest.reference.tickerNews("AAPL").then((data) => { diff --git a/examples/rest/options-tickers.js b/examples/rest/options-tickers.js index 50c3471..aea14bd 100644 --- a/examples/rest/options-tickers.js +++ b/examples/rest/options-tickers.js @@ -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/options/get_v3_reference_tickers rest.reference.tickers({ market: "stocks", limit: 1000 }).then((data) => { diff --git a/examples/rest/options-trades.js b/examples/rest/options-trades.js index d97070b..072d4f2 100644 --- a/examples/rest/options-trades.js +++ b/examples/rest/options-trades.js @@ -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/options/get_v3_trades__optionsticker rest.options.trades("O:TSLA210903C00700000").then((data) => { diff --git a/examples/rest/stocks-aggregates_bars.js b/examples/rest/stocks-aggregates_bars.js index 3e0463c..49d4348 100644 --- a/examples/rest/stocks-aggregates_bars.js +++ b/examples/rest/stocks-aggregates_bars.js @@ -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/stocks/get_v2_aggs_ticker__stocksticker__range__multiplier___timespan___from___to rest.stocks.aggregates("AAPL", 1, "day", "2019-01-01", "2019-02-01").then((data) => { diff --git a/examples/rest/stocks-conditions.js b/examples/rest/stocks-conditions.js index eb3d9b4..b123036 100644 --- a/examples/rest/stocks-conditions.js +++ b/examples/rest/stocks-conditions.js @@ -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/stocks/get_v3_reference_conditions rest.reference.conditions({ asset_class: "stocks", limit: 1000 }).then((data) => { diff --git a/examples/rest/stocks-daily_open_close.js b/examples/rest/stocks-daily_open_close.js index c8ac3d2..f739314 100644 --- a/examples/rest/stocks-daily_open_close.js +++ b/examples/rest/stocks-daily_open_close.js @@ -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/stocks/get_v1_open-close__stocksticker___date rest.stocks.dailyOpenClose("AAPL", "2023-03-31").then((data) => { diff --git a/examples/rest/stocks-dividends.js b/examples/rest/stocks-dividends.js index b66cd52..21b1940 100644 --- a/examples/rest/stocks-dividends.js +++ b/examples/rest/stocks-dividends.js @@ -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/stocks/get_v3_reference_dividends rest.reference.dividends("AAPL").then((data) => { diff --git a/examples/rest/stocks-exchanges.js b/examples/rest/stocks-exchanges.js index 036b8c3..93c7afc 100644 --- a/examples/rest/stocks-exchanges.js +++ b/examples/rest/stocks-exchanges.js @@ -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/stocks/get_v3_reference_exchanges rest.reference.exchanges({ asset_class: "stocks" }).then((data) => { diff --git a/examples/rest/stocks-grouped_daily_bars.js b/examples/rest/stocks-grouped_daily_bars.js index 95a94d1..433403f 100644 --- a/examples/rest/stocks-grouped_daily_bars.js +++ b/examples/rest/stocks-grouped_daily_bars.js @@ -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/stocks/get_v2_aggs_grouped_locale_us_market_stocks__date rest.stocks.aggregatesGroupedDaily("2023-03-31").then((data) => { diff --git a/examples/rest/stocks-last_quote.js b/examples/rest/stocks-last_quote.js index c32f081..7380bb3 100644 --- a/examples/rest/stocks-last_quote.js +++ b/examples/rest/stocks-last_quote.js @@ -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/stocks/get_v2_last_nbbo__stocksticker rest.stocks.lastQuote("AAPL").then((data) => { diff --git a/examples/rest/stocks-last_trade.js b/examples/rest/stocks-last_trade.js index 3676c3b..88cb485 100644 --- a/examples/rest/stocks-last_trade.js +++ b/examples/rest/stocks-last_trade.js @@ -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/stocks/get_v2_last_trade__stocksticker rest.stocks.lastTrade("AAPL").then((data) => { diff --git a/examples/rest/stocks-market_holidays.js b/examples/rest/stocks-market_holidays.js index d0d99ae..8be1d11 100644 --- a/examples/rest/stocks-market_holidays.js +++ b/examples/rest/stocks-market_holidays.js @@ -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/stocks/get_v1_marketstatus_upcoming rest.reference.marketHolidays().then((data) => { diff --git a/examples/rest/stocks-market_status.js b/examples/rest/stocks-market_status.js index 01f5574..0680575 100644 --- a/examples/rest/stocks-market_status.js +++ b/examples/rest/stocks-market_status.js @@ -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/stocks/get_v1_marketstatus_now rest.reference.marketStatus().then((data) => { diff --git a/examples/rest/stocks-previous_close.js b/examples/rest/stocks-previous_close.js index 2db31d3..3228a55 100644 --- a/examples/rest/stocks-previous_close.js +++ b/examples/rest/stocks-previous_close.js @@ -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/stocks/get_v2_aggs_ticker__stocksticker__prev rest.stocks.previousClose("AAPL").then((data) => { diff --git a/examples/rest/stocks-quotes.js b/examples/rest/stocks-quotes.js index f60dd7f..14bce4a 100644 --- a/examples/rest/stocks-quotes.js +++ b/examples/rest/stocks-quotes.js @@ -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/stocks/get_v3_quotes__stockticker rest.stocks.quotes("HCP").then((data) => { diff --git a/examples/rest/stocks-snapshots_all.js b/examples/rest/stocks-snapshots_all.js index 7efc9dc..7351298 100644 --- a/examples/rest/stocks-snapshots_all.js +++ b/examples/rest/stocks-snapshots_all.js @@ -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/stocks/get_v2_snapshot_locale_us_markets_stocks_tickers rest.stocks.snapshotAllTickers().then((data) => { diff --git a/examples/rest/stocks-snapshots_gainers_losers.js b/examples/rest/stocks-snapshots_gainers_losers.js index 1b30f0a..3d222f2 100644 --- a/examples/rest/stocks-snapshots_gainers_losers.js +++ b/examples/rest/stocks-snapshots_gainers_losers.js @@ -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/stocks/get_v2_snapshot_locale_us_markets_stocks__direction // gainers diff --git a/examples/rest/stocks-snapshots_ticker.js b/examples/rest/stocks-snapshots_ticker.js index 25083ad..0e6d6b5 100644 --- a/examples/rest/stocks-snapshots_ticker.js +++ b/examples/rest/stocks-snapshots_ticker.js @@ -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/stocks/get_v2_snapshot_locale_us_markets_stocks_tickers__stocksticker rest.stocks.snapshotTicker("AAPL").then((data) => { diff --git a/examples/rest/stocks-stock_financials.js b/examples/rest/stocks-stock_financials.js index 599dc96..a1392d4 100644 --- a/examples/rest/stocks-stock_financials.js +++ b/examples/rest/stocks-stock_financials.js @@ -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/stocks/get_vx_reference_financials rest.reference.stockFinancials("AAPL").then((data) => { diff --git a/examples/rest/stocks-stock_splits.js b/examples/rest/stocks-stock_splits.js index 4e2e6e8..2f8b448 100644 --- a/examples/rest/stocks-stock_splits.js +++ b/examples/rest/stocks-stock_splits.js @@ -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/stocks/get_v3_reference_splits rest.reference.stockSplits("AAPL").then((data) => { diff --git a/examples/rest/stocks-technical_indicators_ema.js b/examples/rest/stocks-technical_indicators_ema.js index f8811aa..e30690b 100644 --- a/examples/rest/stocks-technical_indicators_ema.js +++ b/examples/rest/stocks-technical_indicators_ema.js @@ -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/stocks/get_v1_indicators_ema__stockticker rest.stocks.ema("AAPL").then((data) => { diff --git a/examples/rest/stocks-technical_indicators_macd.js b/examples/rest/stocks-technical_indicators_macd.js index 5f96c54..b8dcabc 100644 --- a/examples/rest/stocks-technical_indicators_macd.js +++ b/examples/rest/stocks-technical_indicators_macd.js @@ -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/stocks/get_v1_indicators_macd__stockticker rest.stocks.macd("AAPL").then((data) => { diff --git a/examples/rest/stocks-technical_indicators_rsi.js b/examples/rest/stocks-technical_indicators_rsi.js index 90d90d0..e7483fa 100644 --- a/examples/rest/stocks-technical_indicators_rsi.js +++ b/examples/rest/stocks-technical_indicators_rsi.js @@ -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/stocks/get_v1_indicators_rsi__stockticker rest.stocks.rsi("AAPL").then((data) => { diff --git a/examples/rest/stocks-technical_indicators_sma.js b/examples/rest/stocks-technical_indicators_sma.js index e0e4909..323c5fc 100644 --- a/examples/rest/stocks-technical_indicators_sma.js +++ b/examples/rest/stocks-technical_indicators_sma.js @@ -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/stocks/get_v1_indicators_sma__stockticker rest.stocks.sma("AAPL").then((data) => { diff --git a/examples/rest/stocks-ticker_details.js b/examples/rest/stocks-ticker_details.js index fca6cf0..e4ce97e 100644 --- a/examples/rest/stocks-ticker_details.js +++ b/examples/rest/stocks-ticker_details.js @@ -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/stocks/get_v3_reference_tickers__ticker rest.reference.tickerDetails("AAPL").then((data) => { diff --git a/examples/rest/stocks-ticker_news.js b/examples/rest/stocks-ticker_news.js index 2a58e45..aaf9e49 100644 --- a/examples/rest/stocks-ticker_news.js +++ b/examples/rest/stocks-ticker_news.js @@ -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/stocks/get_v2_reference_news rest.reference.tickerNews("AAPL").then((data) => { diff --git a/examples/rest/stocks-ticker_types.js b/examples/rest/stocks-ticker_types.js index f264b03..bf4678e 100644 --- a/examples/rest/stocks-ticker_types.js +++ b/examples/rest/stocks-ticker_types.js @@ -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/stocks/get_v3_reference_tickers_types rest.reference.tickerTypes({ asset_class: "stocks"}).then((data) => { diff --git a/examples/rest/stocks-tickers.js b/examples/rest/stocks-tickers.js index f4dc919..b376049 100644 --- a/examples/rest/stocks-tickers.js +++ b/examples/rest/stocks-tickers.js @@ -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/stocks/get_v3_reference_tickers rest.reference.tickers({ market: "stocks", limit: 1000 }).then((data) => { diff --git a/examples/rest/stocks-trades.js b/examples/rest/stocks-trades.js index c2e507f..054a2e4 100644 --- a/examples/rest/stocks-trades.js +++ b/examples/rest/stocks-trades.js @@ -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/stocks/get_v3_trades__stockticker rest.stocks.trades("HCP").then((data) => { diff --git a/examples/rest/universal-snapshot.js b/examples/rest/universal-snapshot.js index a2bd4df..37acfa6 100644 --- a/examples/rest/universal-snapshot.js +++ b/examples/rest/universal-snapshot.js @@ -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); // You can access the universal snapshot endpoint from any asset class client diff --git a/examples/websocket/advanced.js b/examples/websocket/advanced.js index 613a0c3..657c57b 100644 --- a/examples/websocket/advanced.js +++ b/examples/websocket/advanced.js @@ -1,7 +1,8 @@ -const lodash = require('lodash') -const WebSocket = require('ws') -const EventEmitter = require('events').EventEmitter +import lodash from 'lodash'; +import WebSocket from 'ws'; +import { EventEmitter } from 'events'; + const APIKEY = process.env.POLY_API_KEY || 'YOUR_API_KEY' diff --git a/examples/websocket/index.js b/examples/websocket/index.js index 3d531e9..0090451 100644 --- a/examples/websocket/index.js +++ b/examples/websocket/index.js @@ -1,4 +1,5 @@ -const WebSocket = require('ws') +import WebSocket from 'ws'; + const APIKEY = process.env.POLY_API_KEY || 'YOUR_API_KEY' // Connection Type: diff --git a/package-lock.json b/package-lock.json index 97ecaed..55b3693 100644 --- a/package-lock.json +++ b/package-lock.json @@ -24,15 +24,18 @@ "@types/sinon": "^10.0.6", "@types/websocket": "^1.0.4", "chai": "^4.3.4", + "events": "^3.3.0", "husky": "^7.0.4", "lint-staged": "^12.1.2", + "lodash": "^4.17.21", "mocha": "^9.1.3", "prettier": "^2.5.1", "sinon": "^12.0.1", "ts-node": "^10.9.1", "tsup": "^6.7.0", "typedoc": "^0.22.10", - "typescript": "^4.5.2" + "typescript": "^4.5.2", + "ws": "^8.13.0" }, "engines": { "node": ">=16" @@ -1162,6 +1165,15 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/events": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/events/-/events-3.3.0.tgz", + "integrity": "sha512-mQw+2fkQbALzQ7V0MY0IqdnXNOeTtP4r0lN9z7AAawCXgqea7bDii20AYrIBrFd/Hx0M2Ocz6S111CaFkUcb0Q==", + "dev": true, + "engines": { + "node": ">=0.8.x" + } + }, "node_modules/execa": { "version": "5.1.1", "resolved": "https://registry.npmjs.org/execa/-/execa-5.1.1.tgz", @@ -1804,6 +1816,12 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/lodash": { + "version": "4.17.21", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", + "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==", + "dev": true + }, "node_modules/lodash.get": { "version": "4.4.2", "resolved": "https://registry.npmjs.org/lodash.get/-/lodash.get-4.4.2.tgz", @@ -3138,6 +3156,27 @@ "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", "dev": true }, + "node_modules/ws": { + "version": "8.13.0", + "resolved": "https://registry.npmjs.org/ws/-/ws-8.13.0.tgz", + "integrity": "sha512-x9vcZYTrFPC7aSIbj7sRCYo7L/Xb8Iy+pW0ng0wt2vCJv7M9HOMy0UoN3rr+IFC7hb7vXoqS+P9ktyLLLhO+LA==", + "dev": true, + "engines": { + "node": ">=10.0.0" + }, + "peerDependencies": { + "bufferutil": "^4.0.1", + "utf-8-validate": ">=5.0.2" + }, + "peerDependenciesMeta": { + "bufferutil": { + "optional": true + }, + "utf-8-validate": { + "optional": true + } + } + }, "node_modules/y18n": { "version": "5.0.8", "resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz", @@ -3994,6 +4033,12 @@ "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==", "dev": true }, + "events": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/events/-/events-3.3.0.tgz", + "integrity": "sha512-mQw+2fkQbALzQ7V0MY0IqdnXNOeTtP4r0lN9z7AAawCXgqea7bDii20AYrIBrFd/Hx0M2Ocz6S111CaFkUcb0Q==", + "dev": true + }, "execa": { "version": "5.1.1", "resolved": "https://registry.npmjs.org/execa/-/execa-5.1.1.tgz", @@ -4439,6 +4484,12 @@ "p-locate": "^5.0.0" } }, + "lodash": { + "version": "4.17.21", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", + "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==", + "dev": true + }, "lodash.get": { "version": "4.4.2", "resolved": "https://registry.npmjs.org/lodash.get/-/lodash.get-4.4.2.tgz", @@ -5383,6 +5434,13 @@ "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", "dev": true }, + "ws": { + "version": "8.13.0", + "resolved": "https://registry.npmjs.org/ws/-/ws-8.13.0.tgz", + "integrity": "sha512-x9vcZYTrFPC7aSIbj7sRCYo7L/Xb8Iy+pW0ng0wt2vCJv7M9HOMy0UoN3rr+IFC7hb7vXoqS+P9ktyLLLhO+LA==", + "dev": true, + "requires": {} + }, "y18n": { "version": "5.0.8", "resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz", diff --git a/package.json b/package.json index f993512..2bbf571 100644 --- a/package.json +++ b/package.json @@ -59,15 +59,18 @@ "@types/sinon": "^10.0.6", "@types/websocket": "^1.0.4", "chai": "^4.3.4", + "events": "^3.3.0", "husky": "^7.0.4", "lint-staged": "^12.1.2", + "lodash": "^4.17.21", "mocha": "^9.1.3", "prettier": "^2.5.1", "sinon": "^12.0.1", "ts-node": "^10.9.1", "tsup": "^6.7.0", "typedoc": "^0.22.10", - "typescript": "^4.5.2" + "typescript": "^4.5.2", + "ws": "^8.13.0" }, "husky": { "hooks": { From d6a952081bd61b7626ae69259fbcb84dea391b2a Mon Sep 17 00:00:00 2001 From: Katie Adams <64220601+timetraveler328@users.noreply.github.com> Date: Fri, 11 Aug 2023 17:21:47 -0400 Subject: [PATCH 22/39] Release/v7.2.6 (#175) * Changelog for release * 7.2.6 --- CHANGELOG.md | 6 ++++++ package-lock.json | 4 ++-- package.json | 2 +- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 662f90a..89defc1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +## [7.2.6](https://github.com/polygon-io/client-js/compare/v7.2.5...v7.2.6) (2023-08-11) +### Bug Fixes +* Export universal snapshot types +* Add next_url to Aggregates enpdoints response types +* Update examples to use import syntax instead of require + ## [7.2.4](https://github.com/polygon-io/client-js/compare/v7.2.3...v7.2.4) (2023-06-14) ### Bug Fixes * Update snapshot min to support n and t diff --git a/package-lock.json b/package-lock.json index 55b3693..dd21140 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@polygon.io/client-js", - "version": "7.2.5", + "version": "7.2.6", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@polygon.io/client-js", - "version": "7.2.5", + "version": "7.2.6", "license": "MIT", "workspaces": [ "./dist/*", diff --git a/package.json b/package.json index 2bbf571..73735b3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@polygon.io/client-js", - "version": "7.2.5", + "version": "7.2.6", "description": "Isomorphic Javascript client for Polygon.io Stocks, Forex, and Crypto APIs", "main": "dist/main.js", "types": "dist/main.d.ts", From e77bab074270e181f80de31b5e06ca1da97bc58f Mon Sep 17 00:00:00 2001 From: justinpolygon <123573436+justinpolygon@users.noreply.github.com> Date: Thu, 7 Sep 2023 11:51:53 -0700 Subject: [PATCH 23/39] Update README with pagination and trace modes (#176) --- README.md | 72 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) diff --git a/README.md b/README.md index 6616404..8cc095b 100644 --- a/README.md +++ b/README.md @@ -64,6 +64,78 @@ rest.stocks.snapshotAllTickers().then((data) => { 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. +## Pagination + +The client can handle pagination for you through the `globalFetchOptions` by turning on the `pagination: true` option. The feature will automatically fetch all `next_url` pages of data when the API response indicates more data is available. + +```javascript +import('@polygon.io/client-js').then(({ restClient }) => { + const globalFetchOptions = { + pagination: true, + }; + const rest = restClient("XXXX", "https://api.polygon.io", globalFetchOptions); + rest.stocks.aggregates("TSLA", 1, "minute", "2022-01-01", "2023-08-31", { limit: 50000 }).then((data) => { + const resultCount = data.length; + console.log("Result count:", resultCount); + }).catch(e => { + console.error('An error happened:', e); + }); +}); +``` + +If there is a `next_url` field in the API response, the client will recursively fetch the next page for you, and then pass along the accumulated data. + +## Debugging + +Sometimes you may find it useful to see the actual request and response details while working with the API. The client allows for this through the `globalFetchOptions` by turning on the `trace: true` option. + +### How to Enable Debug Mode + +You can activate the debug mode as follows: + +```javascript +import('@polygon.io/client-js').then(({ restClient }) => { + const globalFetchOptions = { + trace: true, + }; + const rest = restClient("XXXX", "https://api.polygon.io", globalFetchOptions); + rest.stocks.aggregates("TSLA", 1, "minute", "2023-08-01", "2023-08-01", { limit: 50000 }).then((data) => { + const resultCount = data.length; + console.log("Result count:", resultCount); + }).catch(e => { + console.error('An error happened:', e); + }); +}); +``` + +### What Does Debug Mode Do? + +When debug mode is enabled, the client will print out useful debugging information for each API request. This includes: the request URL, the headers sent in the request, and the headers received in the response. + +### Example Output + +For instance, if you made a request for `TSLA` data for the date `2023-08-01`, you would see debug output similar to the following: + +``` +Request URL: https://api.polygon.io/v2/aggs/ticker/TSLA/range/1/minute/2023-08-01/2023-08-01?limit=50000 +Request Headers: { Authorization: 'Bearer REDACTED' } +Response Headers: Headers { + [Symbol(map)]: [Object: null prototype] { + server: [ 'nginx/1.19.2' ], + date: [ 'Thu, 06 Jul 2023 18:34:27 GMT' ], + 'content-type': [ 'application/json' ], + 'transfer-encoding': [ 'chunked' ], + connection: [ 'close' ], + 'content-encoding': [ 'gzip' ], + vary: [ 'Accept-Encoding' ], + 'x-request-id': [ '06dc97920681d8335c0451894aa1f79f' ], + 'strict-transport-security': [ 'max-age=15724800; includeSubDomains' ] + } +} +``` + +This can be an invaluable tool for debugging issues or understanding how the client interacts with the API. + ## Launchpad Usage Users of the Launchpad product will need to pass in certain headers in order to make API requests. Example can be found [here](./examples/rest/launchpad/README.md). From 0a1b2cc9f73c9769bc7f9b9654b458a2470ae360 Mon Sep 17 00:00:00 2001 From: justinpolygon <123573436+justinpolygon@users.noreply.github.com> Date: Thu, 7 Sep 2023 11:52:33 -0700 Subject: [PATCH 24/39] Added request tracing and API pagination support (#164) * Added request tracing and API pagination support * Added paginationEnabled option * Update pagination flag name --- src/rest/transport/request.ts | 108 +++++++++++++++++++++++----------- 1 file changed, 75 insertions(+), 33 deletions(-) diff --git a/src/rest/transport/request.ts b/src/rest/transport/request.ts index c517048..ef505d7 100644 --- a/src/rest/transport/request.ts +++ b/src/rest/transport/request.ts @@ -24,7 +24,13 @@ export interface IPolygonQueryWithCredentials extends IPolygonQuery { } export type IGet = (path: string, query: IPolygonQuery, options: IRequestOptions) => Promise; -export type ICurriedGet = (apiKey: string, apiBase: string, globalOptions?: IRequestOptions) => IGet; + +export interface IGlobalOptions extends IRequestOptions { + trace?: boolean; + pagination?: boolean; +} + +export type ICurriedGet = (apiKey: string, apiBase: string, globalOptions?: IGlobalOptions) => IGet; export type IStructuredError = InstanceType; class StructuredError extends Error { @@ -37,44 +43,80 @@ class StructuredError extends Error { } } -export const getWithGlobals: ICurriedGet = (apiKey, apiBase, globalOptions = {}): IGet => - async ( path, query = {}, options = {} ): Promise => { - if (!apiKey) { - throw new Error("API KEY not configured..."); - } +export const getWithGlobals: ICurriedGet = (apiKey, apiBase, globalOptions = {}): IGet => + async (path, query = {}, options = {}): Promise => { + if(!apiKey) { + throw new Error("API KEY not configured..."); + } - const queryString = stringify(query, { encode: true }); - const url = `${apiBase}${path}?${queryString}`; - try { - const response = await fetchModule.fetch(url, { - ...globalOptions, - ...options, - headers: { + const fetchPage = async (path, query = {}, options: IRequestOptions = {}, allData = []): Promise => { + const queryString = stringify(query, { + encode: true + }); + const url = `${apiBase}${path}${queryString ? '?' + queryString : ''}`; + const headers = { ...(options.headers || globalOptions.headers || {}), "Authorization": `Bearer ${apiKey}` } - }); - if (response.status >= 400) { - const rawMessage = await response.text(); - let error; + if(globalOptions.trace) { + console.log("Request URL: ", url); + + // make a copy of headers so as not to modify the original + const printHeaders = { + ...headers + }; + if('Authorization' in printHeaders) { + printHeaders['Authorization'] = printHeaders['Authorization'].replace(apiKey, 'REDACTED'); + } + + console.log("Request Headers: ", printHeaders); + } + try { - // first try parsing JSON from the response - const json = JSON.parse(rawMessage); - error = new StructuredError(json.message, json.status, json.request_id); + const response = await fetchModule.fetch(url, { + ...globalOptions, + ...options, + headers: headers + }); + + if(globalOptions.trace) { + console.log("Response Headers: ", response.headers); + } + + if(response.status >= 400) { + const rawMessage = await response.text(); + let error; + try { + // first try parsing JSON from the response + const json = JSON.parse(rawMessage); + error = new StructuredError(json.message, json.status, json.request_id); + } catch (e) { + // default to sending a string error message + error = new Error(rawMessage); + } + throw error; + } + + if(response?.headers?.get('content-type') === 'text/csv') { + return response.text(); + } + + const json = await response.json(); + const newData = allData.concat(json.results); + + // check if there is a next page, pagination is enabled, and fetch it recursively + if(globalOptions.pagination && json.next_url) { + const nextPath = json.next_url.replace(apiBase, ""); + return fetchPage(nextPath, {}, options, newData); + } else { + return newData; + } + } catch (e) { - // default to sending a string error message - error = new Error(rawMessage); + throw e; } - throw error; - } - - if (response?.headers?.get('content-type') === 'text/csv') { - return response.text(); - } + }; - return response.json(); - } catch (e) { - throw e; - } -}; + return fetchPage(path, query, options); + }; From 75aa6edc0b0ca5ebcce92ce9c4db6546dcae093e Mon Sep 17 00:00:00 2001 From: Meekit Patel <36168387+mpatel18@users.noreply.github.com> Date: Thu, 7 Sep 2023 15:16:03 -0400 Subject: [PATCH 25/39] Release/v7.3.0 (#177) * 7.3.0 * Update CHANGELOG.md --- CHANGELOG.md | 5 +++++ package-lock.json | 4 ++-- package.json | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 89defc1..6dee1f6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +## [7.3.0](https://github.com/polygon-io/client-js/compare/v7.2.6...v7.3.0) (2023-08-11) +### New Feature +* Update README with pagination and trace modes +* Added request tracing and API pagination support + ## [7.2.6](https://github.com/polygon-io/client-js/compare/v7.2.5...v7.2.6) (2023-08-11) ### Bug Fixes * Export universal snapshot types diff --git a/package-lock.json b/package-lock.json index dd21140..2d9fd8a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@polygon.io/client-js", - "version": "7.2.6", + "version": "7.3.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@polygon.io/client-js", - "version": "7.2.6", + "version": "7.3.0", "license": "MIT", "workspaces": [ "./dist/*", diff --git a/package.json b/package.json index 73735b3..d616d2b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@polygon.io/client-js", - "version": "7.2.6", + "version": "7.3.0", "description": "Isomorphic Javascript client for Polygon.io Stocks, Forex, and Crypto APIs", "main": "dist/main.js", "types": "dist/main.d.ts", From 507a889c6ab8c8f1d039eeb45c62b0b5fef7ccc1 Mon Sep 17 00:00:00 2001 From: Katie Adams <64220601+timetraveler328@users.noreply.github.com> Date: Mon, 18 Sep 2023 09:20:22 -0400 Subject: [PATCH 26/39] Fixes the response format, also adds tests to make sure changes to this have coverage (#179) * Fix hole in testing, also maybe fixed the request format * 7.3.1 * Release notes --- CHANGELOG.md | 9 +++- package-lock.json | 4 +- package.json | 2 +- src/rest/crypto/index.test.ts | 6 +++ src/rest/forex/index.test.ts | 6 +++ src/rest/indices/index.test.ts | 6 +++ src/rest/options/index.test.ts | 6 +++ src/rest/stocks/index.test.ts | 11 ++++- src/rest/transport/index.test.ts | 76 ++++++++++++++++++++++++++++++++ src/rest/transport/request.ts | 12 +++-- 10 files changed, 128 insertions(+), 10 deletions(-) create mode 100644 src/rest/transport/index.test.ts diff --git a/CHANGELOG.md b/CHANGELOG.md index 6dee1f6..c84be1a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,11 @@ -## [7.3.0](https://github.com/polygon-io/client-js/compare/v7.2.6...v7.3.0) (2023-08-11) +## [7.3.1](https://github.com/polygon-io/client-js/compare/v7.3.0...v7.3.1) (2023-09-15) +### Bug Fixes +* Fix unintended change to top level response object that returned results array instead of results object + +### Other Changes +* Improved test coverage for response object + +## [7.3.0](https://github.com/polygon-io/client-js/compare/v7.2.6...v7.3.0) (2023-09-11) ### New Feature * Update README with pagination and trace modes * Added request tracing and API pagination support diff --git a/package-lock.json b/package-lock.json index 2d9fd8a..9c5f3f0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@polygon.io/client-js", - "version": "7.3.0", + "version": "7.3.1", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@polygon.io/client-js", - "version": "7.3.0", + "version": "7.3.1", "license": "MIT", "workspaces": [ "./dist/*", diff --git a/package.json b/package.json index d616d2b..f7c0bf9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@polygon.io/client-js", - "version": "7.3.0", + "version": "7.3.1", "description": "Isomorphic Javascript client for Polygon.io Stocks, Forex, and Crypto APIs", "main": "dist/main.js", "types": "dist/main.d.ts", diff --git a/src/rest/crypto/index.test.ts b/src/rest/crypto/index.test.ts index 6e0f165..8c5e2b9 100644 --- a/src/rest/crypto/index.test.ts +++ b/src/rest/crypto/index.test.ts @@ -37,6 +37,12 @@ describe("[REST] Crypto", () => { sandbox.restore(); }); + it("should have appropriate results", async () => { + setStub({ results: [{ o: 1}] }); + const response = await crypto.aggregates("AAPL", 1, "day", "2019-01-01", "2019-02-01", mocks.query, mocks.overrideOptions); + response.results![0].t?.should.eql(1); + }); + it("aggregates call /v2/aggs/ticker/{ticker}/range/{multiplier}/{timespan}/{from}/{to}", async () => { setStub({ results: [] }); await crypto.aggregates("BTC", 1, "day", "2019-01-01", "2019-02-01", mocks.query, mocks.overrideOptions); diff --git a/src/rest/forex/index.test.ts b/src/rest/forex/index.test.ts index fc3ea0f..88cc6e4 100644 --- a/src/rest/forex/index.test.ts +++ b/src/rest/forex/index.test.ts @@ -37,6 +37,12 @@ describe("[REST] Forex / Currencies", () => { sandbox.restore(); }); + it("should have appropriate results", async () => { + setStub({ results: [{ o: 1}] }); + const response = await fx.aggregates("AAPL", 1, "day", "2019-01-01", "2019-02-01", mocks.query, mocks.overrideOptions); + response.results![0].t?.should.eql(1); + }); + it("aggregates call /v2/aggs/ticker/{ticker}/range/{multiplier}/{timespan}/{from}/{to}", async () => { setStub({ results: [] }); await fx.aggregates("EURCHF", 1, "day", "2019-01-01", "2019-02-01", mocks.query, mocks.overrideOptions); diff --git a/src/rest/indices/index.test.ts b/src/rest/indices/index.test.ts index f749015..df9f7c1 100644 --- a/src/rest/indices/index.test.ts +++ b/src/rest/indices/index.test.ts @@ -38,6 +38,12 @@ describe("[REST] Indices", () => { sandbox.restore(); }); + it("should have appropriate results", async () => { + setStub({ results: [{ o: 1}] }); + const response = await indices.aggregates("AAPL", 1, "day", "2019-01-01", "2019-02-01", mocks.query, mocks.overrideOptions); + response.results![0].t?.should.eql(1); + }); + it("aggregates call /v2/aggs/ticker/{ticker}/range/{multiplier}/{timespan}/{from}/{to}", async () => { setStub({ results: [] }); await indices.aggregates("AAPL", 1, "day", "2019-01-01", "2019-02-01", mocks.query, mocks.overrideOptions); diff --git a/src/rest/options/index.test.ts b/src/rest/options/index.test.ts index 304e62a..85a79b2 100644 --- a/src/rest/options/index.test.ts +++ b/src/rest/options/index.test.ts @@ -38,6 +38,12 @@ describe("[REST] Options", () => { sandbox.restore(); }); + it("should have appropriate results", async () => { + setStub({ results: [{ o: 1}] }); + const response = await options.aggregates("AAPL", 1, "day", "2019-01-01", "2019-02-01", mocks.query, mocks.overrideOptions); + response.results![0].t?.should.eql(1); + }); + it("aggregates call /v2/aggs/ticker/{ticker}/range/{multiplier}/{timespan}/{from}/{to}", async () => { setStub({ results: [] }); await options.aggregates("AAPL", 1, "day", "2019-01-01", "2019-02-01", mocks.query, mocks.overrideOptions); diff --git a/src/rest/stocks/index.test.ts b/src/rest/stocks/index.test.ts index 2846ff7..244431b 100644 --- a/src/rest/stocks/index.test.ts +++ b/src/rest/stocks/index.test.ts @@ -38,13 +38,20 @@ describe("[REST] Stocks", () => { sandbox.restore(); }); + it("should have appropriate results", async () => { + setStub({ results: [{ o: 1}] }); + const response = await stocks.aggregates("AAPL", 1, "day", "2019-01-01", "2019-02-01", mocks.query, mocks.overrideOptions); + response.results![0].t?.should.eql(1); + }); + it("aggregates call /v2/aggs/ticker/{ticker}/range/{multiplier}/{timespan}/{from}/{to}", async () => { - setStub({ results: [] }); - await stocks.aggregates("AAPL", 1, "day", "2019-01-01", "2019-02-01", mocks.query, mocks.overrideOptions); + setStub({ results: [{ o: 1}] }); + const response = await stocks.aggregates("AAPL", 1, "day", "2019-01-01", "2019-02-01", mocks.query, mocks.overrideOptions); fetchStub.callCount.should.eql(1); getPath(fetchStub.getCalls()[0].args[0]).should.eql( "/v2/aggs/ticker/AAPL/range/1/day/2019-01-01/2019-02-01" ); + response.results?.[0].o?.should.eql(1); fetchStub.getCalls()[0].args[0].indexOf(mocks.query.query1).should.be.gt(-1); fetchStub.getCalls()[0].args[1].referrer.should.eql(mocks.overrideOptions.referrer); fetchStub.getCalls()[0].args[1].headers.header1.should.eql(mocks.globalOptions.headers.header1); diff --git a/src/rest/transport/index.test.ts b/src/rest/transport/index.test.ts new file mode 100644 index 0000000..80e2bf5 --- /dev/null +++ b/src/rest/transport/index.test.ts @@ -0,0 +1,76 @@ +import * as sinon from "sinon"; +import * as chai from "chai"; +import fetchModule from '../transport/fetch'; +import { getWithGlobals } from '../transport/request'; + +describe("[REST] Stocks", () => { + chai.should(); + const mocks = { + key: 'invalid', + base: 'https://test.api.polygon.io', + query: { query1: 'queryVal' }, + overrideOptions: { + referrer: 'overrideVal' + }, + globalOptions: { + referrer: 'globalVal1', + headers: { + header1: 'headerVal1' + } + } + }; + let fetchStub; + const sandbox = sinon.createSandbox(); + const getPath = (url) => url.slice(mocks.base.length, url.indexOf('?')); + const setStub = (returnVal, status = 200) => { + fetchStub?.restore(); + fetchStub = sandbox.stub(fetchModule, 'fetch').returns( + Promise.resolve({ json: () => Promise.resolve(returnVal), status } as Response) + ); + } + const setStubs = (returnVal1, returnVal2, status = 200) => { + fetchStub?.restore(); + fetchStub = sandbox.stub(fetchModule, 'fetch').onCall(0).returns( + Promise.resolve({ json: () => Promise.resolve(returnVal1), status } as Response) + ).onCall(1).returns( + Promise.resolve({ json: () => Promise.resolve(returnVal2), status } as Response) + ); + } + beforeEach(async () => { + setStub({ ticks: [], results: [], tickers: [] }); + }); + afterEach(() => { + sandbox.restore(); + }); + + it("Returns the expected result when pagination is not enabled", async () => { + setStub({ results: [{ a: 1 }] }); + const requestFn = getWithGlobals(mocks.key, mocks.base, mocks.globalOptions); + const response = await requestFn("/v2/aggs/ticker/AAPL/range/1/day/2019-01-01/2019-02-01", mocks.query, mocks.overrideOptions); + response.results[0].a.should.eql(1); + fetchStub.callCount.should.eql(1); + getPath(fetchStub.getCalls()[0].args[0]).should.eql( + "/v2/aggs/ticker/AAPL/range/1/day/2019-01-01/2019-02-01" + ); + fetchStub.getCalls()[0].args[0].indexOf(mocks.query.query1).should.be.gt(-1); + fetchStub.getCalls()[0].args[1].referrer.should.eql(mocks.overrideOptions.referrer); + fetchStub.getCalls()[0].args[1].headers.header1.should.eql(mocks.globalOptions.headers.header1); + }); + + + it("Returns the expected result when pagination is enabled", async () => { + setStubs({ results: [{ a: 1 }], next_url: "/v2/aggs/ticker/AAPL/range/1/day/2019-01-01/2019-02-02" }, { results: [{ b: 2 }], }); + const requestFn = getWithGlobals(mocks.key, mocks.base, {...mocks.globalOptions, pagination: true}); + const response = await requestFn("/v2/aggs/ticker/AAPL/range/1/day/2019-01-01/2019-02-01", mocks.query, mocks.overrideOptions); + response.results.length.should.eql(2); + response.results[0].a.should.eql(1); + response.results[1].b.should.eql(2); + fetchStub.callCount.should.eql(2); + getPath(fetchStub.getCalls()[0].args[0]).should.eql( + "/v2/aggs/ticker/AAPL/range/1/day/2019-01-01/2019-02-01" + ); + fetchStub.getCalls()[0].args[0].indexOf(mocks.query.query1).should.be.gt(-1); + fetchStub.getCalls()[0].args[1].referrer.should.eql(mocks.overrideOptions.referrer); + fetchStub.getCalls()[0].args[1].headers.header1.should.eql(mocks.globalOptions.headers.header1); + }); +}); diff --git a/src/rest/transport/request.ts b/src/rest/transport/request.ts index ef505d7..14639ac 100644 --- a/src/rest/transport/request.ts +++ b/src/rest/transport/request.ts @@ -103,14 +103,18 @@ export const getWithGlobals: ICurriedGet = (apiKey, apiBase, globalOptions = {}) } const json = await response.json(); - const newData = allData.concat(json.results); + const newData = json.results instanceof Array ? allData.concat(json.results) : allData; - // check if there is a next page, pagination is enabled, and fetch it recursively - if(globalOptions.pagination && json.next_url) { + if(globalOptions?.pagination && json.next_url) { + // check if there is a next page, pagination is enabled, and fetch it recursively const nextPath = json.next_url.replace(apiBase, ""); return fetchPage(nextPath, {}, options, newData); + } else if (globalOptions?.pagination) { + // check if there is a next page, pagination is enabled, and fetch it recursively + return { ...json, results: newData, count: newData.length, next_url: null } } else { - return newData; + // just return the response + return json; } } catch (e) { From 8df798856551b76a134e682ad3f1680708d145fe Mon Sep 17 00:00:00 2001 From: Katie Adams <64220601+timetraveler328@users.noreply.github.com> Date: Thu, 5 Oct 2023 16:38:20 -0400 Subject: [PATCH 27/39] Patch for global config option types (#182) * Fixes #181, adds optional global config attributes to options type for pagination and trace. * Changelog * 7.3.2 --- CHANGELOG.md | 4 ++++ package-lock.json | 4 ++-- package.json | 2 +- src/rest/transport/request.ts | 12 +++++++----- 4 files changed, 14 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c84be1a..4b4083f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## [7.3.2](https://github.com/polygon-io/client-js/compare/v7.3.1...v7.3.2) (2023-10-05) +### Bug Fixes +* Rearrange request config types so they inherit global options for pagination and trace + ## [7.3.1](https://github.com/polygon-io/client-js/compare/v7.3.0...v7.3.1) (2023-09-15) ### Bug Fixes * Fix unintended change to top level response object that returned results array instead of results object diff --git a/package-lock.json b/package-lock.json index 9c5f3f0..c63bfa2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@polygon.io/client-js", - "version": "7.3.1", + "version": "7.3.2", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@polygon.io/client-js", - "version": "7.3.1", + "version": "7.3.2", "license": "MIT", "workspaces": [ "./dist/*", diff --git a/package.json b/package.json index f7c0bf9..d9f8020 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@polygon.io/client-js", - "version": "7.3.1", + "version": "7.3.2", "description": "Isomorphic Javascript client for Polygon.io Stocks, Forex, and Crypto APIs", "main": "dist/main.js", "types": "dist/main.d.ts", diff --git a/src/rest/transport/request.ts b/src/rest/transport/request.ts index 14639ac..832add5 100644 --- a/src/rest/transport/request.ts +++ b/src/rest/transport/request.ts @@ -17,7 +17,12 @@ export interface IRequestInit extends Omit { headers?: IHeaders } -export type IRequestOptions = IRequestInit; +export interface IGlobalOptions extends IRequestInit { + trace?: boolean; + pagination?: boolean; +} + +export type IRequestOptions = IGlobalOptions; export interface IPolygonQueryWithCredentials extends IPolygonQuery { apiKey: string | boolean; @@ -25,10 +30,7 @@ export interface IPolygonQueryWithCredentials extends IPolygonQuery { export type IGet = (path: string, query: IPolygonQuery, options: IRequestOptions) => Promise; -export interface IGlobalOptions extends IRequestOptions { - trace?: boolean; - pagination?: boolean; -} + export type ICurriedGet = (apiKey: string, apiBase: string, globalOptions?: IGlobalOptions) => IGet; export type IStructuredError = InstanceType; From e0b8a5ff1147ab9a3c9b29cc7c0cf868de1e2422 Mon Sep 17 00:00:00 2001 From: Katie Adams <64220601+timetraveler328@users.noreply.github.com> Date: Mon, 6 Nov 2023 16:00:26 -0500 Subject: [PATCH 28/39] Fix/ws examples (#185) * Update websocket examples and add one for Polygon Business * Fix double tabs --- examples/websocket/polygon-business.js | 29 ++++++++++++++++++ examples/websocket/polygon-client-library.js | 30 +++++++++++++++++++ .../{advanced.js => ws-library-advanced.js} | 4 +-- .../{index.js => ws-library-simple.js} | 9 ++++-- 4 files changed, 68 insertions(+), 4 deletions(-) create mode 100644 examples/websocket/polygon-business.js create mode 100644 examples/websocket/polygon-client-library.js rename examples/websocket/{advanced.js => ws-library-advanced.js} (93%) rename examples/websocket/{index.js => ws-library-simple.js} (77%) diff --git a/examples/websocket/polygon-business.js b/examples/websocket/polygon-business.js new file mode 100644 index 0000000..25730cd --- /dev/null +++ b/examples/websocket/polygon-business.js @@ -0,0 +1,29 @@ +import { websocketClient } from "@polygon.io/client-js"; + +/* + This example uses polygon client-js library to connect to the polygon stocks for business + websocket to subscribe to the fair market value channel for the ticker AAPL. +*/ + +// create a websocket client using the polygon client-js library +const ws = websocketClient('API KEY', 'wss://business.polygon.io').stocks(); + +// register a handler to log errors +ws.onerror = (err) => console.log('Failed to connect', err); + +// register a handler to log info if websocket closes +ws.onclose = (code, reason) => console.log('Connection closed', code, reason); + +// register a handler when messages are received +ws.onmessage = (msg) => { + // parse the data from the message + const parsedMessage = JSON.parse(msg.data); + + // wait until the message saying authentication was successful, then subscribe to a channel + if (parsedMessage[0].ev === 'status' && parsedMessage[0].status === 'auth_success') { + console.log('Subscribing to Fair Market Value channel for ticker AAPL'); + ws.send(JSON.stringify({"action":"subscribe", "params":"FMV.AAPL"})); + } + + console.log('Message received:', parsedMessage); +} \ No newline at end of file diff --git a/examples/websocket/polygon-client-library.js b/examples/websocket/polygon-client-library.js new file mode 100644 index 0000000..f84b2d5 --- /dev/null +++ b/examples/websocket/polygon-client-library.js @@ -0,0 +1,30 @@ +/* + This example uses polygon client-js library to connect to the delayed stocks polygon + websocket to subscribe to minute ohlc values for the ticker AAPL. +*/ + +import { websocketClient } from "@polygon.io/client-js"; + +// create a websocket client using the polygon client-js library +const ws = websocketClient('API KEY', 'wss://delayed.polygon.io').stocks(); // 15-min delay websocket +// const ws = websocketClient('API KEY', 'wss://socket.polygon.io').stocks(); // real-time webscoket + +// register a handler to log errors +ws.onerror = (err) => console.log('Failed to connect', err); + +// register a handler to log info if websocket closes +ws.onclose = (code, reason) => console.log('Connection closed', code, reason); + +// register a handler when messages are received +ws.onmessage = (msg) => { + // parse the data from the message + const parsedMessage = JSON.parse(msg.data); + + // wait until the message saying authentication was successful, then subscribe to a channel + if (parsedMessage[0].ev === 'status' && parsedMessage[0].status === 'auth_success') { + console.log('Subscribing to the minute aggregates channel for ticker AAPL'); + ws.send(JSON.stringify({"action":"subscribe", "params":"AM.AAPL"})); + } + + console.log('Message received:', parsedMessage); +} diff --git a/examples/websocket/advanced.js b/examples/websocket/ws-library-advanced.js similarity index 93% rename from examples/websocket/advanced.js rename to examples/websocket/ws-library-advanced.js index 657c57b..7296a16 100644 --- a/examples/websocket/advanced.js +++ b/examples/websocket/ws-library-advanced.js @@ -7,8 +7,8 @@ const APIKEY = process.env.POLY_API_KEY || 'YOUR_API_KEY' /* - This example is similar to the basic example provided, however - in addition it offers reconnection logic, as well as an easier + This example also uses the ws (https://github.com/websockets/ws) library to connect to a websocket, + adding reconnection logic, as well as an easier way to process each type of messages. We can use the `subscribe` method at any time to subscribe to more channels.. */ diff --git a/examples/websocket/index.js b/examples/websocket/ws-library-simple.js similarity index 77% rename from examples/websocket/index.js rename to examples/websocket/ws-library-simple.js index 0090451..79dab5d 100644 --- a/examples/websocket/index.js +++ b/examples/websocket/ws-library-simple.js @@ -1,3 +1,8 @@ +/* + This example uses the ws (https://github.com/websockets/ws) library to connect to the delayed stocks polygon + websocket to subscribe to minute ohlc values for the ticker AAPL. +*/ + import WebSocket from 'ws'; const APIKEY = process.env.POLY_API_KEY || 'YOUR_API_KEY' @@ -16,8 +21,8 @@ ws.on('open', () => { //ws.send(`{"action":"subscribe","params":"C.AUD/USD,C.USD/EUR,C.USD/JPY"}`) // aggregates - //ws.send(`{"action":"subscribe","params":"AM.*"}`) // min - ws.send(`{"action":"subscribe","params":"A.*"}`) // sec + ws.send(`{"action":"subscribe","params":"AM.*"}`) // min + // ws.send(`{"action":"subscribe","params":"A.*"}`) // sec // trades //ws.send(`{"action":"subscribe","params":"T.*"}`) From 7fbbf6d191b663e342d95fb2e8df0514173fdeb1 Mon Sep 17 00:00:00 2001 From: Hunter <6395201+HunterL@users.noreply.github.com> Date: Mon, 22 Apr 2024 16:50:58 -0400 Subject: [PATCH 29/39] Add cboe cgi to IIndicesGroups (#192) --- src/rest/reference/marketStatus.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/rest/reference/marketStatus.ts b/src/rest/reference/marketStatus.ts index 2acaa1e..41c7bfc 100644 --- a/src/rest/reference/marketStatus.ts +++ b/src/rest/reference/marketStatus.ts @@ -5,6 +5,7 @@ import { IGet, IPolygonQuery, IRequestOptions } from "../transport/request.js"; export interface IIndicesGroups { s_and_p?: string; societe_generale?: string; + cgi?: string; msci?: string; ftse_russell?: string; mstar?: string; From 71d2b11bf66200304341fa6ba7b8bcfa0b3e992d Mon Sep 17 00:00:00 2001 From: justinpolygon <123573436+justinpolygon@users.noreply.github.com> Date: Fri, 6 Sep 2024 06:26:13 -0700 Subject: [PATCH 30/39] Update README.md (#187) --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 8cc095b..f7ea0f0 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ For upgrade instructions please see the [Release Notes](./CHANGELOG.md). To get started, you'll need to install the client library: ```bash -npm install --save @polygon.io/client-js +npm install --save `@polygon.io/client-js` ``` Next, create a new client with your [API key](https://polygon.io/dashboard/signup). From 24ee29e82b797829f764ca64046ea220c24cd94e Mon Sep 17 00:00:00 2001 From: Hunter <6395201+HunterL@users.noreply.github.com> Date: Thu, 3 Oct 2024 13:14:43 -0400 Subject: [PATCH 31/39] Add Missing Fields for Universal Snapshots (#201) * add ask and bid exchange fields to last quote for universal snapshots * add fmv to UniversalSnapshotInfo --- src/rest/universal/universalSnapshot.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/rest/universal/universalSnapshot.ts b/src/rest/universal/universalSnapshot.ts index c5525c6..cc435ab 100644 --- a/src/rest/universal/universalSnapshot.ts +++ b/src/rest/universal/universalSnapshot.ts @@ -21,8 +21,10 @@ export interface UniversalSnapshotLastQuote { timeframe?: string; ask?: number; ask_size?: number; + ask_exchange?: number, bid?: number; bid_size?: number; + bid_exchange?: number; midpoint?: number; exchange?: number; } @@ -77,6 +79,7 @@ export interface UniversalSnapshotInfo { underlying_asset?: UniversalSnapshotUnderlyingAsset; value?: number; break_even_price?: number; + fmv?: number; } export interface IUniversalSnapshotQuery extends IPolygonQuery { From f90298342cbf46ce09d6e67b17f96a21c11bc25e Mon Sep 17 00:00:00 2001 From: Hunter <6395201+HunterL@users.noreply.github.com> Date: Tue, 22 Oct 2024 10:42:21 -0400 Subject: [PATCH 32/39] add regular_trading_change and regular_trading_change_percent to the universal snapshot session response (#203) --- src/rest/universal/universalSnapshot.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/rest/universal/universalSnapshot.ts b/src/rest/universal/universalSnapshot.ts index cc435ab..ea758d2 100644 --- a/src/rest/universal/universalSnapshot.ts +++ b/src/rest/universal/universalSnapshot.ts @@ -5,6 +5,8 @@ export interface UniversalSnapshotSession { change_percent?: number; early_trading_change?: number; early_trading_change_percent?: number; + regular_trading_change?: number; + regular_trading_change_percent?: number; late_trading_change?: number; late_trading_change_percent?: number; close?: number; From 7fa989767a89d89122c359c884bd90334776aa2f Mon Sep 17 00:00:00 2001 From: Huseyin ELMAS Date: Tue, 25 Feb 2025 22:00:56 +0300 Subject: [PATCH 33/39] fix: missing timeframe `ttm` in stock financials (#195) --- src/rest/reference/stockFinancials.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rest/reference/stockFinancials.ts b/src/rest/reference/stockFinancials.ts index 7577d75..448d797 100644 --- a/src/rest/reference/stockFinancials.ts +++ b/src/rest/reference/stockFinancials.ts @@ -62,7 +62,7 @@ export interface IStockFinancialQuery extends IPolygonQuery { "period_of_report_date.lte"?: string; "period_of_report_date.gt"?: string; "period_of_report_date.gte"?: string; - timeframe?: "annual" | "quarterly"; + timeframe?: "annual" | "quarterly" | "ttm"; included_sources?: "true" | "false"; order?: "asc" | "desc"; limit?: number; From ce7e849b7332e54539c1aee2471c0935d424dffa Mon Sep 17 00:00:00 2001 From: Huseyin ELMAS Date: Tue, 25 Feb 2025 22:01:10 +0300 Subject: [PATCH 34/39] fix: market status `afterhours` typo (#196) --- src/rest/reference/marketStatus.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rest/reference/marketStatus.ts b/src/rest/reference/marketStatus.ts index 41c7bfc..7b66f99 100644 --- a/src/rest/reference/marketStatus.ts +++ b/src/rest/reference/marketStatus.ts @@ -16,7 +16,7 @@ export interface IIndicesGroups { } export interface IMarketStatus { - afterhours?: boolean; + afterHours?: boolean; currencies?: { fx?: string; crypto?: string; From 794d098f45ba3953c478aae7b1622586fe544fd8 Mon Sep 17 00:00:00 2001 From: David O'Trakoun <113943464+dotrakoun-clearstreet@users.noreply.github.com> Date: Tue, 25 Feb 2025 14:01:43 -0500 Subject: [PATCH 35/39] Update tickers.ts (#206) fix types to match api docs --- src/rest/reference/tickers.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/rest/reference/tickers.ts b/src/rest/reference/tickers.ts index 6cc7f9f..7dbc926 100644 --- a/src/rest/reference/tickers.ts +++ b/src/rest/reference/tickers.ts @@ -16,7 +16,7 @@ export type TickerTypes = | "INDEX" | "ETF" | "ETN"; -export type MarketType = "stocks" | "crypto" | "fx"; +export type MarketType = "stocks" | "crypto" | "fx" | "otc" | "indices"; export type Order = "asc" | "desc"; export interface ITickersQuery extends IPolygonQuery { @@ -42,7 +42,7 @@ export interface ITickersQuery extends IPolygonQuery { export interface ITickersResults { ticker: string; name: string; - market: string; + market: MarketType; locale: string; primary_exchange: string; type: string; From 76c3a68d5ff8aca8e6028af31f8a009080b37be5 Mon Sep 17 00:00:00 2001 From: Katie Adams <64220601+timetraveler328@users.noreply.github.com> Date: Tue, 25 Feb 2025 14:26:57 -0500 Subject: [PATCH 36/39] 7.4.0 --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index c63bfa2..8a83493 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@polygon.io/client-js", - "version": "7.3.2", + "version": "7.4.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@polygon.io/client-js", - "version": "7.3.2", + "version": "7.4.0", "license": "MIT", "workspaces": [ "./dist/*", diff --git a/package.json b/package.json index d9f8020..628a84e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@polygon.io/client-js", - "version": "7.3.2", + "version": "7.4.0", "description": "Isomorphic Javascript client for Polygon.io Stocks, Forex, and Crypto APIs", "main": "dist/main.js", "types": "dist/main.d.ts", From d557f7527ab19c98e56087265a3025cedfcdcec7 Mon Sep 17 00:00:00 2001 From: Tyler Date: Mon, 31 Mar 2025 09:52:50 -0500 Subject: [PATCH 37/39] fix: typo in options snapshot details type (#214) --- src/rest/options/snapshots.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rest/options/snapshots.ts b/src/rest/options/snapshots.ts index 52b92a3..fa82d32 100644 --- a/src/rest/options/snapshots.ts +++ b/src/rest/options/snapshots.ts @@ -17,7 +17,7 @@ export interface SnapshotDay { export interface SnapshotDetails { contract_type?: string; - exercise_styled?: string; + exercise_style?: string; expiration_date?: string; shares_per_contract?: number; strike_price?: number; From c54e6e5f4dbaf442cb633714651c8c5ceb2b2f9e Mon Sep 17 00:00:00 2001 From: Hamir Mahal Date: Mon, 28 Apr 2025 23:50:27 -0700 Subject: [PATCH 38/39] fix: `No such file or directory` output on install (#219) * chore: changes from formatting on save * fix: `No such file or directory` output on install Without this commit, [the install command](https://github.com/polygon-io/client-js/blob/master/README.md?plain=1#L14) results in additional ``` bash: @polygon.io/client-js@next: No such file or directory ``` output with ``` $ bash --version GNU bash, version 5.1.16(1)-release (x86_64-pc-linux-gnu) ``` --- ``` $ npm install --save `@polygon.io/client-js@next` bash: @polygon.io/client-js@next: No such file or directory up to date, audited 854 packages in 1s 161 packages are looking for funding run `npm fund` for details 14 vulnerabilities (1 low, 8 moderate, 5 high) To address issues that do not require attention, run: npm audit fix To address all issues (including breaking changes), run: npm audit fix --force Run `npm audit` for details. ``` With this commit, the install command doesn't have that additional output. ``` npm install --save '@polygon.io/client-js' changed 5 packages, and audited 262 packages in 2s 50 packages are looking for funding run `npm fund` for details 14 vulnerabilities (1 low, 7 moderate, 6 high) To address issues that do not require attention, run: npm audit fix To address all issues (including breaking changes), run: npm audit fix --force Run `npm audit` for details. ``` --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index f7ea0f0..ec35221 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ For upgrade instructions please see the [Release Notes](./CHANGELOG.md). To get started, you'll need to install the client library: ```bash -npm install --save `@polygon.io/client-js` +npm install --save '@polygon.io/client-js' ``` Next, create a new client with your [API key](https://polygon.io/dashboard/signup). @@ -61,8 +61,8 @@ rest.stocks.snapshotAllTickers().then((data) => { }); ``` -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. +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. ## Pagination From 794d005d366afd4be0efe1f820b3bdb11c339609 Mon Sep 17 00:00:00 2001 From: justinpolygon <123573436+justinpolygon@users.noreply.github.com> Date: Wed, 30 Apr 2025 11:09:29 -0700 Subject: [PATCH 39/39] Fixed update README, remove launchpad, and repo contact (#222) * Fixed update README, remove launchpad, and repo contact * Update package.json --------- Co-authored-by: Justin --- README.md | 4 ---- examples/rest/launchpad/README.md | 26 -------------------------- examples/rest/launchpad/index.js | 18 ------------------ package.json | 12 ++---------- 4 files changed, 2 insertions(+), 58 deletions(-) delete mode 100644 examples/rest/launchpad/README.md delete mode 100644 examples/rest/launchpad/index.js diff --git a/README.md b/README.md index ec35221..db40c9d 100644 --- a/README.md +++ b/README.md @@ -136,10 +136,6 @@ Response Headers: Headers { This can be an invaluable tool for debugging issues or understanding how the client interacts with the API. -## Launchpad Usage - -Users of the Launchpad product will need to pass in certain headers in order to make API requests. Example can be found [here](./examples/rest/launchpad/README.md). - ## WebSocket Client Import the [Websocket](https://polygon.io/docs/stocks/ws_getting-started) client and models packages to get started. You can get preauthenticated [websocket clients](https://www.npmjs.com/package/websocket) for the 3 topics. diff --git a/examples/rest/launchpad/README.md b/examples/rest/launchpad/README.md deleted file mode 100644 index c4184a7..0000000 --- a/examples/rest/launchpad/README.md +++ /dev/null @@ -1,26 +0,0 @@ -### [Launchpad REST API](https://polygon.io/docs/stocks/launchpad/getting-started) - -- import all the rest submodule or a specific submodule - -```typescript -// The entire rest submodule -import { restClient } from "@polygon.io/client-js"; -// A specific submodule, in this instance the reference client -import { referenceClient } from "@polygon.io/client-js"; - -// Headers required to use the Launchpad product. -const edgeHeaders = { - // X-Polygon-Edge-ID is a required Launchpad header. It identifies the Edge User requesting data. - 'X-Polygon-Edge-ID': sampleEdgeID, - // X-Polygon-Edge-IP-Address is a required Launchpad header. It denotes the originating IP Address of the Edge User requesting data. - 'X-Polygon-Edge-IP-Address': 192.0.2.1, - // X-Polygon-Edge-User-Agent is an optional Launchpad header. It denotes the originating UserAgent of the Edge User requesting data. - 'X-Polygon-Edge-User-Agent': useragent -} - -const rest = restClient(process.env.POLY_API_KEY); -rest.forex.previousClose("C:EURUSD", {}, { headers: edgeHeaders }).then(/* your success handler */); - -const reference = referenceClient(process.env.POLY_API_KEY); -reference.tickers({}, { headers: edgeHeaders }).then(/* your success handler */); -``` \ No newline at end of file diff --git a/examples/rest/launchpad/index.js b/examples/rest/launchpad/index.js deleted file mode 100644 index e9c21b6..0000000 --- a/examples/rest/launchpad/index.js +++ /dev/null @@ -1,18 +0,0 @@ -import { restClient } from "@polygon.io/client-js"; -import { referenceClient } from "@polygon.io/client-js"; - -// Headers required to use the Launchpad product. -const edgeHeaders = { - // X-Polygon-Edge-ID is a required Launchpad header. It identifies the Edge User requesting data. - 'X-Polygon-Edge-ID': 'sampleEdgeID', - // X-Polygon-Edge-IP-Address is a required Launchpad header. It denotes the originating IP Address of the Edge User requesting data. - 'X-Polygon-Edge-IP-Address': '192.0.2.1', - // X-Polygon-Edge-User-Agent is an optional Launchpad header. It denotes the originating UserAgent of the Edge User requesting data. - 'X-Polygon-Edge-User-Agent': 'useragent' -} - -const rest = restClient(process.env.POLY_API_KEY); -rest.forex.previousClose("C:EURUSD", {}, { headers: edgeHeaders }).then(/* your success handler */); - -const reference = referenceClient(process.env.POLY_API_KEY); -reference.tickers({}, { headers: edgeHeaders }).then(/* your success handler */); \ No newline at end of file diff --git a/package.json b/package.json index 628a84e..b3bf626 100644 --- a/package.json +++ b/package.json @@ -30,16 +30,8 @@ ], "contributors": [ { - "name": "Julien Prugne", - "email": "julien@webeleon.dev" - }, - { - "name": "Katie Adams", - "email": "katie@polygon.io" - }, - { - "name": "Andrew Bailey", - "email": "andrew.bailey@polygon.io" + "name": "Polygon Support", + "email": "support@polygon.io" } ], "license": "MIT",