jadchaar / sec-edgar-downloader

📈 Download filings from the SEC EDGAR database using Python
https://sec-edgar-downloader.readthedocs.io
MIT License
501 stars 137 forks source link

403 Client Error: Forbidden for url #91

Closed acriptis closed 1 year ago

acriptis commented 3 years ago

Hello, I'm trying to dwnload 13F-HR form with your library but I have 403 Error:

HTTPError                                 Traceback (most recent call last)
/tmp/ipykernel_5201/2161259805.py in <module>
----> 1 dl.get("13F-HR", "AAPL", amount=2)

~/anaconda3/envs/ntf_env7/lib/python3.8/site-packages/sec_edgar_downloader/Downloader.py in get(self, filing, ticker_or_cik, amount, after, before, include_amends, download_details, query)
    171             raise TypeError("Query must be of type string.")
    172 
--> 173         filings_to_fetch = get_filing_urls_to_download(
    174             filing,
    175             ticker_or_cik,

~/anaconda3/envs/ntf_env7/lib/python3.8/site-packages/sec_edgar_downloader/_utils.py in get_filing_urls_to_download(filing_type, ticker_or_cik, num_filings_to_download, after_date, before_date, include_amends, query)
    158                 headers={"User-Agent": generate_random_user_agent()},
    159             )
--> 160             resp.raise_for_status()
    161             search_query_results = resp.json()
    162 

~/anaconda3/envs/ntf_env7/lib/python3.8/site-packages/requests/models.py in raise_for_status(self)
    951 
    952         if http_error_msg:
--> 953             raise HTTPError(http_error_msg, response=self)
    954 
    955     def close(self):

HTTPError: 403 Client Error: Forbidden for url: https://efts.sec.gov/LATEST/search-index

Version of the library is '4.2.2'

What is the best practive with handling this issue?

jadchaar commented 2 years ago

Hi @acriptis, mind trying v4.3.0 to see if this is still occurring?

zhunarold commented 2 years ago

I have the same issue with v4.3.0

dl.get("10-K", "MSFT") Traceback (most recent call last): File "", line 1, in File "D:\Anaconda3\envs\python37\lib\site-packages\sec_edgar_downloader\Downloader.py", line 180, in get query, File "D:\Anaconda3\envs\python37\lib\site-packages\sec_edgar_downloader_utils.py", line 163, in get_filing_urls_to_download resp.raise_for_status() File "D:\Anaconda3\envs\python37\lib\site-packages\requests\models.py", line 943, in raise_for_status raise HTTPError(http_error_msg, response=self) requests.exceptions.HTTPError: 403 Client Error: Forbidden for url: https://efts.sec.gov/LATEST/search-index

jadchaar commented 2 years ago

Hey all, thanks for the feedback. I am working on an update in v5 that should resolve these issues. I am in progress of migrating to the new data API provided by the SEC, and that should mitigate these 403 errors completely.

zhunarold commented 2 years ago

look forward to v5.

rthapliyal commented 1 year ago

Hi @jadchaar , When's v5 anticipated? This bug still occurs and once it happens every so often.

jadchaar commented 1 year ago

Hi @rthapliyal I have added an aggressive rate-limiting mechanism in v5.0 that will delay requests until the "leaky bucket" can be re-filled within the 10 request per second limit. Please do give v5.0 a try and let me know if this issue is still occurring. This should finally be fixed fingers crossed :)!

rthapliyal commented 1 year ago

will take a look. thx much!