Skip to content

Commit 86e426a

Browse files
author
stottp
committed
Updated endpoints and added cSharp login sample
1 parent 92225ac commit 86e426a

44 files changed

Lines changed: 826 additions & 23 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ This github respository contains sample code in various languages to help custom
22

33
Each sample demonstrates a basic use case of placing a bet on the next GB Horse Racing market.
44

5-
A comprehensive description of the samples can be found at: TODO
5+
A comprehensive description of the samples can be found <a href="http://my.developer.betfair.com/">
6+
here.</a>
7+
8+
There is also a limited sample of login examples within the loginCode subdirectory.
69

710
The sample code is not intended to be used as-is in a production environment and carries no assurances or guarantees.

cSharp/Api-ng-sample-code/Api-ng-sample-code/JsonRpcClient.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public class JsonRpcClient : HttpWebClientProtocol, IClient
3838

3939
public JsonRpcClient(string endPoint, string appKey, string sessionToken)
4040
{
41-
this.EndPoint = endPoint + "/json-rpc";
41+
this.EndPoint = endPoint + "/json-rpc/v1";
4242
CustomHeaders = new NameValueCollection();
4343
if (appKey != null)
4444
{

cSharp/Api-ng-sample-code/Api-ng-sample-code/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ namespace Api_ng_sample_code
99
{
1010
class Program
1111
{
12-
private static string Url = "https://beta-api.betfair.com";
12+
private static string Url = "https://api.betfair.com/exchange/betting";
1313

1414
static void Main(string[] args)
1515
{

curl/jsonrpc_curl.bash

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
APP_KEY=$1
99
SESSION_TOKEN=$2
1010

11-
HOST=https://beta-api.betfair.com
11+
HOST=https://api.betfair.com/exchange/betting
1212
PORT=443
1313

1414
# List all event types, providing app key and session token
@@ -31,7 +31,7 @@ function list_available_horse_races() {
3131
# get date now and format it
3232
local DATE=`date +"%Y-%m-%dT%TZ"`
3333

34-
OUT=`curl -s -X POST --header "Accept: application/json" --header "Content-Type: application/json" --header "X-Application: $APP_KEY" --header "X-Authentication: $SESSION_TOKEN" --data "[{ \"jsonrpc\": \"2.0\", \"method\": \"SportsAPING/v1.0/listMarketCatalogue\", \"params\": {\"filter\":{\"eventTypeIds\":[$HORSE_RACING_EVENT_TYPE_ID], \"marketCountries\" :[\"GB\"],\"marketTypeCodes\" :[\"WIN\"],\"marketStartTime\":{\"from\":\"$DATE\"}},\"sort\":\"FIRST_TO_START\",\"maxResults\":\"$MAX_RESULTS\",\"marketProjection\":[\"RUNNER_DESCRIPTION\"]}, \"id\": 1}]" $HOST:$PORT/json-rpc`
34+
OUT=`curl -s -X POST --header "Accept: application/json" --header "Content-Type: application/json" --header "X-Application: $APP_KEY" --header "X-Authentication: $SESSION_TOKEN" --data "[{ \"jsonrpc\": \"2.0\", \"method\": \"SportsAPING/v1.0/listMarketCatalogue\", \"params\": {\"filter\":{\"eventTypeIds\":[$HORSE_RACING_EVENT_TYPE_ID], \"marketCountries\" :[\"GB\"],\"marketTypeCodes\" :[\"WIN\"],\"marketStartTime\":{\"from\":\"$DATE\"}},\"sort\":\"FIRST_TO_START\",\"maxResults\":\"$MAX_RESULTS\",\"marketProjection\":[\"RUNNER_DESCRIPTION\"]}, \"id\": 1}]" $HOST:$PORT/json-rpc/v1`
3535
echo $OUT | json_reformat
3636
}
3737

@@ -43,7 +43,7 @@ function list_runners() {
4343
# extract market id from prev. response
4444
MARKET_ID=`echo $OUT | cut -f10 -d "\""`
4545

46-
OUT=`curl -s -X POST --header "Accept: application/json" --header "Content-Type: application/json" --header "X-Application: $APP_KEY" --header "X-Authentication: $SESSION_TOKEN" --data "[{ \"jsonrpc\": \"2.0\", \"method\": \"SportsAPING/v1.0/listMarketBook\", \"params\": {\"marketIds\":[\"$MARKET_ID\"],\"priceProjection\":{\"priceData\":[\"EX_BEST_OFFERS\"],\"exBestOfferOverRides\":{\"bestPricesDepth\":2,\"rollupModel\":\"STAKE\",\"rollupLimit\":20},\"virtualise\":false,\"rolloverStakes\":false},\"orderProjection\":\"ALL\",\"matchProjection\":\"ROLLED_UP_BY_PRICE\"}, \"id\": 1}]" $HOST:$PORT/json-rpc`
46+
OUT=`curl -s -X POST --header "Accept: application/json" --header "Content-Type: application/json" --header "X-Application: $APP_KEY" --header "X-Authentication: $SESSION_TOKEN" --data "[{ \"jsonrpc\": \"2.0\", \"method\": \"SportsAPING/v1.0/listMarketBook\", \"params\": {\"marketIds\":[\"$MARKET_ID\"],\"priceProjection\":{\"priceData\":[\"EX_BEST_OFFERS\"],\"exBestOfferOverRides\":{\"bestPricesDepth\":2,\"rollupModel\":\"STAKE\",\"rollupLimit\":20},\"virtualise\":false,\"rolloverStakes\":false},\"orderProjection\":\"ALL\",\"matchProjection\":\"ROLLED_UP_BY_PRICE\"}, \"id\": 1}]" $HOST:$PORT/json-rpc/v1`
4747
echo $OUT | json_reformat
4848
}
4949

@@ -62,7 +62,7 @@ function place_bet() {
6262

6363
echo "Placing bet on : Selection Id: $SELECTION_ID, Side: $SIDE, Price: $PRICE, Size: $SIZE"
6464

65-
OUT=`curl -s -X POST --header "Accept: application/json" --header "Content-Type: application/json" --header "X-Application: $APP_KEY" --header "X-Authentication: $SESSION_TOKEN" --data "[{ \"jsonrpc\": \"2.0\", \"method\": \"SportsAPING/v1.0/placeOrders\", \"params\": {\"marketId\":\"$MARKET_ID\",\"instructions\":[{\"selectionId\":\"$SELECTION_ID\",\"handicap\":\"0\",\"side\":\"$SIDE\",\"orderType\":\"LIMIT\",\"limitOrder\":{\"size\":\"$SIZE\",\"price\":\"$PRICE\",\"persistenceType\":\"LAPSE\"}}],\"customerRef\":\"$REFERENCE\"}, \"id\": 1}]" $HOST:$PORT/json-rpc`
65+
OUT=`curl -s -X POST --header "Accept: application/json" --header "Content-Type: application/json" --header "X-Application: $APP_KEY" --header "X-Authentication: $SESSION_TOKEN" --data "[{ \"jsonrpc\": \"2.0\", \"method\": \"SportsAPING/v1.0/placeOrders\", \"params\": {\"marketId\":\"$MARKET_ID\",\"instructions\":[{\"selectionId\":\"$SELECTION_ID\",\"handicap\":\"0\",\"side\":\"$SIDE\",\"orderType\":\"LIMIT\",\"limitOrder\":{\"size\":\"$SIZE\",\"price\":\"$PRICE\",\"persistenceType\":\"LAPSE\"}}],\"customerRef\":\"$REFERENCE\"}, \"id\": 1}]" $HOST:$PORT/json-rpc/v1`
6666
echo $OUT | json_reformat
6767
# operation should return error as bet size is too small
6868
handleError $OUT

curl/rescript_curl.bash

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
APP_KEY=$1
99
SESSION_TOKEN=$2
1010

11-
HOST=https://beta-api.betfair.com
11+
HOST=https://api.betfair.com/exchange/betting
1212
PORT=443
1313

1414

java/ng/src/main/java/com/betfair/aping/ApiNGDemo.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,9 @@ public static void main(String[] args) {
4747
sessionToken = args[1];
4848
jsonOrRescript = args[2];
4949

50-
if(jsonOrRescript.equals("json-rpc")){
50+
if(jsonOrRescript.equalsIgnoreCase("json-rpc")){
5151
jsonRpcRequest=true;
52-
} else if(jsonOrRescript.equals("rescript")){
52+
} else if(jsonOrRescript.equalsIgnoreCase("rescript")){
5353
jsonRpcRequest=false;
5454
}
5555

java/ng/src/main/java/com/betfair/aping/ApiNGJRescriptDemo.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,6 @@ public void start(String appKey, String ssoid) {
148148
} else if (placeBetResult.getStatus() == ExecutionReportStatus.FAILURE) {
149149
System.out.println("Your bet has NOT been placed :*( ");
150150
System.out.println("The error is: " + placeBetResult.getErrorCode() + ": " + placeBetResult.getErrorCode().getMessage());
151-
System.out.println("Sorry, more luck next time\n\n");
152151
}
153152
} else {
154153
System.out.println("Sorry, no runners found\n\n");

java/ng/src/main/java/com/betfair/aping/ApiNGJsonRpcDemo.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,6 @@ public void start(String appKey, String ssoid) {
148148
} else if (placeBetResult.getStatus() == ExecutionReportStatus.FAILURE) {
149149
System.out.println("Your bet has NOT been placed :*( ");
150150
System.out.println("The error is: " + placeBetResult.getErrorCode() + ": " + placeBetResult.getErrorCode().getMessage());
151-
System.out.println("Sorry, more luck next time\n\n");
152151
}
153152
} else {
154153
System.out.println("Sorry, no runners found\n\n");

java/ng/src/main/resources/apingdemo.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ APPLICATION_JSON=application/json
44
TIMEOUT=10000
55

66
#API NG URL
7-
APING_URL=https://beta-api.betfair.com/
8-
JSON_RPC_SUFFIX=json-rpc/
7+
APING_URL=https://api.betfair.com/exchange/betting/
8+
JSON_RPC_SUFFIX=json-rpc/v1
99
RESCRIPT_SUFFIX=rest/v1.0/
1010

1111
#Bet size and price

javascript/JsonRpcApiNgClient.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ var DEFAULT_ENCODING = 'utf-8';
1717
var DEFAULT_JSON_FORMAT = '\t';
1818

1919
var options = {
20-
hostname: 'beta-api.betfair.com',
20+
hostname: 'api.betfair.com/exchange/betting',
2121
port: 443,
22-
path: '/json-rpc',
22+
path: '/json-rpc/v1',
2323
method: 'POST',
2424
headers: {
2525
'X-Application' : appkey,

0 commit comments

Comments
 (0)