mirror of
https://github.com/hwchase17/langchain.git
synced 2025-06-19 21:33:51 +00:00
community: Update Polygon.io API (#27552)
**Description:** Update the wrapper to support the Polygon API if not you get an error. I keeped `STOCKBUSINESS` for retro-compatbility with older endpoints / other uses Old Code: ``` if status not in ("OK", "STOCKBUSINESS"): raise ValueError(f"API Error: {data}") ``` API Respond: ``` API Error: {'results': {'P': 0.22, 'S': 0, 'T': 'ZOM', 'X': 5, 'p': 0.123, 'q': 0, 's': 200, 't': 1729614422813395456, 'x': 1, 'z': 1}, 'status': 'STOCKSBUSINESS', 'request_id': 'XXXXXX'} ``` - **Issue:** N/A Polygon API update - **Dependencies:** N/A - **Twitter handle:** @wgcv --------- Co-authored-by: ccurme <chester.curme@gmail.com>
This commit is contained in:
parent
621f78babd
commit
f94125a325
@ -45,7 +45,7 @@ class PolygonAPIWrapper(BaseModel):
|
||||
data = response.json()
|
||||
|
||||
status = data.get("status", None)
|
||||
if status not in ("OK", "STOCKBUSINESS"):
|
||||
if status not in ("OK", "STOCKBUSINESS", "STOCKSBUSINESS"):
|
||||
raise ValueError(f"API Error: {data}")
|
||||
|
||||
return data.get("results", None)
|
||||
@ -61,7 +61,7 @@ class PolygonAPIWrapper(BaseModel):
|
||||
data = response.json()
|
||||
|
||||
status = data.get("status", None)
|
||||
if status not in ("OK", "STOCKBUSINESS"):
|
||||
if status not in ("OK", "STOCKBUSINESS", "STOCKSBUSINESS"):
|
||||
raise ValueError(f"API Error: {data}")
|
||||
|
||||
return data.get("results", None)
|
||||
@ -82,7 +82,7 @@ class PolygonAPIWrapper(BaseModel):
|
||||
data = response.json()
|
||||
|
||||
status = data.get("status", None)
|
||||
if status not in ("OK", "STOCKBUSINESS"):
|
||||
if status not in ("OK", "STOCKBUSINESS", "STOCKSBUSINESS"):
|
||||
raise ValueError(f"API Error: {data}")
|
||||
|
||||
return data.get("results", None)
|
||||
@ -116,7 +116,7 @@ class PolygonAPIWrapper(BaseModel):
|
||||
data = response.json()
|
||||
|
||||
status = data.get("status", None)
|
||||
if status not in ("OK", "STOCKBUSINESS"):
|
||||
if status not in ("OK", "STOCKBUSINESS", "STOCKSBUSINESS"):
|
||||
raise ValueError(f"API Error: {data}")
|
||||
|
||||
return data.get("results", None)
|
||||
|
Loading…
Reference in New Issue
Block a user