program set apibf for betfair’s services api-ng · pdf file1 program set _apibf for...
TRANSCRIPT
1
Program set _ApiBF for BetFair’s services Api-NG
15th Feb 2015 – Version 1.2.14
Support for services Api-NG of betting exchange BetFair - program _ApiBF.EXE and auxiliary programs
(_ApiBF_ses.EXE for getting of SessionToken for Api-NG services,
_ApiBF_par.EXE for getting of request strings for Api-NG operations)
- for testing in "Command line" window
- for retrieving from users program in various languages (C#/C++/Java/VB/Python …)
- entry parameters for option of operation, filtering of data, structure JSON/CSV
- returned data in original structure of Api-NG (JSON) or in CSV-format
Additional qualities - supplementation of original services and parameters Api-NG with additional :
combined operations for getting of data sets for competition+events or
competition+events+markets+odds
parameters for filtering of data volume during processing of operations
(filters for names of competitions, events, markettypes)
- simply application, high speed (based on C++)
Special DLL libraries for sportsbetting - DLL libraries for integration into programs Visual Studio (C#, Basic, ...)
DLL_ApiBF_par – for construction of requests for Api-NG services of Betfair
DLL_AnalTextStaSpo – analysis of texts – names of states, competitions, teams
(common using for matching events in offer of different bookmakers)
Demoversions in Python, Visual C#, Visual Basic (including source codes) - description based on examples - source code for :
- PYTHON – Console Application for stepping in GUI
- VISUAL C# + VISUAL BASIC :
a) Console Application for stepping
b) Windows Forms Application with examples
- forms for concrete operation Api-NG or additional combined operation
(display results – for several examples of entry parameters or users experiments)
- form frmOTHERbookie
(see chapter 4.4.– using of combination Analysis of Texts + Betfairs Api-NG
for matching offer of other bookie versus BetFair with result:
download in CSV structure of BetFairs Odds for asked matches and types of bets)
Similar conception – program set _ApiPS (for API operations of Pinnacle Sports)
- programs with demo ApiBD ( for API services of BetDAQ)
– program set for API of Matchbook :
- see http://www.betoptim.com/index.aspx?lang=EN&start=DownInst
In Building :
1) Program Bet_LIVE_Comparation
– comparation of current odds (prices, amounts) for concrete event from different
sources API (preferred are LIVE/Inplay matches, prospective plan -> Trading)
2) Program Bet_Info.EXE
– Betfairs Api-NG in cooperation with database PostgreSQL for storage of current data
2
CONTENT :
Program set _ApiBF for BetFair’s services Api-NG ............................ 1
1. INSTALLATION .................................................................. 3
2. SELF SIGNED CERTIFICATES ...................................................... 4 2.1. Creating a Self Signed Certificate .......................................... 4 2.2. Linking of the Certificate to Your Betfair Account .......................... 5 2.3. Creating a file PKCS#12 format – file client-2048.p12 ..................... 6 2.4. Getting of SessionToken – with batch _ApiBFses.bat / in users program ...... 7 2.5. How to get value of "Application Key" (+ value Session Token manually) ... 7
3. BASIC PROGRAM _ApiBF.EXE ...................................................... 9 3.1. Testing of program _ApiBF.EXE in "Command Line" window ...................... 9 3.2. Console applications ( in Python / Visual C# / Visual Basic ) ............... 9 3.3. Windows Forms Applications ( in Visual C# / Visual Basic ) ................. 10 3.4. Usage of program _ApiBF.EXE in users program in other languages ........... 10 3.5. Entry parameters of program _ApiBF.EXE : ................................... 11 3.6. Additional Filtering of Competitions, Events, Markets – wildcards "*" ...... 14 3.7. Additional Filtering of Competitions – _AT – Analysis of texts ............ 15
4. USAGE of PROGRAM _ApiBF.EXE - Examples .................................... 16 4.1. Original operations of Betfairs _ApiBF - Betting operations ................ 16 4.2. Additional (combined) operations of program _ApiBF.EXE .................... 20 4.3. Other operations of Betfairs Api-NG - Managing of bets (direct retrieving) . 21 4.4. Complete DEMO – Download of BetFairs Odds for requested matches with using
"Analysis of Texts" ( for matching with offer of other bookie ) ................. 21
5. Auxiliary programs _ApiBF_???.EXE, libraries DLL_???.DLL ................... 24 5.1. Program _ApiBF_ses.EXE – getting of Sessiontoken ........................... 24 5.2. Program _ApiBF_par.EXE – getting of Request (reduced) for Betfairs Api-NG .. 24 5.3. Library DLL_ApiBF_par.dll - support for request strings Betfairs Api-NG .... 25 5.4. Library DLL_AnalTextStaSpo.dll - support for Analysis of texts ............. 27
6. Download, Update, Upgrade, Contact ........................................... 30 6.1. Update of files for Analysis of texts , of DLL_AnalTextStaSpo.dll .......... 30 . ............................................................................... 30
Appendix A - Error Codes, Error Messages ........................................ 31
Appendix B - Overview of parameters for Api-NG requests in _ApiBF???.EXE ........ 32
Appendix C - Parameter #4 (required values or other parameters for Filtering) ... 34
Appendix D - Parameter #6 (additional parameters for Filtering) ................. 35
Appendix E - Operation Competitions_Events - structure of output CSV ......... 36
Appendix F - Operation CompEvents_MarkBook - structure of output CSV ......... 38 . ............................................................................... 40
7. VERSIONs ..................................................................... 40
3
1. INSTALLATION
1) Download and store installation file ApiBF_Install.ZIP into any installation
directory
2) Unpack Zip-file -> (Setup.EXE + ApiBF_Install.MSI)
3) Launch installation with Setup.EXE into installation directory
f.e. D:\_Api_Install (can work together with program _ApiPS.EXE for API of Pinnacle,
program for API of BetDAQ)
or D:\Bet_Info (can work together with program Bet_Info.EXE)
Subdirectories :
a) _BAT.ApiBF
batch files for testing in command line, detection of problems after installation
b) _ApiBF (auxiliary programs)
_ApiBF_ses.EXE - for getting of SessionToken for Api-NG services,
_ApiBF_par.EXE - for getting of request strings for Api-NG operations
_ApiBF.EXE – program for calling of Betfairs Api-NG services including additional
combined services
c) _AT
data files for Analysis of texts - names of states, competitions, teams
(can be updated with download from webpage www.betoptim.com – see frm_Update_AT)
registry key for Analysis of text – AT?????X.TXT
d) DOC._ApiBF
documentation (this file *.PDF with description of programs)
e) KEYS
own key-files of concrete user for Betfairs services Client-2048.P12 (*.CRT, *.KEY)
file _AppKey.TXT with DeveloperAppKey (16 chars – registration of user at Betfair)
f) DATA
storage of SessionToken (into file _SessionToken.TXT)
default directory for storage of downloaded data files
Subdirectories for DEMOversions :
a) Python_BeFa_CONSOLE
b) VisualBasic_BeFa_CONSOLE
c) VisualBasic_BeFa_DEMO
d) VisualCsharp_BeFa_CONSOLE
e) VisualCsharp_BeFa_DEMO
These examples of usage are identical in programming languages C#/VB/Python :
to get versions number of program _ApiBF.EXE
use of program _ApiBF_ses.EXE for obtaining of SessionToken string
single services BetFair Api-NG for obtaining of current offer Betfair exchange
use of program _ApiBF.EXE for retrieving of original services BetFair Api-NG,
obtaining of response, processing of response from JSON to CSV structure
retrieving of combined services – sequence of original services with using of text
filters (simple "wildcards" for name of competition, of event, of markets) or with
using AT (Analysis of texts – detection of competition/team name in steps state,
competition, team)
Faster (for obtaining of prices) are combined operations – demonstrated both in
Windows Forms Applications (Visual C#/Basic) and in console applications(+Python).
4
2. SELF SIGNED CERTIFICATES
Program set uses services Api-NG (for downloads from webserver BetFair). Functionality
of these services is conditioned by creation and uploading of Self Signed Certificates
of user (registered by BetFair.com for his players account) – file client-2048.p12.
See description in documentation BetFair Api-Ng – Chapter Non-Interactive (bot) login
(https://api.developer.betfair.com/services/webapps/docs/display/1smk3cen4v3lu3yomq5qy
e0ni/Non-Interactive+%28bot%29+login)
Based on using OpenSSL ( http://www.openssl.org )
Download, install to your PC, installation folders are default :
C:\OpenSSL-Win32
C:\OpenSSL-Win32\bin
2.1. Creating a Self Signed Certificate
Launch "command line", change directory to C:\OpenSSL-Win32\bin
1) Create a public/private RSA key pair using OpenSSL (PRIVATE KEY) OpenSSL genrsa –out client-2048.key 2048
=> created private key: C:\OpenSSL-Win32\bin\client-2048.key
2) Update or Create the OpenSSL configuration file (openssl.cnf) (details – see page of Betfair for Non-Interactive (bot) login)
3) Create a file "???.csr" (CERTIFICATE SIGNING REQUEST) OpenSSL req –new –config openssl.cnf –key client-2048.key –out client-2048.csr
(details – see page of Betfair for Non-Interactive (bot) login or picture below)
=> created key file: C:\OpenSSL-Win32\bin\client-2048.csr
4) Self-sign the certificate request to create a file "???.crt" (CERTIFICATE) OpenSSL x509 –req –days 365 –in client-2048.csr –signkey client-2048.key
-out client-2048.crt –extfile openssl.cnf –extensions ssl_client
=> created key file: C:\OpenSSL-Win32\bin\client-2048.crt
5) Create a file "???.pem" – with any simple editor - copy the contents of the *.CRT file and the *.KEY file into a new file
- save this new file as client-2048.pem
Example of content of command line for steps 1) – 4) :
5
2.2. Linking of the Certificate to Your Betfair Account
- Login to your Betfair account www.betfair.com (in your browser, Username+Password)
- Paste following URL into the address bar of your browser (after Login)
https://myaccount.betfair.com/account/authentication?showAPI=1
- Upload clients certificate PEM/CRT to Betfair.com :
6
Section of Betfairs page for upload BEFORE Upload : (Button "Procházet" = BROWSE)
- after choice of file client-2048.PEM is yellow button "Upload" activated
Section of Betfairs page for upload AFTER Upload :
Registration of a key can be deleted
- with blue button "Delete" on a row with short info about registered key
2.3. Creating a file PKCS#12 format – file client-2048.p12
- Create the PKCS#12 format using crt and key
- in command line with command
OpenSSL pkcs12 –export –in client-2048.crt –inkey client-2048.key –out client-2048.p12
=> created key file: C:\OpenSSL-Win32\bin\client-2048.p12
- with this file has to be replaced file with the same name client-2048.p12 (but with
size 0 bytes) from installation in subfolder KEYS
- you can check it with batch _BAT.ApiBF\_ApiBF_ses.bat - see chapter 2.4
7
2.4. Getting of SessionToken – with batch _ApiBFses.bat / in users program
Batch files can be used for checking of some functionalities, they are placed in
subdirectory _BAT.ApiBF .
Simple way – how to get visible response of a batch is using of "command line"
Command in Batch file is :
..\_ApiBF\_ApiBF_ses.EXE "username=MyBetFairUSERNAME&password=MyBetFairPASSWORD"
..\KEYS\client-2048.p12 - ..\DATA\SessionToken.txt
Parameters in command :
..\_ApiBF\_ApiBF_ses.EXE - launch program _ApiBF_ses.EXE in installation subfolder
"username=???&password=???" – place your username&password for Betfair account into
this string
..\KEYS\client-2048.p12 - specification of file (registration key, certificate)
- - unused parameter
..\DATA\_SessionToken.txt - output file for value of SessionToken
After installation of program set _ApiBF is in subfolder KEYS only an empty file
client-2048.p12 . This file has to be replaced with "self signed certificate" of
concrete user. How to get it describes chapter 2. .
Functionality of this batch and obtaining of Sessiontoken (and functionality of
Login to BetFair in program Bet_Info) are conditioned by correct certificate file
client-2048.p12 and by placing correct Username and Password of this user into text of
batch file.
Quotation marks have to be used for parameters that contain spaces or separators – in
this case parameter "username=MYUSERNAME&password=MYPASSWORD" contains character "&")
Response :
0 – OK
current value of SessionToken
In Users program :
- how to retrieve program _ApiBF_ses.EXE with parameters : see above
+ read SessionToken-string from output file
- see console application for concrete program language
2.5. How to get value of "Application Key" (+ value Session Token manually)
1) Login to your Betfairs account ( www.betfair.com ) in your browser
2) Insert into field of browser for URL address :
https://developer.betfair.com/visualisers/api-ng-account-operations/
( address for visualiser of Betfair for accounts )
3) Send => to launch Visualiser
4) Above in field for Session Token ssoid is current value of SessionToken
8
A) Create a new Developer Application key
- on the left click on function "createDeveloperAppKeys"
- enter Application Name : MyApplicationNAME
- click on button "Execute"
Application Keys appear in the table on the right
- NOT USE row for Version WITH EXTENSION "-DELAY"
- use row for Version f.e. "1.0" 16 characters from column "Application Key"
To place this string – Application Key (16 characters) into file _AppKey.txt in
subdirectory KEYS of program directory ( after installation is this file empty
- specification of this file is f.e. D:\_Api_Install\KEYS\_AppKey.txt )
- Login and getting of SessionToken can be successful, but correct value of
Application key in file _AppKey.txt (+ certificate file client-2048.p12) are condition
for successful downloads (Betfair Api-NG services)
B) Get info about existing Developer Application key
- on the left click on function "getDeveloperAppKeys"
- at the bottom of form click on button "Execute"
- click on "+"
For both A) and B) ist on the right info about Application key(s)
9
3. BASIC PROGRAM _ApiBF.EXE
This program retrieves :
a) concrete original Betfairs operations Api-NG
b) additional combined operations (sequence of original Betfair operations Api-NG)
Output text file (response) of operations can be :
a) JSON – original structure of response of Betfair operations
b) CSV – "comma separated values"
For output structure CSV can be used additional parameters for filtering of output
a) AT (Analysis of texts – detection of state in first step and detection of
competition based on code of state+name of competition in second step)
b) using of text filters (simple "wildcards" for name of competition, of event, of
markets)
After getting of response of original Betfairs operation are applied Additional
parameters for filtering and into output file are included only matching items.
For combined operations are additional parameters for filtering used between simple
operations – this reduces number of downloads and increases speed of response.
Program _ApiBF.EXE returns exit-code 0 (success) or <>0 (error).
Error codes – see Appendix A.
One of parameters is specification of text file for output – this file contains data
(in case of success) or error message (in case of error).
3.1. Testing of program _ApiBF.EXE in "Command Line" window
Retrieving of program _ApiBF.EXE with parameters can be saved in program batch *.BAT
Simply example for retrieving of program _ApiBF.EXE is usage with parameter –-VERSION
- it returns string with current versions number of this program
- see batch file _ApiBF_VER.bat in subdirectory _BAT.ApiBF
Batch files can be retrieved from subdirectory of installing directory
- f.e. D:/_Api_Install/_BAT.ApiBF
Another way is retrieving of program _ApiBF.EXE in "Command Line" with parameter :
- f.e. D:/_Api_Install/_ApiBF/_ApiBF.EXE --VERSION
Result of operation :
a) "small" ( f.e. programs version number / error message ) - is displayed in row below the command for program _ApiBF.EXE
b) "big" ( f.e. result of download)
- displayed is only "error code" => to read content of output file
3.2. Console applications ( in Python / Visual C# / Visual Basic )
- see source code in subdirectories of installation directory :
F.e. for Python : D:/_Api_Install/Python_BeFa_CONSOLE
for VisualBasic : D:/_Api_Install/VisualBasic_BeFa_CONSOLE
for Visual C# : D:/_Api_Install/VisualCsharp_BeFa_CONSOLE
These console applications contain one command file. Individual commands are examples
of retrieving of program _ApiBF.EXE (or auxiliary programs _ApiBF_ses.EXE,
_ApiBF_par.EXE) with different parameters.
Commands should be stepped in GUI - it allows checking of results.
10
3.3. Windows Forms Applications ( in Visual C# / Visual Basic )
- see source code in subdirectories of installation(program) directory :
For VisualBasic : D:/_Api_Install/VisualBasic_BeFa_DEMO
For Visual C# : D:/_Api_Install/VisualCsharp_BeFa_DEMO
This applications contain horizontal menu with columns :
a) Betfair–Login / Betfair–Logout
using of form frmLogin for getting of SessionToken
b) Betting operations – List
- original Betfairs operations Api-NG
- additional combined operations
c) Analysis of Texts
- frmStates (identification of state)
- frmLeagues (identification of league/competition)
- frmTeams (identification of team)
- frmOTHERbookie (Complete DEMO – Download of BetFairs Odds with using "Analysis of
Texts" - for matching BetFair versus offer of other bookie – see 4.4.)
d) Help
- Update Files – Analysis of Texts
Principle of forms b), c) is :
- 1 item of menu = 1 windows form = 1 operation of Betfairs Api-NG / program _ApiBF
- component NumericUpDownEXAMPLE allows cycling between examples Up/Down
- every example is 1 combination of entry parameters (filled into fields)
- clicking button "Download" starts operation
- processing of entry parameters can be checked in routine butDownload_Click
- results of operation are displayed in component TextBox txtResult and saved in
textfile with specification – see TextBox txtSpecOutput .
User can test another "own" combinations of parameters and check results after
clicking button "Download".
1-3 Radiobuttons are used for option of structure of output file :
For JSON structure are in Windows Forms Applications two ways of getting :
a) direct retrieving response of Betfair service – entry parameters from windows form
are processed with function of DLL library (DLL_ApiBF_par), returned string of
request for concrete operation is passed to Betfairs Api-NG
b) run program _ApiBF.EXE – parameters from windows form are joined to one string
(separator "|"); this string is passed to program _ApiBF.EXE
For output in structure CSV can be used additional parameters for filtering of output
a) _AT (Analysis of texts – detection of competition based on detection of state in
first step)
b) using of text filters (simple "wildcards" for name of competition, of event, of
markets)
3.4. Usage of program _ApiBF.EXE in users program in other languages
Program _ApiBF.EXE can be retrieved in other languages than Python, Visual C# and
Visual Basic – entry parameters and exit codes (+ output files) are the same.
11
3.5. Entry parameters of program _ApiBF.EXE :
1) BASIC parameters of program _ApiBF.EXE for original Betfairs operations :
Parameter#1 = OPERATION (no distinction between lower/upper characters)
--ListEventTypes / --ListCountries / --ListVenues / --ListCompetitions
--ListTimeRanges / --ListEvents / --ListMarketTypes / --ListMarketCatalogue
--ListMarketBook
Parameter#2 = SessionToken
a) concrete string – result of "Login operation" (or program _ApiBF_ses.EXE) - see chapter 2.4. Getting of SessionToken
b) value RS ("Read _SessionToken.txt") - SessionToken was stored in file DATA/_SessionToken.txt
- program _ApiBF can read SessionToken from this file
Parameter#3 = Application Key
a) concrete string – see chapter 2.5. How to get Application Key b) value RA ("Read _AppKey.txt")
- Application Key was stored in file KEYS/_AppKey.txt
- program _ApiBF can read Application Key from this file
Parameter#4 = Required values or other parameters for Filtering
+ OPTION : output JSON (default BetFair) / CSV (addition program‘s _ApiBF)
a) value "" or "-" or – (without quotations) - default value of this parameter for OPERATION (Parameter#1)
- without filtering = simpliest usage of program _ApiBF
b) list of parameters in string |param1=???|param2=???|…| – see chapter 5.2. Program _ApiBF_par.EXE or Appendix B,C
HOW TO SWITCH format of output from default JSON -> CSV (comma separated values) ?
- with PREFIX "CSV_" or "CSV_qn" before value of Parameter#4
a) value "CSV_" or "CSV_-" or CSV_ or "CSV_qn" ... (without filtering)
b) list of parameters (see Appendix B,C) -> "CSV_|param1=???|param2=???|…|" From version 1.2.12 :
PREFIX "CSV_qn" ... output file CSV without quotation marks
Parameter#5 = Specification of Output File
a) default storage is in subdirectory DATA default extension is *.JSON or *.CSV_ (depends on Parameter#4)
default FileName is given by Parameter#1 (Operation)
f.e. DATA/ListEventTypes.JSON for --ListEventTypes
b) Relative PATH/filename.ext (from installation directory) f.e. DATA/ListEventTypesMY.json
c) Absolute Specification !!! DIRECTORY FOR OUTPUT FILE HAS TO EXIST (before retrieving of _ApiBF) !!!
Comment – Additional parameters:
For operations --ListCompetitions , --ListMarketTypes , --ListEvents and
--ListMarketCatalogue
can be used additional parameters (simple wildcards "*", Analysis of texts) for
filtering of competitions, events, markets - see next paragraph
12
2) ADDITIONAL Operations & Parameters of program _ApiBF.EXE are :
Additional OPERATIONS ( only Output structure *.CSV ) :
--COMPETITIONS_EVENTS
- returns text file "CSV" with info about competitions + their matches/events
- 1 row info about Competition
- following rows info about matches/events of this Competition
--CATALOGUE_BOOK
--COMPEVENTS_MARKBOOK
- returns text file "CSV" with info about competitions + their matches/events
+ current offer of Betfair for match/event (prices, amounts Back/Lay)
- structure of text file "CSV" is the same – see Appendix F
- for operation --CATALOGUE_BOOK is bigger danger of error response TOO_MUCH_DATA
- operation --COMPEVENTS_MARKBOOK can work faster
Additional Default values of parameters :
marketProjection=COMPETITION,EVENT,EVENT_TYPE,RUNNER_DESCRIPTION,
RUNNER_METADATA,MARKET_START_TIME
pricedata=EX_BEST_OFFERS
Additional (combined) _ApiBF operations - execute more than 1 original operation Betfairs Api-NG
- program _ApiBF.EXE for original Betfairs Api-NG operations ( List?????? )
executes
only 1 operation
a) --COMPETITIONS_EVENTS
executes 1 operation ListCompetitions + N operations ListEvents
operations ListEvents only for competitionIDs matching filtering options
ADDITIONAL PARAMETERS
For competition: simple wildcard (only "*") for competition name
Analysis of competition name (see chapter 5.4. + priority>=N)
For event : simple wildcard (only "*") for event name
b) --CATALOGUE_BOOK
executes 1 operation ListMarketCatalogue + N operations ListMarketBook
operations ListMarketBook only for marketIDs matching filtering options
ADDITIONAL PARAMETERS
For competition: simple wildcard (only "*") for competition name
Analysis of competition name (see chapter 5.4. + priority>=N)
For event : simple wildcard (only "*") for event name
For markets: simple wildcard (only "*") for market name
c) --COMPEVENTS_MARKBOOK
executes 1 operation ListCompetitions
=> filtering of Competitions (competition name / Analysis of texts)
executes 1 operation ListEvents (only for compIDs – matching in previous step)
=> filtering of Events (event name)
executes 1 or more operations ListMarketCatalogue (only for matching eventIDs)
=> filtering of Markets (market name)
executes N operations ListMarketBook
=> info about prices, amounts Back/Lay
ADDITIONAL PARAMETERS
For competition: simple wildcard (only "*") for competition name
Analysis of competition name (see chapter 5.4. + priority>=N)
For event : simple wildcard (only "*") for event name
For markets: simple wildcard (only "*") for market name
13
Comment – Speed of operations:
Speed of Additional _ApiBF operations is larger (of original operations also)
– if are used basic filtering parameters (eventTypeIds=sports, marketCountries,
CompetitionsIDs ...)
- this parameters reduce volume of data in downloads (in first steps) from Betfair and
number of records for processing in next steps
Entry parameters :
Parameter#1 = OPERATION (no distinction between lower/upper characters)
--Competitions_Events / --Catalogue_Book / --CompEvents_MarkBook
Parameter#2 = SessionToken
Parameter#3 = Application Key
Parameter#4 = Parameters for Filtering (or other required parameters)
- see paragraph 1) in this chapter, appendix B,C
Parameter#5 = Specification of Output File
Parameter#6 = Additional Parameters for Filtering – see next chapters, Appendix D
Parameter#7 = Directory for _AT (Analysis of texts)
f.e. "D:\_Api_Install\_AT"
Structure of Output CSV-files from Additional operations :
- see Appendix E – operation –-Competitions_Events
- see Appendix F – operations --CompEvents_MarkBook (+ --Catalogue_Book)
14
3.6. Additional Filtering of Competitions, Events, Markets – wildcards "*"
Volume of returned data can be decreased to asked competitions / events=matches /
markets with filtering (based on names):
Filtering string for NAME (of competition / event=match / market ):
entry text fields in forms of demoversion (Windows Form Application VB / C#)
how to place filtering strings into Parameter #6 (see Appendix D)
characters(lefts) + "*" (right) => NAME HAS TO START with this characters(lefts)
"*" (left) + characters(right) => NAME HAS TO END with characters(right)
"*" (left) + "characters" + "*" (right) => NAME HAS CONTAIN STRING "characters"
(anywhere)
No characters "*" in filtering string => NAME HAS BE EQUAL to filtering string
Filtering is NOT "case sensitive"
Examples :
1) For NAME OF COMPETITION filtering string "Premier*" MATCHING
Competition with name "PREMIER league" Yes
Competition with name "Barclays Premier league" No
2) For NAME OF EVENT filtering string "* V *" (= match) MATCHING
Event name "Arsenal v Chelsea" Yes
Event name "v Liverpool v" No
3) For NAME OF MARKET filtering string "*MATCH ODDS" MATCHING
Market name "MATCH ODDS" Yes
Market name "MATCH ODDS 1st HALF" No
Filtering strings WITH MORE SECTIONS :
Separator of sections is character "|" (Alt 124)
Evaluation corresponds to LOGICAL OR - if 1 (any) section is matching => OK
If SECTION STARTS WITH NOT and this condition is matched => Result is NOT OK
4) For NAME OF EVENT filtering string "|*CHELSEA*|*MANCHESTER*|NOT*city*|" MATCHING
Event name "Chelsea v Arsenal" Yes
Event name "Liverpool v Manchester Utd" Yes
Event name "Manchester Utd v Manchester City" No
5) For NAME OF MARKET filtering string "|*HALF*|NOT*GOAL*|NOT*SCORE*" MATCHING
Market name "Half Time" Yes
Market name "Half Time Full Time" Yes
Market name "Half Time Score" No
Market name "First Half Goals" No
Filtering strings (simply wildcards "*") can be used in following operations :
ORIGINAL Api-NG operations ADDITIONAL operations _ApiBF.EXE
a) --ListCompetitions e) –-Competition_Events
for Competition Name for Competition Name, Event Name
b) –ListEvents f) --Catalogue_Book
for Event Name Competition Name, Event Name, Market Type
c) –ListMarketTypes g) --CompEvents_MarkBook
for Market Type Competition Name, Event Name, Market Type
d) -–ListMarketCatalogue
for Competition Name, Event Name, Market Type
15
3.7. Additional Filtering of Competitions – _AT – Analysis of texts
Another way for filtering of competitions is _AT – Analysis of texts.
For 2 sports ( Football and Ice Hockey ) and (at betting) most used competitions
(leagues, cups, championships...) are defined rules for their distinguishing (based on
info about sport – country – name of competition).
The same rules for distinguishing of competitions (and teams) are used :
1) in programs _ApiBF.EXE (Betfair) and _ApiPS.EXE (Pinnacle)
2) in program Bet_Info.EXE (uses for data storage database PostgreSQL)
3) in DLL_AnalTextStaSpo.dll – can be added to users program in programming languages
Visual Basic, Visual C#, C++, ... (every language that uses DLL libraries)
Output from distinguishing are 3 ABBREVIATIONS :
1) STATE – 3 chars in system ALPHA (ISO 3166-1 alpha-3) – used by Betfair and also
EUR / AFR / ASI / AME – for continental competitions
WOR (world) for competitions without connection with 1 country (incl. friendlies)
2) TYPE&LEVEL of competition – max. 5 chars (1.L / 2.L / 3.L / ... / CUP / CHxxx ...)
Full length of abbreviation 5 chars can distinguish f.e. in England
CUPfa = England FA Cup, CUPca = England Capital One Cup, ...
3) PARTICIPANTS (M=men, W=women, 2nd+3th character UnderNN ...)
W20 (for World Championship Women Under 20),
M19 (for European Championship Men Under 19)
Another returned information about Competition is PRIORITY (5=Maximal, ...1=Minimal).
For filtering can be used parameter Prio>=N
– f.e. for condition Prio>=4 are competitions with priority 1,2,3 ignored
3 ABBREVIATIONS for Competition + its Priority (1..5)
- are returned with operations :
a) --ListCompetitions
b) -–ListMarketCatalogue
c) –-Competition_Events
d) --Catalogue_Book
e) --CompEvents_MarkBook
- are returned if filtering string for _AT is not empty value; value of string has to
be at least "FOO|*,*,*" or "HOC|*,*,*" (1 sport, no filtering)
- are returned in last 4 parameters in a row of competition in CSV-files ("COMP";...)
– see structure of output files CSV in Appendix E, F
The same parameters ( 3 abbreviations + priority 1..5 ) are returned by library
DLL_AnalTextStaSpo.dll (for including into programs in VB, C#, ...)
- as result of Analysis of texts – based on info:¨
a) sport (only FOO=football, HOC=Ice hockey)
b) text – name of state
c) text – name of competition
This is typical description of competition (league) in offers of bookies.
Library DLL_AnalTextStaSpo.dll
can be used for matching of offers of other bookies with offer of Betfair (both
competitions and teams => matches)
can be tested in demoversions Windows Forms Applications for VB and C# - forms in
column of menu "Analysis of Texts" – frmStates, frmLeagues, frmTeams, frmOTHERbookie)
Info about 3 abbreviations + priorities of ALL CURRENT competitions in Betfairs offer
can be retrieved :
with operation –ListCompetitions with next values of parameter #6 :
"FOO|*,*,*" - for sport = Football/Soccer
"HOC|*,*,*" - for sport = Ice Hockey
In returned CSV-file are only competitions (included in definition files of "Analysis
of texts" and library DLL_AnalTextStaSpo.dll) - most used competitions, leagues, cups,
championships....
16
4. USAGE of PROGRAM _ApiBF.EXE - Examples
Following commands can be retrieved :
a) in "Command Line" window – see chapter 3.1. Testing of program _ApiBF.EXE
b) in console applications – see chapter 3.2 (VB, C#, Python)
c) in Windows Form Applications see chapter 3.3 (VB, C#)
d) in other programming languages
4.1. Original operations of Betfairs _ApiBF - Betting operations
1) Api-NG operation "listEventTypes" - this operation returns list of Sports (with their codes and numbers of Markets)
Examples of command for retrieving :
_ApiBF --ListEventTypes RS RA
- default structure JSON, default output DATA/listEventTypes.json
_ApiBF --ListEventTypes RS RA CSV_ (or CSV_qn ... without quotation marks)
- structure CSV_, default output DATA/listEventTypes.csv_
_ApiBF –-ListEventTypes RS RA – DATA/listEventTypesMY.json
- default structure JSON, relative path for output file DATA/listEventTypesMY.json
_ApiBF –-ListEventTypes RS RA CSV_ D:/listEventTypesMY.csv_ (or CSV_qn)
- structure CSV_, absolute path for output file listEventTypesMY.csv_
_ApiBF –-ListEventTypes RS RA CSV_|param1=???|param2=???|…| D:/listEventTypesMY.csv_
- structure CSV_, filtering with parameters in |list| (see parameter#4, Appendix C)
!!! DIRECTORY FOR OUTPUT FILE HAS TO EXIST !!!
2) Api-NG operation "listCountries" - this operation returns list of Countries (Abbreviation 2 chars + number of Markets)
Examples of command for retrieving :
_ApiBF --ListCountries RS RA
- default structure JSON, default output DATA/listCountries.json
_ApiBF --ListCountries RS RA CSV_ (or CSV_qn ... without quotation marks)
- structure CSV_, default output DATA/listCountries.csv_
_ApiBF –-ListCountries RS RA – DATA/listCountriesMY.json
- default structure JSON, relative path for output file DATA/listCountriesMY.json
_ApiBF –-ListCountries RS RA CSV_ D:/listCountriesMY.csv_ (or CSV_qn)
- structure CSV_, absolute path for output file listCountriesMY.csv_
_ApiBF –-ListCountries RS RA CSV_|param1=???|param2=???|…| D:/listCountriesMY.csv_
- structure CSV_, filtering with parameters in |list| (see parameter#4, Appendix C)
DIRECTORY FOR OUTPUT FILE HAS TO EXIST !!!
3) Api-NG operation "listVenues"
Examples of command for retrieving :
_ApiBF --ListVenues RS RA
- default structure JSON, default output DATA/listVenues.json
17
_ApiBF --ListVenues RS RA CSV_ (or CSV_qn ... without quotation marks)
- structure CSV_, default output DATA/listVenues.csv_
_ApiBF –-ListVenues RS RA – DATA/listVenuesMY.json
- default structure JSON, relative path for output file DATA/listVenuesMY.json
_ApiBF –-ListVenues RS RA CSV_ D:/listVenuesMY.csv_ (or CSV_qn)
- structure CSV_, absolute path for output file listVenuesMY.csv_
_ApiBF –-ListVenues RS RA CSV_|param1=???|param2=???|…| D:/listVenuesMY.csv_
- structure CSV_, filtering with parameters in |list| (see parameter#4, Appendix C)
!!! DIRECTORY FOR OUTPUT FILE HAS TO EXIST !!!
4) Api-NG operation "listCompetitions"
Examples of command for retrieving :
_ApiBF --ListCompetitions RS RA
- default structure JSON, default output DATA/listCompetitions.json
_ApiBF --ListCompetitions RS RA CSV_ (or CSV_qn ... without quotation marks)
- structure CSV_, default output DATA/listCompetitions.csv_
_ApiBF –-ListCompetitions RS RA – DATA/listCompetitionsMY.json
- default structure JSON, relative path for output file DATA/listCompetitionsMY.json
_ApiBF –-ListCompetitions RS RA CSV_ D:/listCompetitionsMY.csv_ (or CSV_qn)
- structure CSV_, absolute path for output file listCompetitionsMY.csv_
_ApiBF –-ListCompetitions RS RA CSV_|param1=??|param2=??|…| D:/listCompetitionsMY.csv_
- structure CSV_, filtering with parameters in |list| (see parameter#4, Appendix C)
!!! DIRECTORY FOR OUTPUT FILE HAS TO EXIST !!!
For filtering of Competitions names can be used (in this operation) both simple
wildcard "*" and _AT (Analysis of text)- place to parameter #6 – see Appendix D.
5) Api-NG operation "listTimeRanges"
Examples of command for retrieving :
_ApiBF --ListTimeRanges RS RA
- default structure JSON, default output DATA/listTimeRanges.json
_ApiBF --ListTimeRanges RS RA CSV_ (or CSV_qn ... without quotation marks)
- structure CSV_, default output DATA/listTimeRanges.csv_
_ApiBF –-ListTimeRanges RS RA – DATA/listTimeRangesMY.json
- default structure JSON, relative path for output file DATA/listTimeRangesMY.json
_ApiBF –-ListTimeRanges RS RA CSV_ D:/listTimeRangesMY.csv_ (or CSV_qn)
- structure CSV_, absolute path for output file listTimeRangesMY.csv_
_ApiBF –-ListTimeRanges RS RA CSV_|param1=???|param2=???|…| D:/listTimeRangesMY.csv_
- structure CSV_, filtering with parameters in |list| (see parameter#4, Appendix C)
!!! DIRECTORY FOR OUTPUT FILE HAS TO EXIST !!!
18
6) Api-NG operation "listEvents"
Examples of command for retrieving :
_ApiBF --ListEvents RS RA
- default structure JSON, default output DATA/listEvents.json
_ApiBF --ListEvents RS RA CSV_ (or CSV_qn ... without quotation marks)
- structure CSV_, default output DATA/listEvents.csv_
_ApiBF –-ListEvents RS RA – DATA/listEventsMY.json
- default structure JSON, relative path for output file DATA/listEventsMY.json
_ApiBF –-ListEvents RS RA CSV_ D:/listEventsMY.csv_ (or CSV_qn)
- structure CSV_, absolute path for output file listEventsMY.csv_
_ApiBF –-ListEvents RS RA CSV_|param1=???|param2=???|…| D:/listEventsMY.csv_
- structure CSV_, filtering with parameters in |list| (see parameter#4, Appendix C)
!!! DIRECTORY FOR OUTPUT FILE HAS TO EXIST !!!
For this operation can be used filter string (simple wildcard "*")
- for Event Name (place to parameter #6 – see Appendix D)
7) Api-NG operation "listMarketTypes"
Examples of command for retrieving :
_ApiBF --ListMarketTypes RS RA
- default structure JSON, default output DATA/listMarketTypes.json
_ApiBF --ListMarketTypes RS RA CSV_ (or CSV_qn ... without quotation marks)
- structure CSV_, default output DATA/listMarketTypes.csv_
_ApiBF –ListMarketTypes RS RA – DATA/listMarketTypesMY.json
- default structure JSON, relative path for output file DATA/listMarketTypesMY.json
_ApiBF –ListMarketTypes RS RA CSV_ D:/listMarketTypesMY.csv_ (or CSV_qn)
- structure CSV_, absolute path for output file listMarketTypesMY.csv_
_ApiBF –-ListMarketTypes RS RA CSV_|param1=???|param2=???|…| D:/listMarketTypesMY.csv_
- structure CSV_, filtering with parameters in |list| (see parameter#4, Appendix C)
!!! DIRECTORY FOR OUTPUT FILE HAS TO EXIST !!!
For this operation can be used filter string (simple wildcard "*")
- for Market Type (place to parameter #6 – see Appendix D)
8) Api-NG operation "listMarketCatalogue"
Examples of command for retrieving :
_ApiBF --ListMarketCatalogue RS RA
- default structure JSON, default output DATA/listMarketCatalogue.json
_ApiBF --ListMarketCatalogue RS RA CSV_ (or CSV_qn ... without quotation marks)
- structure CSV_, default output DATA/listMarketCatalogue.csv_
_ApiBF –ListMarketCatalogue RS RA – DATA/listMarketCatalogueMY.json
- default structure JSON, relat.path for output file DATA/listMarketCatalogueMY.json
19
_ApiBF –ListMarketCatalogue RS RA CSV_ D:/listMarketCatalogueMY.csv_ (or CSV_qn)
- structure CSV_, absolute path for output file listMarketCatalogueMY.csv_
_ApiBF –-ListMarketCatalogue RS RA CSV_|param1=?|param2=?| D:/listMarketCatalogue.csv_
- structure CSV_, filtering with parameters in |list| (see parameter#4, Appendix C)
!!! DIRECTORY FOR OUTPUT FILE HAS TO EXIST !!!
For Competitions Name can be used (in this operation) both filter string (simple
wildcard "*") and _AT (Analysis of text), for Names of Event and Market Type can be
used filter string (simple wildcard "*") - (place to parameter #6 – see Appendix D)
9) Api-NG operation "listMarketBook"
Examples of command for retrieving :
_ApiBF --ListMarketBook RS RA
- default structure JSON, default output DATA/listMarketBook.json
_ApiBF --ListMarketBook RS RA CSV_ (or CSV_qn ... without quotation marks)
- structure CSV_, default output DATA/listMarketBook.csv_
_ApiBF –ListMarketBook RS RA – DATA/listMarketBookMY.json
- default structure JSON, relative path for output file DATA/listMarketBookMY.json
_ApiBF –ListMarketBook RS RA CSV_ D:/listMarketBookMY.csv_ (or CSV_qn)
- structure CSV_, absolute path for output file listMarketBookMY.csv_
_ApiBF –-ListMarketBook RS RA CSV_|param1=???|param2=???|…| D:/listMarketBookMY.csv_
- structure CSV_, filtering with parameters in |list| (see parameter#4, Appendix C)
!!! DIRECTORY FOR OUTPUT FILE HAS TO EXIST !!!
20
4.2. Additional (combined) operations of program _ApiBF.EXE
This additional operations are more detailed described
- in chapter 3.5. Entry parameters, in paragraph 2)
– execution more than 1 original operation Betfairs Api-NG .
--COMPETITIONS_EVENTS - returns text file "CSV" with info about competitions + their matches/events
- 1 row info about Competition
- following rows info about matches/events of this Competition
- structure of CSV-output is described in Appendix E
--CATALOGUE_BOOK
--COMPEVENTS_MARKBOOK - returns text file "CSV" with info about competitions + their matches/events
+ current offer of Betfair for match/event (prices, amounts Back/Lay)
- structure of text file "CSV" (the same for both this operations) is described in
Appendix F
- for operation --CATALOGUE_BOOK is bigger danger of error response TOO_MUCH_DATA
- operation --COMPEVENTS_MARKBOOK can work faster (for acceleration to maximise
using of original Betfairs parameters for competitions, events...)
Examples of retrieving :
--Competition_Events
_ApiPS --Competition_Events RS RA CSV_|param1=?|param2=?| D:/Competition_EventsMY.csv_
Filter_AT#|#|#otherFilters directory_AT
- structure CSV_, filtering with parameters in |list| + in parameter#6(see Appendix D)
!!! DIRECTORY FOR OUTPUT FILE HAS TO EXIST !!!
For Competitions Name can be used (in this operation) both filter string (simple
wildcard "*") and _AT (Analysis of text), for Event Name can be used filter string
(simple wildcard "*") - (place to parameter #6 – see Appendix D)
--Catalogue_Book , --CompEvents_MarkBook
_ApiPS --Catalogue_Book RS RA CSV_|param1=???|param2=???|
D:/Catalogue_BookMY.csv_ Filter_AT#|#|#otherFilters directory_AT
_ApiPS --CompEvents_MarkBook RS RA CSV_|param1=???|param2=???|
D:/CompEvents_MarkBookMY.csv_ Filter_AT#|#|#otherFilters directory_AT
For Competitions Name can be used (in these operations) both filter string (simple
wildcard "*") and _AT (Analysis of text), for Names of Event and Market Type can be
used filter string (simple wildcard "*") - (place to parameter #6 – see Appendix D)
21
4.3. Other operations of Betfairs Api-NG - Managing of bets (direct retrieving)
Other Betting Operations
listClearedOrders , listCurrentOrders , listMarketProfitAndLoss
cancelOrders , placeOrders , replaceOrders , updateOrders
Fastest retrieving of services with direct json-rpc calls in C#/VB/Python
From version 1.1.26 are in examples :
a) console operation for C# ( see subfolder VisualCsharp_CONSOLE )
b) console operation for VB ( see subfolder VisualBasic_CONSOLE )
c) script for Python ( see subfolder Python_CONSOLE )
Functions with identical name Get_ResponseJson in these 3 languages
- for fastest direct retrieving of services BetFair without using any external program
- this retrieving returns data only in JSON structure (not CSV)
Usage of this functions can be combined with usage of programs described in
previous chapters
f.e.
1) retrieving of Api-NG operation ListCompetitions for getting competitions list
(for basic filtering can be used string prepared by program _ApiBF_par.EXE)
2) list of competitions can be processed by users program
3) only for selected competitions fastest direct retrieving of operation listEvents
(function Get_ResponseJson for CompetitionsID returns JSON-string with events)
4.4. Complete DEMO – Download of BetFairs Odds for requested matches with using
"Analysis of Texts" ( for matching with offer of other bookie )
Demoversions (Windows Applications in Visual Basic and Visual C# including source
codes) contain form "frmOTHERbookie"; this form should demonstrate :
CONNECTION OF DOWNLOADS OF ODDS FROM DIFFERENT SOURCES AND MATCHING OF CORRES-
PONDING MATCHES, BETTYPES AND PRICES FOR PROCESSING OF VALUE BETS, SURE BETS…
Download of prices (of other bookie) is simulated in this example BY :
TEXT FILE in subdirectory of installation folder DATA \ _LeaguesMatchesWEEK.TXT
this file contains fixtures of several competitions in next weeks
user can edit content of this file (correct current matches, teams for Premier
league, Bundesliga or add interesting leagues) for testing of next steps
demoversion downloads in next steps current offer (matches, odds, …) of Betfair
(with Api-NG operations); success of matching is determined by currency of matches in
text file _LeaguesMatchesWEEK.TXT
Example of content of text file _LeaguesMatchesWEEK.TXT (section for 1 league):
COMP:FOO;England;Premier League;BWIN;01.-03.Nov 2014
Newcastle United;FC Liverpool;
FC Everton;Swansea City;
FC Arsenal;Burnley;
Hull City;Southampton FC;
FC Chelsea;Queens Park Rangers;
Leicester City;West Bromwich Albion;
Stoke City;West Ham United;
22
Manchester City;Manchester Utd;
Aston Villa;Tottenham Hotspur;
Crystal Palace;Sunderland;
First row describes COMPetition (FOO=Football, State=England, Name=Premier League).
Remaining data-items are only for information (displayed in list of competitions for
selection in combobox).
Next rows should contain matches(names of teams) played in next hours, days.
STEP #1 – CHOICE of COMPETITION (LEAGUE) – of OTHER BOOKIE
In left upper corner is specification of Input text file and combobox for choice of
competition – in offer are competitions from text file (rows COMP:... ) :
For selected competition are displayed :
- content of row COMP in collapsed combobox
- matches (following rows in text file) - in left box for matches
STEP #2 – LOOKING UP of COMPETITION (LEAGUE) in BETFAIRs current offer
After mouse click (button "Search Competition") are displayed parameters of found
competition (in system for "Analysis of texts" - abbreviations for state, league +
description of competition/league).
Text field below contains ID of found competition/league in Betfairs database.
Button "Search Competition" is after this step passivated.
From version 1.2.12 in upper right corner Checkbox "with Quotes" – for this setting
(not checked)(=> prefix CSV_qn), output file without quotation marks.
STEP #3 – MATCHING of EVENTS (MATCHES) in BETFAIRs current offer
After mouse click (button "Search Matches") are displayed (for matches and teams in
left blue box - from text file=from offer of other bookie) in the right green box
"RESULTS – MATCHES (BetFair) " corresponding events(matches) from current BetFairs
offer.
In parenthesis are abbreviations of both teams.
23
Text fields in the right contain ID of events/matches in Betfairs database (for
download of bets in next step). Button "Search Matches" is after this step passivated.
STEP #4 – DOWNLOAD OF PRICES & AMOUNTS Back/Lay with BetFairs Api-NG
Checkboxes – for choice of download only for concrete matches.
How to define concrete bet types for download with Filter – see chapter 3.6 .
Download starts with button "Search Bets". Result is written to text file *.CSV_
(structure see Appendix F), his content is displayed in form(window) for results.
COMMENT :
This procedure is DEMO – in source code of windows application (Visual Basic / C# , in
form frmOTHERbookie.VB / *.VC) are for concrete steps detailed commands.
Real users application can execute downloads of prices without dividing into separated
steps, procedure (matching with "Analysis of texts" – with library DLL) can be
repeated for different bookies.
24
5. Auxiliary programs _ApiBF_???.EXE, libraries DLL_???.DLL
5.1. Program _ApiBF_ses.EXE – getting of Sessiontoken
This program can be used for getting of SessionToken (string 40 characters) for
Betfairs Api-NG services – in all demoversions _ApiBF (both console applications and
windows forms applications).
Info about version and program directory of program _ApiBF_ses.EXE with command:
_Api_NG_ses.EXE --VERSION (to retrieve in command line)
Parameters of program _ApiBF_ses.EXE are :
Parameter#1 = users username&password for Betfair account
"username=???&password=???"
Parameter#2 = specification of file (registration key, certificate)
a) relative PATH/filename.ext (in program directory)
f.e. KEYS/client-2048.p12
b) absolute Specification
f.e. D:/_Api_Install/KEYS/client-2048.p12
Parameter#3 = unused parameter (password for key *.p12)
Parameter#4 = Specification of Output File
a) relative PATH/filename.ext (in program directory) f.e. DATA/_SessionToken.txt
b) absolute Specification f.e. D:/_Api_Install/DATA/_SessionToken.txt
!!! DIRECTORY FOR OUTPUT FILE HAS TO EXIST (before retrieving of _ApiBF_ses.EXE) !!!
Quotation marks have to be used for parameters that contain spaces or separators – in
this case parameter "username=MYUSERNAME&password=MYPASSWORD" contains character "&")
Return value :
- file (see Parameter#4) contains SessionToken (string 40 characters)
- for all operations of program _ApiBF.EXE and value of Parameter#2 = RS reads program
_ApiBF SessionToken from this data file
5.2. Program _ApiBF_par.EXE – getting of Request (reduced) for Betfairs Api-NG
Better way (than using of this program) is (in programming languages VB, C#, ...)
usage of library DLL_ApiBF_par.dll (see next chapter)
This program can be used f.e. in Python for getting of string with parameters for
Betfairs Api-NG request – see console application(script) in Python , chapter 3.2.
Reduced string (of request) with parameters has to be extended to complete request
string (with name of Betfairs Api-NG operation + other parameters)
Info about version and program directory of program _ApiBF_par.EXE with command :
_Api_NG_par.EXE –VERSION (to retrieve in command line)
Parameters of program _ApiBF_par.EXE are :
Parameter#1 = Specification of Output File
a) default value "-" or – or RP or "RP"
DATA/_Parameters.txt
b) relative PATH/filename.ext (in program directory)
f.e. DATA/_ParametersMY.txt
c) absolute Specification
f.e. D:/_Api_Install/DATA/_Parameters.txt
!!! DIRECTORY FOR OUTPUT FILE HAS TO EXIST (before retrieving of _ApiBF_par.EXE) !!!
25
Parameter#2 = List of parameters in string (separator is character "|")
|ident1=value|ident2=value|...|
identN ... (no distinction between lower/upper characters)
value ... if contains " " (space) or other separator => TO USE QUOTATION MARKS
"|ident1=value|ident2=value|...|"
Identifiers of individual parameters in Parameter#2 – see Appendix B
Examples of usage, results :
_ApiBF_par "–" |id=1|
... Result into Output file DATA/_Parameters.txt (Parameter#1 = "–") :
"'params': {'filter':{ }}, 'id': 1"
_ApiBF_par – id=1 |EVENTTYPEIDS=1,2,5|
... Result into Output file DATA/_Parameters.txt (Parameter#1 = –) :
"'params': {'filter':{'eventTypeIds':['1','2','5']}}, 'id': 1"
... this content is going to filter in operation "--ListEventTypes" only sports with
id = 1 or 2 or 5 ( Soccer / Tennis / Rugby )
_ApiBF_par DATA\_ParametersMY.txt |id=1|eventTypeIds=1|marketCountries=BR|from=2014-
06-01T22:00:00Z|to=2014-06-30T22:00:00Z|
... Result into Output file DATA/_ParametersMY.txt
'params':{'filter':
{'eventTypeIds':['1'], 'marketCountries':['BR'],
'marketStartTime':{'from':'2014-06-01T22:00:00Z','to':'2014-06-30T22:00:00Z'}
}}, 'id':1
... Selection f.e. Events – Sport=Soccer and Country=Brasil and June 2014
(matches of World Championship 2014 in Brasil)
_ApiBF_par "-"
|maxResults=200|competitionIds=31|marketTypeCodes=DRAW_NO_BET,MATCH_ODDS|id=1|marketPr
ojection=COMPETITION,EVENT,EVENT_TYPE,RUNNER_DESCRIPTION|
Comment#1 competitionIds=31 Barclays Premier League
Comment#2 outputfile DATA/_Parameters.txt
5.3. Library DLL_ApiBF_par.dll - support for request strings Betfairs Api-NG
This library provides support for request string Betfairs Api-NG services
a) for direct retrieving of Api-NG services from users programs in all languages
b) inside the program _ApiBF.EXE for processing of parameter#4 (list of parameters|…|)
It can be included into programs (in Visual Basic, Visual C#, C++ …)
- see demoversions (windows form applications), forms for demonstration of retrieving
Betfair Api-NG operations
How to include this library into users program :
Visual Basic Visual C# Imports DLL_ApiBF_par using DLL_ApiBF_par;
All offered variables, functions ... are included in static class DLLap
1) Info about versions number :
DLLapp.stVersion (value f.e. "1.2.05")
26
2) Functions for request string – Betfairs Api-NG operations – Betting
Api-NG operation Function in DLL
(DLLap.FuncRequestBet_List????) ListCompetitions DLLap.FuncRequestBet_ListCompetitions() ListCountries DLLap.FuncRequestBet_ListCountries()
ListEvents DLLap.FuncRequestBet_ListEvents()
ListEventTypes DLLap.FuncRequestBet_ListEventTypes()
ListMarketBook DLLap.FuncRequestBet_ListMarketBook()
ListMarketCatalogue DLLap.FuncRequestBet_ListMarketCatalogue()
ListMarketTypes DLLap.FuncRequestBet_ListMarketTypes()
ListTimeRanges DLLap.FuncRequestBet_ListTimeRanges()
ListVenues DLLap.FuncRequestBet_ListVenues()
Functions in Visual Basic : Public Shared Function FuncRequestBet_List??????(
ByVal stListParams As String, ByRef enApiBF_Error As enApiBF_ErrorCode,
Optional ByVal chDelimiter As String = """") As String
Functions in Visual C# : public static string FuncRequestBet_List??????(string stListParams,
ref enApiBF_ErrorCode enApiBF_Error, string chDelimiter As = "")
parameter#1 – list of parameters in 1 string (separator is character "|")
- only parameters for operations Betfairs Api-NG – Betting operations – see
Appendix B (Group of parameters I)
- f.e. "|id=1|eventTypeIds=1,2,3|"
Parameter#2 – return value of function - errorCode (type enApiBF_ErrorCode)
- enApiBF_OK = 0 / enErrCod071errPar_Ident (unknown identifier) /
enErrCod073errPar_CombParams (combination of parameters Betting & Orders / …)
Parameter#3 – delimiter in returned request string (default char ", other char ‘)
Return value = complete request string for Betfairs Api-NG operation
f.e. function FuncRequestBet_ListEventTypes (for operation ListEventTypes and list
of parameters "|id=1|eventTypeIds=1,2,3|") returns request string
{"jsonrpc": "2.0", "method": "SportsAPING/v1.0/listEventTypes", "params":{
"filter":{"eventTypeIds":["1","2","3"]}},"id":1}
3) Functions for request string – Betfairs Api-NG operations – Managing of orders
Api-NG operation Function in DLL (DLLap.FuncRequestBet_List???? ListClearedOrders DLLap.FuncRequestOrd_ListClearedOrders()
ListCurrentOrders DLLap.FuncRequestOrd_ListCurrentOrders()
ListMarketProfitAndLoss DLLap.FuncRequestOrd_ListMarketProfitAndLoss()
CancelOrders DLLap.FuncRequestOrd_CancelOrders()
PlaceOrders DLLap.FuncRequestOrd_PlaceOrders()
ReplaceOrders DLLap.FuncRequestOrd_ReplaceOrders()
UpdateOrders DLLap.FuncRequestOrd_UpdateOrders()
Functions in Visual Basic : Public Shared Function FuncRequestOrd_??????(
ByVal stListParams As String, ByRef enApiBF_Error As enApiBF_ErrorCode,
Optional ByVal chDelimiter As String = """") As String
Functions in Visual C# : public static string FuncRequestOrd_??????(string stListParams,
ref enApiBF_ErrorCode enApiBF_Error, string chDelimiter As = "")
parameter#1 – list of parameters in 1 string (separator is character "|")
- only parameters for operations Betfairs Api-NG – Managing of orders – see
Appendix B (Group of parameters II)
- f.e. "|ORD_id=1|ORD_eventTypeIds=1,2,3|"
27
Parameter#2 – return value of function - errorCode (type enApiBF_ErrorCode)
- enApiBF_OK = 0 / enErrCod071errPar_Ident (unknown identifier) /
enErrCod073errPar_CombParams (combination of parameters Betting & Orders / …)
Parameter#3 – delimiter in returned request string (default char ", other char ‘)
4) OTHER functions in Class DLLap :
Function FuncErrCode_ToText(ByVal enERR_CODE As enApiBF_ErrorCode) As String ERROR TEXT FOR ERROR CODE
parameter#1 = error code
RETURNS : error text for this error code
Function FuncRemoveParamFromStr(ByVal stLIST_PARAM As String, ByVal stIDENT_PARAM As String) As String
REMOVING OF 1 PARAMETER + HIS VALUE FROM LIST OF PARAMETERS
parameter#1 = list of parameters in 1 string (separator is character "|")
parameter#2 = ident of parameter (is going to be removed from list of parameters)
RETURNS : list of parameters without parameter stIDENT_PARAM
Function FuncGetParamFromStr(ByVal stLIST_PARAM As String, ByVal stIDENT_PARAM As String) As String
GETTING OF VALUE OF 1 PARAMETER FROM LIST OF PARAMETERS
parameter#1 = list of parameters in 1 string (separator is character "|")
parameter#2 = ident of parameter (his value is going to be returned from list)
RETURNS : value of parameter with identifier stIDENT_PARAM
Function FuncState2charsInfo(ByVal stState2 As String) As String FOR ABBREVIATION 2 CHARACTERS RETURNS ABBREVIATION 3 CHARS + NAME OF STATE
parameter#1 = abbreviation of state (2 characters) f.e. "CH"
RETURNS : CHE~Switzerland (Confederation Of Helvetia)
Function FuncState2_toState3(ByVal stState_2 As String) As String parameter#1 = abbreviation of state (2 characters) f.e. "GB"
RETURNS : abbreviation of this state (3 characters) f.e. "GBR"
Function FuncListStatesCorrection(ByVal stListStates3 As String) As String parameter#1 = abbreviation of state (3 characters) f.e. "GBR"
RETURNS : abbreviation of this state (2 characters) f.e. "GB"
OR
parameter#1 = list of states (2 or 3 characters, separator ",") f.e. "GB,GER"
RETURNS : list of states (2 characters) f.e. "GB,DE"
("english" abbreviations f.e. "GER" are replaced with asked abbreviations "DEU",
similar "ALG"->"DZA" , "CHI"->"CHL" , "CRO"->"HRV" , "DEN"->"DNK" , "GER"->"DEU" ,
"GRE"->"GRC" , "HOL"->"NLD" , "ICE"->"ISL" , "JAP"->"JPN" , "NED"->"NLD" ,
"ROM"->"ROU" , "SUI"->"CHE" , "UAE"->"ARE")
This function is used for correction of parameter marketCountries
– user can set into field of form (in demoversions) list of countries based on better
known 3 chars-abbreviations and into Betfairs Api-NG operation is passed asked list of
2 chars-abbreviations.
5.4. Library DLL_AnalTextStaSpo.dll - support for Analysis of texts
clAnalTextState – Class for States, basic variables, routines
clAnalTextSport – Class for 1 Sport (his leagues, teams)
1) Info about versions number, STATIC functions :
clAnalTextState.stVersion (value f.e. "1.2.05")
Function FuncEnText3toSPO(ByVal st_COD_Spo3 As String) As enSportTyp parameter#1 = abbreviation of sport (3 characters) "FOO" / "HOC"
RETURNS : value enSportTyp.enSportFOO / enSportTyp.enSportHOC
28
Function FuncEnSPOtoText3(ByVal en_Sport As enSportTyp) As String parameter#1 = value enSportTyp.enSportFOO / enSportTyp.enSportHOC
RETURNS : abbreviation of sport (3 characters) "FOO" / "HOC"
Dim enSport As DLL_AnalTextStaSpo.clAnalTextState.enSportTyp
enSport = clAnalTextState.FuncEnText3toSPO("FOO") return value enSportTyp.enSportFOO
stSport3 = clAnalTextState.FuncEnSPOtoText3(enSport) return value "FOO"
2) How to get instances of classes :
Dim enEnglish As DLL_AnalTextStaSpo.clAnalTextState.enLanguageTyp = _
clAnalTextState.enLanguageTyp.enLanguageEN
Dim enFootball As DLL_AnalTextStaSpo.clAnalTextState.enSportTyp = _
clAnalTextState.enSportTyp.enSportFOO
Dim clAnalTextStateMY As DLL_AnalTextStaSpo.clAnalTextState = _
New DLL_AnalTextStaSpo.clAnalTextState(enEnglish, stDirectoryAT)
Dim clAnalTextSportFOO As DLL_AnalTextStaSpo.clAnalTextSport = _
New DLL_AnalTextStaSpo.clAnalTextSport(enFootball,clAnalTextStateMY)
3) How to Init classes (reading of data files – Names States, Leagues, Teams) :
Dim stErrMsgBack As String = "", boOK As Boolean = True
clAnalTextStateMY.FuncInitReadNames_States(stErrMsgBack)
If stErrMsgBack <> "" Then
MessageBox.Show("ERROR: Unsuccessful reading of file ‘NAMES of STATES‘ & vbCrLf & _
"( " & stErrMsgBack & " )", "Error reading ‘NAMES of STATES‘",
MessageBoxButtons.OK, MessageBoxIcon.Error)
End If
clAnalTextSportFOO.FuncIniNames_LeaguesTeams(False, stErrMsgBack)
If stErrMsgBack <> "" Then
boOK = False
MessageBox.Show("ERROR: Unsuccessful Init Names - Football" & vbCrLf & _
"( " & stErrMsgBack & " )", "Error reading Init Names (Leagues & Teams) ",
MessageBoxButtons.OK, MessageBoxIcon.Error)
End If
4) DYNAMIC Variables, Functions of Class clAnalTextState :
Current language (of strings with description of State, League, Teams) clAnalTextStateMY.enLanguageCurr As enLanguageTyp
( enLanguageEN / enLanguageDE / enLanguageCZ / enLanguageXXX )
Directory of files for Analysis of texts stDirectoryAT = clAnalTextStateMY.stDirectoryAT
SEARCH of STATE - FOR CODE of State 3 chars RETURNS NAME OF STATE(in current language)
Function FuncCodeSta3_ToStateDscr(ByVal stCOD_Sta3 As String,
ByRef stSTATEdscr_Back As String) As Boolean parameter#1 = code of state (Alpha 3) – f.e. "ESP"
parameter#2 = RETURN VALUE for state : Name of state in current language
(f.e. Spain / Spanien / Spanelsko)
RETURNS : value False/True (found ?)
SEARCH of STATE – FOR TEXT(name) OF STATE ( code of region is OPTIONAL )
Function FuncSearchState(ByVal stCOD_Reg3 As String, ByVal stSTATE_TEXT As String, ByRef stCOD_Sta3_Back As String, ByRef stSTATEdscr_Back As String) As Boolean
parameter#1 = "" OR code of region(continent) ("EUR"/"AFR"/"ASI"/"AME")
parameter#2 = TEXT FOR SEARCH of STATE
parameter#3 = RETURN VALUE for State : Abbreviation 3 chars (Alpha 3)
parameter#4 = RETURN VALUE for State : Name of state in current language
RETURNS : value False/True (found ?)
Examples: see demoversion (Windows Forms Application VB/C#) - form frmStates
29
5) DYNAMIC Functions of Class clAnalTextSport :
SEARCH of LEAGUE – FOR CODE of STATE (3 chars Alpha) + TEXT(name) OF LEAGUE
( code of League 5 chars only for known league – getting of its parameters )
Function FuncSearchLeague(ByVal stCOD_Sta3 As String, ByVal stCOD_Lea5 As String, ByVal stLEAG_TEXT As String, ByRef stLEAGdscr_Back As String,
ByRef stCOD_Wom3_Back As String, ByRef stCOD_CsnPrio_Back As String) As String
parameter#1 = "" OR code of state (from FuncSearchState – 3 chars Alpha) parameter#2 = "" OR max. 5 chars f.e. "1.L"/"CUP"/"CH" (optional)
parameter#3 = "" OR TEXT FOR SEARCH of LEAGUE
parameter#4 = RETURN VALUE for League : Name of League in current language
parameter#5 = RETURN VALUE for League : Code max. 3 chars (Men, Women, UnderNN)
parameter#6 = RETURN VALUE for League : Code C(clubs)/S(states)/N(participants
not defined + Priority 1 char "1".."5", maximal "5")
RETURNS : string "State3,Leag5" – f.e. "ENG,1.L" is return value for search text
"England Premier League"
Examples: see demoversion (Windows Forms Application VB/C#) - form frmLeagues
Dim stLeagDscrBack As String = "", stCodeWom3back As String = ""
Dim stCodeCsnPrioBack As String = "", stState3League5 As String = ""
stState3League5 = clAnalTextSportFOO.FuncSearchLeague("ENG", "", "Championship", stLeagDscrBack, stCodeWom3back, stCodeCsnPrioBack)
RETURNS : stState3League5="ENG,2.L", stLeagDscrBack="Championship",
stCodeWom3back = "M", stCodeCsnPrioBack = "c4"
stState3League5 = clAnalTextSportFOO.FuncSearchLeague("ENG", "3.L", "", stLeagDscrBack, stCodeWom3back, stCodeCsnPrioBack)
RETURNS : stState3League5="ENG,3.L", stLeagDscrBack="League One",
stCodeWom3back = "M", stCodeCsnPrioBack = "c3"
stState3League5 = clAnalTextSportFOO.FuncSearchLeague("","","Champions League UEFA", stLeagDscrBack, stCodeWom3back, stCodeCsnPrioBack)
RETURNS : stState3League5="EUR,CUPCZ", stLeagDscrBack="UEFA - Champions League",
stCodeWom3back = "M", stCodeCsnPrioBack = "c5"
Comments:
- the same parameters for league/competition (f.e. "ENG,2.L,M") returns program _ApiBF
in additional operations – in row for competition ("COMP" – see Appendix E,F)
- the same parameters returns also program _ApiPS (for Pinnacle)
- the more correct values in parameters #1, #2 and #3, the better response of function
- it is way how to search for league from users program a corresponding competition in
current Betfairs Api-NG competitions or how to get for different names of leagues (+
states) in offers of different bookies => 1 league with the same identifiers (3+5
chars)
SEARCH of TEAM – FOR CODE of STATE (3 chars Alpha) + CODE of LEAGUE (3-5 chars) + TEXT
Function FuncSearchTeam(ByVal stCOD_Sta3 As String, ByVal stCOD_Lea5 As String, ByVal stCOD_Wom3 As String, ByVal stTEAM_TEXT As String,
ByRef stTEAMdscr_Back As String, ByRef stCOD_Sta3Lea5_Back As String) As String
parameter#1 = "" OR code of state (from FuncSearchState – 3 chars Alpha)
parameter#2 = "" (max. 5 chars f.e. "1.L"/"CUP" optional– from FuncSearchLeague) parameter#3 = "M" OR "W" OR ... ("" = "M")
parameter#4 = "" OR TEXT FOR SEARCH of TEAM
parameter#5 = RETURN VALUE for Team : Name of Team (from DLL_AnalTextStaSpo.dll)
parameter#6 = RETURN VALUE for Team : parameters of League
RETURNS : abbreviation 5 characters – identifier of Team (non-duplicate)
Examples: see demoversion (Windows Forms Application VB/C#) - form frmTeams
Dim stTeam5 As String, stTEAMdscrBack As String="", stCodeSta3Lea5back As String=""
stTeam5 = clAnalTextSportFOO.FuncSearchTeam("", "2.L", "", "Liverpool", stTEAMdscrBack, stCodeSta3Lea5back)
RETURNS : stTeam5 = "LIVER"
stTEAMdscrBack="Liverpool FC", stCodeSta3Lea5back = "ENG,1.L"
30
stTeam5 = clAnalTextSportFOO.FuncSearchTeam("EUR", "CUP", "", "Maribor", stTEAMdscrBack, stCodeSta3Lea5back)
RETURNS : stTeam5 = "MARNK"
stTEAMdscrBack="Maribor NK", stCodeSta3Lea5back = "SVN,1.L"
stTeam5 = clAnalTextSportFOO.FuncSearchTeam("ITA", "2.L", "", "Bergamo", stTEAMdscrBack, stCodeSta3Lea5back)
RETURNS : stTeam5 = "BEATA"
stTEAMdscrBack="Atalanta Bergamo", stCodeSta3Lea5back = "ITA,1.L"
stTeam5 = clAnalTextSportFOO.FuncSearchTeam("ITA", "3.L", "", "Atalanta", stTEAMdscrBack, stCodeSta3Lea5back)
RETURNS : stTeam5 = "BEATA"
stTEAMdscrBack="Atalanta Bergamo", stCodeSta3Lea5back = "ITA,1.L"
Comments:
- the same identifiers for teams (f.e. "LIVER", "MARNK" , "BEATA") returns program
_ApiBF in additional operations – in row for event=match ("EVEN") - teams Home & Away
- the more correct values in parameters #1, #2, #3 and #4, the better response of
function, but see first example – for Liverpool + missing state "ENG" and incorrect
league "2.L" (or Atalanta Bergamo in "2.L"/"3.L") is response correct
- it is way how to search for match from users program a corresponding event(=match)
in current Betfairs Api-NG events or how to get for different names of 1 team in
offers of different bookies the same identifier (5 chars)
6. Download, Update, Upgrade, Contact
www.betoptim.com/en - WEBPAGE
http://www.betoptim.com/index.aspx?lang=EN&start=DownInst - INSTALLATION
[email protected] - EMAIL
6.1. Update of files for Analysis of texts , of DLL_AnalTextStaSpo.dll
Functionality of "Analysis of Texts" is based on data files (for "Names of States", "Names of Leagues" and "Names of Teams"
+ helping file for Correction of names Leagues/Competitions Betfair).
Demoversions (Windows Applications in Visual Basic and Visual C# including source
codes) contain form "frm_Update_AT" for update of this files
see column Help of this applications
current versions of this files are placed in webpage www.betoptim.com
downloaded file is stored on users PC with date&time of internet version
higher date&time current internet version indicates newer file for download
form "frm_Update_AT" (or his clone) can be included into users program
.
31
Appendix A - Error Codes, Error Messages
011...Error_UNKNOWN_OPERATION
012...Error_SessionToken
013...Error_AppKey
014...Error_Parameters
015...Error_CSV_Option
016...Error_JSON_NotAllowed
017...Error_OnlyRP_ReadParam
018...Error_READ_OUTPUT
019...Error_SAVE_OUTPUT
021...Error_CompetitionIds
022...Error_MarketIds
030...Error_Response
050...NotFound_SUBPROGRAM
051...ErrorCall_SUBPROGRAM
052...SUBPROGRAM_NoOutput
056...ErrorCallProg_ApiBF
057...ErrorCallProg_ApiBF_par
058...ErrorCallProg_ApiBF_req
059...ErrorCallProg_ApiBF_ses
061...ApiBF_UNKNOWN_OPERATION
065...ErrApiBF_CSV_Option
068...ErrApiBF_READ_OUTPUT
069...ErrApiBF_SAVE_OUTPUT
071...ErrPar_Ident
073...ErrPar_CombParams
074...ErrPar_OtherOperParams
075...ErrPar_TooManyParams
079...ErrPar_SAVE_OUTPUT
081 ErrReq_NoServiceBetfair
082...ErrReq_SessionToken
083...ErrReq_AppKey
085...ErrReq_Response
086 ErrReq_NoValidOperBetfair
089...ErrReq_SAVE_OUTPUT
092...ErrSes_SessionToken
093...ErrSes_AppKey
099...ErrSes_SAVE_OUTPUT
### COMBINED OPERATIONS
120 Error_Par4_CompetitionsReq
121 Error_Par4_CompetitionsResp
122 Error_Par4_Comp_EventsReq
123 Error_Par4_Comp_EventsResp
126 Error_Par4_CatalogueReq
127 Error_Par4_CatalogueResp
129 Error_Par4_HasToBeList
130 Err_AT_Key_Structure
131 Err_AT_Key_WrongEndDate
132 Err_AT_Key_ExpiredEndDate
135 Err_AT_UnsupportedSport
136 Err_AT_UnsupportedLanguage
141 Err_AT_InitStates
142 Err_AT_InitLeaguesFOO
143 Err_AT_InitLeaguesHOC
144 Err_AT_InitTeamsFOO
145 Err_AT_InitTeamsHOC
150 Err_AT_ReadCorrLeagues
151 Err_AT_Filter
155 Err_FilterName
159 Err_PrioMin
32
Appendix B - Overview of parameters for Api-NG requests in _ApiBF???.EXE
Original parameters in requests Api-NG (black on the left, 3 levels) are in program
set _ApiBF replaced with other parameters (blue on the right, 1 level).
Auxiliary program _ApiBF_par.EXE or main program _ApiBF.EXE can process this 1-level
parameters ( from string |identifier1=value|identifier2=value|...| ) + transform them
to request Api-NG + insert delimiters ( { } [ ] ‘ ‘) and parameters params, filter …
One original Betfairs parameter can have in program set _ApiBF (in groups I and II)
different identifiers (in group II with suffix "ORD_")
A parameter string |identifier1=value|...| can contain either parameters of Group I
or parameters of Group II – Group is given by current operation Api-NG
Combination of parameters I + II in one string causes ERROR 073 (ErrPar_CombParams)
For certain parameters are inserted delimiters (apostrophes/quotation marks)
For parameters Date&Time can be used value DECIMAL (in hours – NOW = 0.0), value in
days can be written as f.e. |from=0.5|to=7x24| (from now+30 min ; within 7 days)
For Countries (parameter marketCountries) are abbreviations 3 characters
transformed to abbreviations 2 characters (with corrections see chapter 5.3.
function FuncListStatesCorrection)
How to use parameter string |identifier1=value|...| - see Appendix C
Group I - Betting Operations (listCompetitions, listCountries, listEvents, listEventTypes, listMarketBook,
listMarketCatalogue, listMarketTypes, listTimeRanges, listVenues)
Identifier of Parameter
in program _ApiBF_par
'params'
'marketIds' SET [strings] marketIds
'filter'
'bspOnly' true/false bspOnly
'competitionIds' SET [strings] competitionIds
'eventIds' SET [strings] eventIds
'eventTypeIds' SET [strings] eventTypeIds
'exchangeIds' SET [strings] exchangeIds
'marketStartTime'
'from' yyyy-mm-ddThh:mm:ssZ from
'to' yyyy-mm-ddThh:mm:ssZ to
'inPlayOnly' true/false inPlayOnly
'marketBettingTypes' SET [ODDS,LINE,RANGE,FIXED_ODDS,
ASIAN_HANDICAP_SINGLE_LINE, ASIAN_HANDICAP_DOUBLE_LINE]
marketBettingTypes
'marketCountries' SET [strings] marketCountries
'marketIds' SET [strings] marketIdsFI
'marketTypeCodes' SET [strings] marketTypeCodes
'textQuery' string textQuery
'turnInPlayEnabled' true/false turnInPlayEnabled
'venues' SET [strings] venues
'withOrders' SET [EXECUTION_COMPLETE,EXECUTABLE] withOrders
'priceProjection'
'priceData' SET [SP_AVAILABLE,SP_TRADED,EX_BEST_OFFERS,
EX_ALL_OFFERS,EX_TRADED] priceData
'rolloverStackes' true/false rolloverStackes
'virtualise' true/false virtualise
'exBestOffersOverrides'
'bestPricesDepth' integer bestPricesDepth
'rollupLimit' integer rollupLimit
'rollupLiabilityThreshold' double rollupLiabilityThreshold
'rollupLiabilityFactor' integer rollupLiabilityFactor
'rollupModel' string STAKE/PAYOUT/MANAGED_LIABILITY/NONE rollupModel
33
'currencyCode' string currencyCode
'locale' string locale
'granularity' string DAYS/HOURS/MINUTES granularity
'marketProjection' SET [COMPETITION,EVENT,EVENT_TYPE,MARKET_START_TIME,
MARKET_DESCRIPTION,RUNNER_DESCRIPTION,RUNNER_METADATA] marketProjection
'maxResults' integer maxResults
'sort' string MINIMUM_TRADED/MAXIMUM_TRADED/MINIMUM_AVAILABLE/
MAXIMUM_AVAILABLE/FIRST_TO_START/LAST_TO_START sort
'id' integer id
Group II - Other Operations Identifier of Parameter
in program _ApiBF_par
A) placeOrders, cancelOrders, replaceOrders, updateOrders
'params'
'marketIds' SET [strings] ORD_marketIds
'instructions' LIST [{string}] ORD_instructions
'customerRef' string ORD_customerRef
'id' integer ORD_id
B) listMarketProfitAndLoss
'params'
'marketIds' SET [strings] ORD_marketIds
'includeSettledBets' true/false ORD_includeSettledBets
'includeBspBets' true/false ORD_includeBspBets
'netOfCommission' true/false ORD_netOfCommission
'id' integer ORD_id
C) listCurrentOrders
'params'
'betIds' SET [strings] ORD_betIds
'marketIds' SET [strings] ORD_marketIds
'orderProjection' string ALL/EXECUTABLE/EXECUTION_COMPLETE
'placedDateRange' = TIMERANGE
'from' yyyy-mm-ddThh:mm:ssZ placedDateRange_from
'to' yyyy-mm-ddThh:mm:ssZ placedDateRange_to
'dateRange' = TIMERANGE
'from' yyyy-mm-ddThh:mm:ssZ ORD_from
'to' yyyy-mm-ddThh:mm:ssZ ORD_to
'orderBy' string BY_BET/BY_MARKET/BY_MATCH_TIME/BY_PLACE_TIME
BY_SETTLED_TIME/BY_VOID_TIME ORD_orderBy
'sortDir' string EARLIEST_TO_LATEST/LATEST_TO_EARLIEST ORD_sortDir
'fromRecord' integer ORD_fromRecord
'recordCount' integer ORD_recordCount
'id' integer ORD_id
D) listClearedOrders
'params'
'betStatus' string SETTLED/VOIDED/LAPSED/CANCELLED ORD_betStatus
'eventTypeIds' SET [strings] ORD_eventTypeIds
'eventIds' SET [strings] ORD_eventIds
'marketIds' SET [strings] ORD_marketIds
'runnerIds' SET [strings] ORD_runnerIds
'betIds' SET [strings] ORD_betIds
'side' string BACK/LAY ORD_side
'settledDateRange' string
'from' yyyy-mm-ddThh:mm:ssZ settledDateRange_from
'to' yyyy-mm-ddThh:mm:ssZ settledDateRange_to
'groupBy' string EVENT_TYPE/EVENT/MARKET/SIDE/BET ORD_groupBy
'includeItemDescription' true/false ORD_includeItemDescription
'locale' string ORD_locale
'fromRecord' integer ORD_fromRecord
'recordCount' integer ORD_recordCount
'id' integer ORD_id
34
Appendix C - Parameter #4 (required values or other parameters for Filtering)
Prefix of parameter#4 – "CSV_" => change of output structure JSON -> output CSV "with quotation marks"
(separator of values = character ";", delimiter of values = character ")
- "CSV_qn" => change of output structure JSON -> output CSV "without quotation marks"
(separator of values = character ";", values without delimiter, in text
values character ";" replaced with ",", character " replaced with ‘)
Required values, (basic) filtering – rest of string parameter#4 :
LIST OF PARAMETERS in 1 STRING
Parameters for _ApiBF –> PROCESSING -> requests Betfairs Api-NG
SEPARATOR of individual parameters is character "|"
individual parameters are |IDENTIFIER=value|
Overview of IDENTIFIERS (for _ApiBF) – see Appendix B
Examples – how to include required values and filtering to parameter#4 :
_ApiBF.EXE –-ListEventTypes RS RA |id=1| DATA/ListEventTypes.JSON
- without filtering, only required value id=1
_ApiBF.EXE –-ListEventTypes RS RA CSV_|id=1|eventTypeIds=1,2| DATA/ListEventTypes.CSV
- output structure CSV, filtering => only sports soccer, tennis
_ApiBF.EXE –-ListEventTypes RS RA CSV_qn|id=1|eventTypeIds=1,2| DATA/ListEventType.CSW
- output structure CSV WITHOUT QUOTES, filtering => only sports soccer, tennis
( Using additional filtering with parameter#6 – see Appendix D )
Other Examples – batch files in subdirectory _BAT.ApiBF
ApiBF01_ListEventTypes1csv.bat
ApiBF02_ListCountries2json.bat
ApiBF03_ListVenues1csv.bat
ApiBF04_ListCompetitions2json.bat
ApiBF05_ListTimeRanges1csv.bat
ApiBF06_ListMarketTypes1csv.bat
ApiBF07_ListEvents1csv.bat
ApiBF08_ListMarketCatalogue2json.bat
+ Examples for additional Combined operations
ApiBF11_Competitions_Events1.bat
ApiBF12_Catalogue_Book1.bat
ApiBF13_CompEvents_MarkBook1.bat
35
Appendix D - Parameter #6 (additional parameters for Filtering)
Filtering in parameter#4 corresponds to requests of original Betfairs Api-NG
operations
In parameter#6 can be passed to program _ApiBF.EXE additional filters
- based on Analysis of texts – see chapter 3.7
- based on Names of Competitions, Events, Markets – see chapter 3.6 – Filtering with
simple wildcards "*"
STRUCTURE OF parameter#6 :
SEPARATOR of individual filters is group of characters "#|#|#"
Filter for "Analysis of texts" has to be first filter
Meaning of the filters – see chapters 3.6. and 3.7.
1) Used only Filtering of competitions based on Analysis of texts (see 3.7.)
f.e. Operation ListCompetitions – filter only Germany - Bundesliga 1 and Bundesliga 2:
_ApiBF.EXE –-ListCompetitions RS RA "CSV_|id=1|eventTypeIds=1|"
DATA/ListCompetitions.CSV "FOO|DEU,1.L,M|DEU,2.L,M" _AT
parameter#4 - output structure CSV, filtering => only sport soccer (eventTypeId=1)
parameter#6 – additional filtering - Analysis of competitions (names)
parameter#7 – data files for Analysis of texts are in subdirectory "_AT" of
program directory
2) Used only 1 or more filters for Names - wildcards "*" (see chapter 3.6.)
f.e. Operation ListEvents
a) only filter for eventname – has to contain 3 characters " v " => MATCH
"#|#|#eventName|* v *|#|#|#marketType|MATCH ODDS|"
_ApiBF.EXE –-ListEvents RS RA "CSV_qn|id=1|competitionIds=31|" DATA/ListEvents.CSV_
"#|#|#eventName|* v *|";
parameter#4 - output structure CSV without quotation marks, filtering => only
competition Id=31 (England Premier League)
parameter#6 – additional filtering based on Event name
b) filters for Event(match) and Market
_ApiBF.EXE –-Catalogue_Book RS RA "CSV_|id=1|competitionIds=31|from=0|to=8x24|"
DATA/Catalogue_Book.CSV_
"#|#|#eventName|*CHELSEA v *|* v CHELSEA*|#|#|#marketType|MATCH ODDS|"
parameter#4 - output structure CSV, filtering => only competition Id=31 (England
Premier League), events within 8 days from now
parameter#6 – additional filtering based on Event name (match of Chelsea), only
market "MATCH ODDS"
c) filters for Competition, Event(match) and Market
_ApiBF.EXE --Catalogue_Book RS RA
"CSV_|id=1|eventTypeIds=1|marketCountries=GB|competitionIds=31|from=0|to=14x24|maxResu
lts=999|" DATA/Catalogue_Book.CSV_
"#|#|#competitionName|*PREMIER LEAGUE*|#|#|#eventName|*CHELSEA v *|* v
CHELSEA*|#|#|#marketType|MATCH ODDS|OVER/UNDER*#|#|#prio>=4"
3) Used ALL Filters – Analysis of texts and 2 Filters (Events, Markets)
_ApiBF.EXE –-CompEvents_MarkBook RS RA "CSV_|id=1|
eventTypeIds=1|marketCountries=DE|from=0|to=8x24|" DATA/CompEvents_MarkBook.CSV_
"FOO|DEU,1.L,M|DEU,2.L,M|#|#|#eventName|* v *|#|#|#marketType|MATCH ODDS|DRAW NO
BET|" _AT
36
Appendix E - Operation Competitions_Events - structure of output CSV
Output only structure CSV (JSON not supported)
Structure CSV – 1 ROW with info about Competition, following rows for its
events/matches (..., again 1 ROW of next competition, ...)
If was used Filter _AT (f.e. "FOO|ENG,1.L,M|...|") => into rows are filled
parameters for competitions and for Team1, Team2 of Match (only for competitions
defined in library for Analysis of Texts - DLL_AnalTextStaSpo.dll)
See Demoversions :
a) Windows Form Applications (in Visual Basic, C#) –form "frmCompetitions_Events.???"
b) Console applications (in VB / C# / Python)
c) Batch files – see subdirectory _BAT.ApiBF / ApiBF11_Competitions_Events1.bat
_BAT.ApiBF / ApiBF11_Competitions_Events2.bat
EXAMPLE OF CALLING :
_ApiPS --Competitions_Events RS RA "CSV_|id=1|eventTypeIds=1|from=0|to=5x24|"
DATA/Competitions_Events.CSV_ "FOO|EUR,C*,M|#|#|#eventName|* v *|"
= Footbal (eventTypeIds=1), European Cups/Championships, only men (EUR,C*,M),
matches within 5 days (to=5x24) from NOW (6th Oct 2014 18:00)
STRUCTURE OF OUTPUT :
1 ROW for COMPETITION :
item 1 = sorting code "items 7–9" or " competition " (for not used Filter _AT)
item 2 = ID of competition (Betfair)
item 3 = Name of competition (Betfair)
item 4 = Country (2 chars) OR "International" (Betfair)
item 5 = Number of records (Betfair)
item 6 = Participants (_ApiBF) - "s"=states, "c"=clubs, "n"=not defined
item 7 = State (_ApiBF) – 3 chars (Aplpha 3)
item 8 = Competition (_ApiBF) – 3-5 chars (Type&Level "1.L", "2.L",...)
item 9 = Participants (_ApiBF) – 1-3 chars (men/women/underNN)
item10 = Priority (_ApiBF) – "1" to "5" (maximum "5")
N ROWs for EVENTS/MATCHES of COMPETITION :
item 1 = sorting code (" event ")
item 2 = ID of competition (Betfair)
item 3 = Date & Time (starting) of Event/Match
item 4 = ID of event (Betfair)
item 5 = Name of event (Betfair)
item 6 = Country (2 chars - venue) (Betfair)
item 7 = Time zone of Date & Time (Betfair)
item 8 = Number of records (Betfair)
item 9 = Identifier of Team1 (_ApiBF) – 5 chars
item10 = Identifier of Team2 (_ApiBF) – 5 chars
37
EXAMPLEs OF OUTPUT
"EUR,CH_ ,M ";" 4527196";"Euro 2016";"International";553;"s";"EUR";"CH_";"M";"5"
" event ";" 4527196";"2014-10-09T18:45:00.000Z";"27277540";"Slovakia
v Spain";"SK";"Europe/London";69;"_SVK_";"_ESP_"
" event ";" 4527196";"2014-10-09T18:45:00.000Z";"27277557";"Sweden
v Russia";"SE";"Europe/London";54;"_SWE_";"_RUS_"
" event ";" 4527196";"2014-10-09T18:45:00.000Z";"27277560";"Belarus
v Ukraine";"BY";"Europe/London";40;"_BLR_";"_UKR_"
" event ";" 4527196";"2014-10-09T18:45:00.000Z";"27277564";"Slovenia
v Switzerland";"SI";"Europe/London";54;"_SVN_";"_CHE_"
" event ";" 4527196";"2014-10-10T18:45:00.000Z";"27278127";"Italy
v Azerbaijan";"IT";"Europe/London";13;"_RUS_";"_AZE_"
" event ";" 4527196";"2014-10-10T18:45:00.000Z";"27278130";"Netherlands
v Kazakhstan";"NL";"Europe/London";13;"_NLD_";"_KAZ_"
" event ";" 4527196";"2014-10-10T18:45:00.000Z";"27278131";"Wales
v Bosnia";"GB";"Europe/London";13;"_WAL_";"_BIH_"
" event ";" 4527196";"2014-10-10T18:45:00.000Z";"27278152";"Bulgaria
v Croatia";"BG";"Europe/London";8;"_BGR_";"_HRV_"
" event ";" 4527196";"2014-10-10T18:45:00.000Z";"27278156";"Cyprus
v Israel";"CY";"Europe/London";8;"_CYP_";"_ISR_"
" event ";" 4527196";"2014-10-10T18:45:00.000Z";"27278159";"Latvia
v Iceland";"LV";"Europe/London";8;"_LVA_";"_ISL_"
" event ";" 4527196";"2014-10-10T18:45:00.000Z";"27278167";"Turkey
v Czech Republic";"TR";"Europe/London";8;"_TUR_";"_CZE_"
"ENG,1.L ,M ";" 31";"Barclays Premier League";"GBR";117;"c";"ENG";"1.L";"M";"5"
" event ";" 31";"2014-10-18T11:45:00.000Z";"27280209";"Man City
v Tottenham";"GB";"Europe/London";13;"MACIT";"TOTTE"
" event ";" 31";"2014-10-18T14:00:00.000Z";"27280195";"Newcastle
v Leicester";"GB";"Europe/London";13;"NEWCA";"LEICE"
" event ";" 31";"2014-10-18T14:00:00.000Z";"27280196";"Arsenal
v Hull";"GB";"Europe/London";13;"ARSEN";"HULL_"
" event ";" 31";"2014-10-18T14:00:00.000Z";"27280197";"Southampton
v Sunderland";"GB";"Europe/London";13;"SOUTH";"SUNDE"
" event ";" 31";"2014-10-18T14:00:00.000Z";"27280198";"Burnley
v West Ham";"GB";"Europe/London";13;"BURNL";"WESHA"
" event ";" 31";"2014-10-18T14:00:00.000Z";"27280199";"C Palace
v Chelsea";"GB";"Europe/London";13;"CRYPA";"CHELS"
" event ";" 31";"2014-10-18T14:00:00.000Z";"27280200";"Everton
v Aston Villa";"GB";"Europe/London";13;"EVERT";"ASTVI"
" event ";" 31";"2014-10-19T12:30:00.000Z";"27280202";"QPR
v Liverpool";"GB";"Europe/London";13;"QPRAN";"LIVER"
" event ";" 31";"2014-10-19T15:00:00.000Z";"27280205";"Stoke
v Swansea";"GB";"Europe/London";13;"STOKE";"SWANS"
38
Appendix F - Operation CompEvents_MarkBook - structure of output CSV
Output with the same structure produces also another combined operation
(--Catalogue_Book) – comparation in chapter
4.2. Additional (combined) operations of program _ApiBF.EXE
these combined operations summarize data from 4 original Betfairs Api-NG operations
(ListCompetitions, ListEvents, ListMarketCatalogue, ListMarketBook)
sumarized output is returned in 1 file with structure CSV (separator ";" ,
individual rows ("COMP" for competitions, "EVEN" for events, "MARK" for markets,
"RU??" for runners=participants + their prices+amounts (Back/Lay)
See Demoversions :
a) Windows Form Applications (in Visual Basic, C#)
– forms "frmCompEvents_MarkBook.???", "frmOTHERbookie.???"
b) Console applications (in VB / C# / Python)
c) Batch files – see subdirectory _BAT.ApiBF / ApiBF13_CompEvents_MarkBook1.bat
_BAT.ApiBF / ApiBF13_CompEvents_MarkBook2.bat
EXAMPLEs OF CALLING :
_ApiBF.EXE –-CompEvents_MarkBook RS RA "CSV_|id=1|competitionIds=31|from=0|to=8x24|"
DATA/CompEvents_MarkBook.CSV_
"FOO|*,*,*|#|#|#eventName|* v *|#|#|#marketType|MATCH ODDS|OVER/UNDER*|" _AT
= Football + England Premier League (competitionIds=31),
Matches (eventName|* v *|) within 8 days (to=8x24) from NOW
only Markets MATCH ODDS + OVER/UNDER 0.5/1.5/... (marketType|MATCH ODDS|OVER/UNDER*|)
Filter _AT only formally (FOO|*,*,*|) => fill parameters from "Analysis of texts" to
output rows
OR
_ApiBF.EXE --CompEvents_MarkBook RS RA
"CSV_|id=1|eventTypeIds=1|marketCountries=DE|from=0|to=8x24|"
DATA/CompEvents_MarkBook.CSV_
"FOO|DEU,1.L,M|DEU,2.L,M|#|#|#eventName|* v *|#|#|#marketType|MATCH ODDS|DRAW NO BET|"
"_AT"
= Football + Bundesliga 1+2 (FOO|DEU,1.L,M|DEU,2.L,M|) only Matches (eventName|* v *|)
within 5 days (to=8x24) from NOW
only Markets MATCH ODDS + DRAW NO BET (marketType|MATCH ODDS|DRAW NO BET|)
+ standard parameters of Betfair |eventTypeIds=1|marketCountries=DE| for reducing of
processed records (higher speed)
39
STRUCTURE OF OUTPUT :
1 ROW for COMPETITION :
A) "COMP" – record (info about COMPETITION)
item 1 = Competition-ID (Betfair)
item 2 = Competition-Name (Betfair)
item 3 = EventType-ID (Betfair)
item 4 = EventType-Name (Betfair)
item 5 = Participants (_ApiBF) - "s"=states, "c"=clubs, "n"=not defined
item 6 = State (_ApiBF) – 3 chars (Aplpha 3)
item 7 = Competition (_ApiBF) – 3-5 chars (Type&Level "1.L", "2.L",...)
item 8 = Participants (_ApiBF) – 1-3 chars (men/women/underNN)
item 9 = Priority (_ApiBF) – "1" to "5" (maximum "5")
1 ROW for EVENT/MATCH :
B) "EVEN" – record (info about EVENT/MATCH)
item 1 = Event-ID (Betfair)
item 2 = Event-CountryCode (Betfair) – 2 chars
item 3 = Event-Name (Betfair)
item 4 = Event-OpenDate f.e. "2014-10-09T18:45:00.000Z"
item 5 = Identifier of Team1 (_ApiBF) – 5 chars
item 6 = Identifier of Team2 (_ApiBF) – 5 chars
1 ROW for MARKET :
C) "MARK" – record (info about MARKET)
item 1 = Market-ID
item 2 = Market-Name
item 3 = Market-StartTime f.e. "2014-10-09T18:45:00.000Z"
1 ROW for BOOK :
D) "BOOK" – record (info about MarketBOOK)
item 1 = Market-ID
item 2 = Market-Name
item 3 = Market-Status "OPEN" / ...
item 4 = MarketBook.InPlay(bool),
item 5 = MarketBook.Complete(bool),
item 6 = MarketBook.NumberOfRunners(int),
item 7 = MarketBook.NumberOfWinners(int),
item 8 = MarketBook.NumberOfActiveRunners(int),
item 9 = MarketBook.IsMarketDataDelayed(bool),
item 10 = MarketBook.BetDelay(int),
item 11 = MarketBook.BspReconciled(bool),
item 12 = MarketBook.LastMatchTime(DateTime),
item 13 = MarketBook.TotalMatched(real),
item 14 = MarketBook.TotalAvailable(real),
item 15 = MarketBook.CrossMatching(BOOL),
item 16 = MarketBookRunners.Voidable(bool),
item 17 = MarketBook.Version(long)
N ROWs for RUNNERS :
E) "RUnn " – record (info about RUNNER #nn
item 1 = Runner-SelectionID (string)
item 2 = Runner-Name (string)
item 3 = Runner-Handicap (real)
item 4 = Runner-Status (string)
F) "RUnnBA" – record (info about RUNNER #nn – AVAILABLE to BACK)
item 1 = Price1/Size1; Price2/Size2; Price3/Size3 (prices DESCending)
G) "RUnnLA" – record (info about RUNNER #nn – AVAILABLE to LAY)
string – Price1/Size1; Price2/Size2; Price3/Size3 (prices ASCending)
40
EXAMPLE OF OUTPUT (matches of Euro 2016 – Qualification 9th Oct 2014)
"COMP";"4527196";"Euro 2016";"";"";"s";"EUR";"CH_";"M";"5"
"EVEN";"27277540";"SK";"Slovakia v Spain";"2014-10-09T18:45:00.000Z";"_SVK_";"_ESP_"
"MARK";"1.115731507";"Match Odds";"2014-10-09T18:45:00.000Z""
"BOOK";"1.115731507";"Match Odds";"OPEN";"N";"Y";3;1;3;"N";0;"N";"2014-10-
06T19:16:21.401Z";10617.13;324305.97;"Y";"N";831632958
"RU00 ";15288;"Slovakia";0.0;"ACTIVE"
"RU00BA";"10.5/8.86;10.0/135.01;9.6/14.79"
"RU00LA";"11.0/404.76;11.5/118.78;13.0/6.36"
"RU01 ";22;"Spain";0.0;"ACTIVE"
"RU01BA";"1.41/1492.29;1.4/13177.12;1.39/13470.0"
"RU01LA";"1.43/753.64;1.44/25.73;1.45/2.0"
"RU02 ";58805;"The Draw";0.0;"ACTIVE"
"RU02BA";"4.9/5.5;4.8/93.0;4.7/126.98"
"RU02LA";"5.2/223.2;5.5/6.36;950.0/2.79"
"MARK";"1.115731484";"DRAW NO BET";"2014-10-09T18:45:00.000Z""
"BOOK";"1.115731484";"DRAW NO
BET";"OPEN";"N";"Y";2;1;2;"N";0;"N";"";0.0;1472.53;"N";"N";835898182
"RU00 ";15288;"Slovakia";0.0;"ACTIVE"
"RU00BA";"6.8/17.04;6.6/59.0"
"RU00LA";"11.5/65.0"
"RU01 ";22;"Spain";0.0;"ACTIVE"
"RU01BA";"1.11/1226.48"
"RU01LA";"1.16/105.0"
.
7. VERSIONs
6th Nov 2014 – Version 1.2.11
15th Nov 2014 – Version 1.2.12
Format CSV_qn – output CSV-files without quotation marks
15th Feb 2015 – Version 1.2.14