Finnhub-Stock-API / finnhub-python

Finnhub Python API Client. Finnhub API provides institutional-grade financial data to investors, fintech startups and investment firms. We support real-time stock price, global fundamentals, global ETFs holdings and alternative data. https://finnhub.io/docs/api
https://finnhub.io/
Apache License 2.0
552 stars 97 forks source link

Code 400 on all Request #26

Open jabber484 opened 3 years ago

jabber484 commented 3 years ago

Hello,

I am experiencing 400 in all endpoint, but using standard request.get(), i am able to fetch data. Anyone experiencing the same thing?

ubuntu@ip-172-31-54-235:~$ python example.py Traceback (most recent call last): File "example.py", line 7, in print(finnhub_client.stock_candles("AAPL", "D", 1590988249, 1591852249)) File "/home/ubuntu/.local/lib/python3.8/site-packages/finnhub/client.py", line 206, in stock_candles return self._get("/stock/candle", params=params) File "/home/ubuntu/.local/lib/python3.8/site-packages/finnhub/client.py", line 69, in _get return self._request("get", path, **kwargs) File "/home/ubuntu/.local/lib/python3.8/site-packages/finnhub/client.py", line 39, in _request return self._handle_response(response) File "/home/ubuntu/.local/lib/python3.8/site-packages/finnhub/client.py", line 44, in _handle_response raise FinnhubAPIException(response) finnhub.exceptions.FinnhubAPIException: FinnhubAPIException(status_code: 400): Malformed URL.

rlangner commented 3 years ago

I have the same issue

MrNightSky commented 3 years ago

I had the same case, but now it work again.

P.S. Examples from https://finnhub.io/docs/api with request work well all time when this library return the error.

emptycamp commented 3 years ago

https://github.com/Finnhub-Stock-API/finnhub-python/blob/2c38c0c65264475ffea0de6913062202a969ade3/finnhub/client.py#L34 This line adds an additional forward slash to the URL (e.g., using ipo calendar it returns 'https://finnhub.io/api/v1//calendar/ipo').

At the time while I was getting 400 error, I tested both URLs with an additional forward slash and without. Using double forward slash returned 400 in request while using single slash worked (that's probably why API urls in docs worked when this library returned errors). Weird thing is that both URLs work now.