DISCLAIMER

DISCLAIMER: The content of the blog made for educational purposes only. Author of this blog does not take responsibility for any loss or damage which may be caused by using of the software code provided on this blog.

Saturday, 9 May 2015

Prep work

API NG is a new API Betfair developed. It uses REST/JSON technology. Before that they had an API based on SOAP which is still in use and as far as I know there is no set date to discontinue it.
Perhaps they are waiting so all the major developers to switch their apps to API NG.
In order to start one needs three things:
1. a Betfair account
2. an Application key
3. session Token

I already had a Betfair account for a while, so all I need is to read an API NG doc and try to do the other two.
API NG docs

An application key is a string which probably generated by some algorithm. In fact there are two of those. One is for normal API and another for a test/delayed API, so one can use it to test the code.
Application key, step by step

The third bit would be to create a session token which requires to create a certificate and register it with Betfair.
Certificate, step by step

First the certificate must be generated. To generate a certificate one need to install openssl. This tool can be downloaded, its an open source SSL libs and tools.
Those are my steps I took to generate a certificate:

"c:\Program Files (x86)\OpenSSL\bin\openssl.exe" genrsa -out client-2048.key 2048

 "c:\Program Files (x86)\OpenSSL\bin\openssl.exe" req -new -config openssl.cnf -key client-2048.key -out client-2048.csr

"c:\Program Files (x86)\OpenSSL\bin\openssl.exe" x509 -req -days 365 -in client-2048.csr -signkey client-2048.key -out client-2048.crt -extfile "c:\Program Files (x86)\OpenSSL\openssl.cnf" -extensions ssl_client


"c:\Program Files (x86)\OpenSSL\bin\openssl.exe" pkcs12 -export -in client-2048.crt -inkey client-2048.key -out client-2048.p12

Once certificate was generated, it need to be added to Windows OS certificate manager.
In order to do that one need to start certmgr.msc, navigate to the correct branch E.g. Personal/Certificates and choose import from the context menu.
Always select PFX/P12 file, not the CRT file!










After this just follow the steps to link the certificate to your Betfair account:
Link certificate to Betfair account

Once this is done you are ready to start coding.

No comments:

Post a Comment