mortada / fredapi

Python API for FRED (Federal Reserve Economic Data) and ALFRED (Archival FRED)
Apache License 2.0
902 stars 159 forks source link

Error with get_series #58

Open shorttermblog opened 1 year ago

shorttermblog commented 1 year ago

Api worked always fine but now gives error Urlopen error SSL: CERTIFICATE_VERIFY_FAILED certificate verify failed: certificate has expired (_ssl.c:1129)

I could not find a way to correct this error

medici89 commented 1 year ago

I'm also running into same issue: ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: certificate has expired (_ssl.c:1122)

ranas919 commented 1 year ago

Feel like this is the same error I am getting in below?

https://github.com/mortada/fredapi/issues/61

Did you guys manage to resolve this?

sdeep27 commented 1 month ago

had this error too. here's how i resolved:

import urllib.request
import ssl
import certifi
from fredapi import Fred

class CustomHTTPSHandler(urllib.request.HTTPSHandler):
    def __init__(self):
        context = ssl.create_default_context(cafile=certifi.where())
        super().__init__(context=context)

opener = urllib.request.build_opener(CustomHTTPSHandler())
urllib.request.install_opener(opener)

fred = Fred(api_key=fred_key)
data = fred.get_series('SP500')

replace fred_key with your api key. lmk if it works for you, it took awhile to troubleshoot this one.