Betfair data threatment API repository
The project was maded using Python 3.10.0, for a single use I recommend to run the virtual environment by the command:
.\ambvir\Scripts\activate.bat
./ambvir/Scripts/activate
If you want to run the code as part of another code, you can see the requirements at the requirements.txt file at root dir, or install it with
pip install -r requirements.txt
As especified by betfair dev doc, you have to generate a self-signed certificate and then link the certificate to your Betfair account by following the steps:
Generate Certificate File (CSR) With openssl
- Create a certs inside the root directory of project (the same that have a app.py file)
- Then run the commands inside the certs directory:
openssl genrsa -out client-2048.key
to create public or private RSA key using openssl. 3. Create a file named openssl.cnf inside the certs directory with
basicConstraints = CA:FALSE
nsCertType = client
keyUsage = digitalSignature, keyEncipherment
extendedKeyUsage = clientAuth
- Llet's create the CSR file
openssl req -new -config openssl.cnf -key client-2048.key -out client-2048.csr
- Then finally
openssl x509 -req -days 365 -in client-2048.csr -signkey client-2048.key -out client-2048.crt -extfile openssl.cnf -extensions ssl_client
You can also generate the certificate of the previous steps with XCA an OpenSSL toolset as specified here.
-
After creating the CSR file, let's link the certificate with our Betfair account:
-
Log in to your Betfair account through betfair.com. Paste the following URL into the address bar of your browser
-
Navigate to https://myaccount.betfair.com/accountdetails/mysecurity?showAPI=1
-
Scroll to the section titled “Automated Betting Program Access” and click 'Edit'
-
Click on “Browse” and then locate and select the file client-2048.crt created above.
-
Click on the “Upload Certificate” button.
-
Scroll down to the “Automated Betting Program Access” section if required and the certificate details should be shown. You should now be able to log in to your Betfair account using the Betfair API endpoint.