Hi, I'm trying to use the api using python programming language. Currently, I am having error when I try to login. I already created api key and certificate. Here is the code I used:
import numpy as np
import os
import datetime
import json
# Change this certs path to wherever you're storing your certificates
certs_path = r'C:\Users\nghia\Desktop\certs1\test'
print(os.listdir(certs_path))
# Change these login details to your own
my_username = ""
my_password = ""
my_app_key = ""
trading = betfairlightweight.APIClient(username=my_username,
password=my_password,
app_key=my_app_key,
certs=certs_path)
trading.login()
And the error is:
ssl.SSLError: [SSL] PEM lib (_ssl.c:3507)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\nghia\AppData\Local\Programs\Python\ Pyth on36\lib\site-packages\requests\adapters.py", line 449, in send
timeout=timeout
File "C:\Users\nghia\AppData\Local\Programs\Python\ Pyth on36\lib\site-packages\urllib3\connectionpool.py", line 638, in urlopen
_stacktrace=sys.exc_info()[2])
File "C:\Users\nghia\AppData\Local\Programs\Python\ Pyth on36\lib\site-packages\urllib3\util\retry.py", line 399, in increment
raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='identitysso-cert.betfair.com', port=443): Max retries exceeded with url: /api/certlogin (Caused by SSLError(SSLError(336265225, '[SSL] PEM lib (_ssl.c:3507)'),))
Exception: [('PEM routines', 'get_name', 'no start line'), ('SSL routines', 'SSL_CTX_use_PrivateKey_file', 'PEM lib')]
I tried: pip install -U pyopenssl, but It did not solve the problem.
Any suggestions? Thank you
import numpy as np
import os
import datetime
import json
# Change this certs path to wherever you're storing your certificates
certs_path = r'C:\Users\nghia\Desktop\certs1\test'
print(os.listdir(certs_path))
# Change these login details to your own
my_username = ""
my_password = ""
my_app_key = ""
trading = betfairlightweight.APIClient(username=my_username,
password=my_password,
app_key=my_app_key,
certs=certs_path)
trading.login()
And the error is:
ssl.SSLError: [SSL] PEM lib (_ssl.c:3507)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\nghia\AppData\Local\Programs\Python\ Pyth on36\lib\site-packages\requests\adapters.py", line 449, in send
timeout=timeout
File "C:\Users\nghia\AppData\Local\Programs\Python\ Pyth on36\lib\site-packages\urllib3\connectionpool.py", line 638, in urlopen
_stacktrace=sys.exc_info()[2])
File "C:\Users\nghia\AppData\Local\Programs\Python\ Pyth on36\lib\site-packages\urllib3\util\retry.py", line 399, in increment
raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='identitysso-cert.betfair.com', port=443): Max retries exceeded with url: /api/certlogin (Caused by SSLError(SSLError(336265225, '[SSL] PEM lib (_ssl.c:3507)'),))
Exception: [('PEM routines', 'get_name', 'no start line'), ('SSL routines', 'SSL_CTX_use_PrivateKey_file', 'PEM lib')]
I tried: pip install -U pyopenssl, but It did not solve the problem.
Any suggestions? Thank you


Comment