How To Create Betdaq API Bot – Intro
Betdaq API is set of web services (or functions) which are accessible from anywhere in the internet. It's possible to utilise the API in a desktop software as well as in a web site.
To get started you need to know some programming language. In this article we will be talking about C# which is part of .NET Framework. So, to create your first Betdaq software you will need:
1. Computer with Windows OS and .NET Framework 3.5 installed.
2. Microsoft Visual Studio 2008, particularly Visual C# which is part of the Visual Studio. You can download Express version for free.
3. Subscribe to the Betdaq API here. It's free, at least if you want to build applications for personal use.
4. Download the Betdaq API documentation. This will help if you want to make your own Betdaq software.
Now you should be ready to start.
Open Visual Studio and create a new project. Choose "Windows Forms Application" project type. VS will create a template for your Betdaq application with one form called "Form1".
Select "Project->Add Service Reference" from the VS menu. The window will show up where you need to enter the address of the Betdaq web service definition file (WSDL file). For Betdaq API the address must be: http://api.betdaq.com/v2.0/API.wsdl. Click "Go", VS will analyse the file from URL and retrieve all required information about API methods and structures. In the "Namespace" box enter "BetdaqService". This will be the name for the API in your project. Click "OK".
Now go back to your Form1 and add one button "Login" and two text boxes "Username" and "Password". We will use these controls to login to Betdaq.
Create the Login button click handler and put the following code:
private void btnLogin_Click(object sender, EventArgs e)
{
SecureServiceClient client = new SecureServiceClient();
client.Open();ExternalApiHeader header = new ExternalApiHeader();
header.username = textUsername.Text;
header.password = textPassword.Text;
header.version = 2;
header.languageCode = "en";GetAccountBalancesRequest request = new GetAccountBalancesRequest();
GetAccountBalancesResponse response = client.GetAccountBalances(header, request);
MessageBox.Show(response.Balance.ToString() + response.Currency);
}
Also add "using" statement in the Form.cs file:
using WindowsFormsApplication2.BetdaqService;
This will allow your code to access the code from BetdaqService file.
Our first Betdaq bot is very simple. The only thing it does is displays the message with Betdaq account balance. Lets look closer at the code. First two lines create and open the client object which we use to call functions from "secure" level. This level includes all account related functions, for example placing bets, retrieving account information, current bets, etc. There is also "read only" level, but we don't use it in our sample.
Next step we initialise ExternalApiHeader structure. It's required for all API calls. It can be set up once in the bot and used without changes. We have to put Betdaq username and password, API version (at the moment 2.0 is the latest) and language code ("en" for English).
Also the GetAccountBalances call requires GetAccountBalancesRequest structure which we leave unchanged. Basically, all Betdaq API functions have associated "Request" and "Response" structures which serve as input and return data.
The last line displays the account balance. If any error has occurred, for example wrong login details, "response.ResturnStatus" will contain error code and description of what happened.
Of course, professional Betdaq software will be much more complicated. The purpose of this article is just to point at first steps you need to know about Betdaq API and developing bots for Betdaq. In the next articles we will show other examples of Betdaq API use.
You may download the code for this article.
How to use Betdaq API
Anyone can get advantage using official Betdaq API. You just need to have Betdaq account. If you have programming knowledge you can make your own software. If not, there is a lot of ready to use software utilising Betdaq API already made by software vendors. More information to come.


