Skip to content

Commit 0cee2f1

Browse files
mpatel18justinpolygonJustin
authored
alpha (#232)
* [DVX-537] feat: auto-generated rest client feature \n\n BREAKING CHANGE: it breaks something # => v8.0.0-alpha.0 on @next (#215) * poc for a auto-generated rest client using openapi genorator * github action for release of client library w/ auto generation (#216) * correct spec fetching when generating rest client * spec adjustments, code cleanup, and old rest client removeal * 8.0.0-alpha.0 * update client and readme * fix readme update * update npm ignore for github actions and scripts files * update readme for correct clientjs version download * Add operationId remapping for logical client function names (#217) * update build with new function names * 8.0.0-alpha.1 * update client with latest spec * 8.0.0-alpha.2 * update api generation to match response adjustments * 8.0.0-alpha.3 * Fixed alpha feedback re: README and contact (#221) Co-authored-by: Justin <[email protected]> * update package.json to remove .cjs * 8.0.0-alpha.4 * add auto pagination to client-js (#226) * [DVX-798] update pipeline to trigger and build on platform spec updates (#228) * update pipeline to trigger and build on platform spec updates * remove dry run * update action for correct release flow * update client-js alpha with new spec changes * 8.0.0-alpha.5 * Add generate-examples-with-tokens.js (#229) * Add quotes to param objects * Revert "Add quotes to param objects" This reverts commit fdadd07. * Remove futures hack and add quotes to example object params (#230) * add updated examples for new generated client * fix type error for automated release-it package * Update operation-mappings.js with futures endpoints (#231) * update readme * add updated generated client files * add missing examples --------- Co-authored-by: justinpolygon <[email protected]> Co-authored-by: Justin <[email protected]>
1 parent 794d005 commit 0cee2f1

File tree

343 files changed

+81868
-7531
lines changed

Some content is hidden

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

343 files changed

+81868
-7531
lines changed

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<!--- Provide a general summary of your changes in the Title above -->
2+
3+
## Description
4+
<!--- Describe your changes in detail -->
5+
6+
## Related Issue
7+
<!--- This project only accepts pull requests related to open issues -->
8+
<!--- If suggesting a new feature or change, please discuss it in an issue first -->
9+
<!--- If fixing a bug, there should be an issue describing it with steps to reproduce -->
10+
<!--- Please link to the issue here: -->
11+
12+
## Motivation and Context
13+
<!--- Why is this change required? What problem does it solve? -->
14+
15+
## How Has This Been Tested?
16+
<!--- Please describe in detail how you tested your changes. -->
17+
<!--- Include details of your testing environment, and the tests you ran to -->
18+
<!--- see how your change affects other areas of the code, etc. -->

.github/workflows/publish.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Release
2+
on:
3+
repository_dispatch:
4+
types: [released]
5+
6+
permissions:
7+
contents: read # for checkout
8+
9+
jobs:
10+
release:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v2
14+
with:
15+
fetch-depth: 0
16+
- name: git config
17+
run: |
18+
git config user.name "${GITHUB_ACTOR}"
19+
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
20+
- run: npm install
21+
- run: npm run build
22+
- run: npx release-it minor
23+
env:
24+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
25+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.npmignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,7 @@
44
/.circleci*
55
tsconfig.json
66
/examples
7-
.mocharc.json
7+
/scripts
8+
/templates
9+
.mocharc.json
10+
/.github

.release-it.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"$schema": "https://unpkg.com/release-it/schema/release-it.json",
3+
"git": {
4+
"requireBranch": "master"
5+
},
6+
"github": {
7+
"release": true
8+
},
9+
"npm": {
10+
"publish": true
11+
}
12+
}

README.md

Lines changed: 17 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ const rest = restClient(process.env.POLY_API_KEY);
2626
After creating the client, making calls to the Polygon API is easy. For example, here's how to get aggregates (bars):
2727

2828
```javascript
29-
rest.stocks.aggregates("AAPL", 1, "day", "2023-01-01", "2023-04-14").then((data) => {
29+
rest.get_stocks_aggregates("AAPL", 1, GetStocksAggregatesTimespanEnum.Day, "2023-01-01", "2023-04-14").then((data) => {
3030
console.log(data);
3131
}).catch(e => {
3232
console.error('An error happened:', e);
@@ -37,14 +37,14 @@ Or, maybe you want to get the last trades or quotes for a ticker:
3737

3838
```javascript
3939
// last trade
40-
rest.stocks.lastTrade("AAPL").then((data) => {
40+
rest.get_stocks_trades("AAPL").then((data) => {
4141
console.log(data);
4242
}).catch(e => {
4343
console.error('An error happened:', e);
4444
});
4545

4646
// last quote (NBBO)
47-
rest.stocks.lastQuote("AAPL").then((data) => {
47+
rest.get_stocks_quotes("AAPL").then((data) => {
4848
console.log(data);
4949
}).catch(e => {
5050
console.error('An error happened:', e);
@@ -54,87 +54,36 @@ rest.stocks.lastQuote("AAPL").then((data) => {
5454
Finally, maybe you want a market-wide snapshot of all tickers:
5555

5656
```javascript
57-
rest.stocks.snapshotAllTickers().then((data) => {
57+
rest.get_snapshots().then((data) => {
5858
console.log(data);
5959
}).catch(e => {
6060
console.error('An error happened:', e);
6161
});
6262
```
6363

64-
See [full examples](./examples/rest/) for more details on how to use this client effectively.
65-
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.
64+
See [full examples](./examples/rest/) for more details on how to use this client effectively.
6665

6766
## Pagination
6867

6968
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.
7069

7170
```javascript
72-
import('@polygon.io/client-js').then(({ restClient }) => {
73-
const globalFetchOptions = {
74-
pagination: true,
75-
};
76-
const rest = restClient("XXXX", "https://api.polygon.io", globalFetchOptions);
77-
rest.stocks.aggregates("TSLA", 1, "minute", "2022-01-01", "2023-08-31", { limit: 50000 }).then((data) => {
78-
const resultCount = data.length;
79-
console.log("Result count:", resultCount);
80-
}).catch(e => {
81-
console.error('An error happened:', e);
82-
});
83-
});
84-
```
85-
86-
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.
87-
88-
## Debugging
89-
90-
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.
91-
92-
### How to Enable Debug Mode
93-
94-
You can activate the debug mode as follows:
71+
import { restClient } from '@polygon.io/client-js';
72+
const rest = restClient(process.env.POLY_API_KEY);
9573

96-
```javascript
97-
import('@polygon.io/client-js').then(({ restClient }) => {
98-
const globalFetchOptions = {
99-
trace: true,
100-
};
101-
const rest = restClient("XXXX", "https://api.polygon.io", globalFetchOptions);
102-
rest.stocks.aggregates("TSLA", 1, "minute", "2023-08-01", "2023-08-01", { limit: 50000 }).then((data) => {
103-
const resultCount = data.length;
104-
console.log("Result count:", resultCount);
105-
}).catch(e => {
106-
console.error('An error happened:', e);
107-
});
74+
const globalFetchOptions = {
75+
pagination: true,
76+
};
77+
const rest = restClient("XXXX", "https://api.polygon.io", globalFetchOptions);
78+
rest.getStocksAggregates("AAPL", 1, GetStocksAggregatesTimespanEnum.Day, "2023-01-01", "2023-04-14").then((data) => {
79+
const resultCount = data.length;
80+
console.log("Result count:", resultCount);
81+
}).catch(e => {
82+
console.error('An error happened:', e);
10883
});
10984
```
11085

111-
### What Does Debug Mode Do?
112-
113-
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.
114-
115-
### Example Output
116-
117-
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:
118-
119-
```
120-
Request URL: https://api.polygon.io/v2/aggs/ticker/TSLA/range/1/minute/2023-08-01/2023-08-01?limit=50000
121-
Request Headers: { Authorization: 'Bearer REDACTED' }
122-
Response Headers: Headers {
123-
[Symbol(map)]: [Object: null prototype] {
124-
server: [ 'nginx/1.19.2' ],
125-
date: [ 'Thu, 06 Jul 2023 18:34:27 GMT' ],
126-
'content-type': [ 'application/json' ],
127-
'transfer-encoding': [ 'chunked' ],
128-
connection: [ 'close' ],
129-
'content-encoding': [ 'gzip' ],
130-
vary: [ 'Accept-Encoding' ],
131-
'x-request-id': [ '06dc97920681d8335c0451894aa1f79f' ],
132-
'strict-transport-security': [ 'max-age=15724800; includeSubDomains' ]
133-
}
134-
}
135-
```
136-
137-
This can be an invaluable tool for debugging issues or understanding how the client interacts with the API.
86+
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.
13887

13988
## WebSocket Client
14089

examples/rest/configuration.js

Lines changed: 0 additions & 24 deletions
This file was deleted.

examples/rest/crypto-aggregates_bars.js

Lines changed: 0 additions & 9 deletions
This file was deleted.

examples/rest/crypto-conditions.js

Lines changed: 0 additions & 9 deletions
This file was deleted.

examples/rest/crypto-daily_open_close.js

Lines changed: 0 additions & 9 deletions
This file was deleted.

examples/rest/crypto-exchanges.js

Lines changed: 0 additions & 9 deletions
This file was deleted.

0 commit comments

Comments
 (0)