polygon-io/client-js

restClient.options.snapshotOptionContract and restClient.reference.optionsContract do not always return the correct data

Closed this issue · 2 comments

Example:

await client.reference.optionsContract('O:AAPL231020P00192500');

and

await client.options.snapshotOptionsContract('AAPL','O:AAPL231020P00192500');

return nothing, but if I use HTTPS and call

https://api.polygon.io/v3/reference/options/contracts/O:AAPL231020P00192500&apiKey=<key>

I get

{"results":{"cfi":"OPASPS","contract_type":"put","exercise_style":"american","expiration_date":"2023-10-20","primary_exchange":"BATO","shares_per_contract":100,"strike_price":192.5,"ticker":"O:AAPL231020P00192500","underlying_ticker":"AAPL"},"status":"OK","request_id":"<rid>"}

which matches the website.

Not sure why the client doesn't work - maybe something odd about cross-fetch but I haven't really investigated.

package-lock.json

"node_modules/@polygon.io/client-js": {
      "version": "7.3.2",
      "resolved": "https://registry.npmjs.org/@polygon.io/client-js/-/client-js-7.3.2.tgz",
      "integrity": "sha512-/06F7g1MFPbot/mkP1Ab0sq1s07hIqkhFajWA9fUFnxgFFXYQCQ3cgXiLBXBqTXqIh0N800LPT7UggISvxjslg==",
      "dependencies": {
        "cross-fetch": "^3.1.4",
        "query-string": "^7.0.1",
        "websocket": "^1.0.34"
      },
      "engines": {
        "node": ">=16"
      }
    },

node version v18.17.1
npm version v9.6.7

I looked more, I'm getting

{
  "status": "ERROR",
  "request_id": "5b1fc8d2b113a3d2a6a67cc32d91b577",
  "error": "API Key was not provided"
}

but only when calling those two APIs I referenced. I can call client.stocks.previousClose('AAPL') with the same client and it works fine.

I am dumb - never mind