### Navigation Data API Endpoint Examples Source: https://betfair-developer-docs.atlassian.net/wiki/spaces/1smk3cen4v3lu3yomq5qye0ni/pages/2687802 Examples of GET requests to retrieve the navigation menu JSON for different regions. Ensure you include the required X-Application and X-Authentication headers. ```HTTP GET https://api.betfair.com/exchange/betting/rest/v1/en/navigation/menu.json ``` ```HTTP GET https://api.betfair.it/exchange/betting/rest/v1/it/navigation/menu.json ``` ```HTTP GET https://api.betfair.es/exchange/betting/rest/v1/es/navigation/menu.json ``` -------------------------------- ### Place Orders Response Example Source: https://betfair-developer-docs.atlassian.net/wiki/spaces/1smk3cen4v3lu3yomq5qye0ni/pages/2687154/New%2BAPI%2BRelease%2B-%2B8th%2BAugust%2B2016 This is an example response for placing orders, showing the success status and details of the placed bet. ```json [{"jsonrpc":"2.0","result":{"status":"SUCCESS","marketId":"1.126124417","instructionReports":[{"status":"SUCCESS","instruction":{"selectionId":11166583,"handicap":0.0,"limitOrder":{"price":2.0,"betTargetSize":2.0,"persistenceType":"LAPSE","betTargetType":"BACKERS_PROFIT"},"orderType":"LIMIT","side":"BACK"},"betId":"72671225671","placedDate":"2016-08-12T13:00:23.000Z","averagePriceMatched":6.3999999999999995,"sizeMatched":0.37}]}},{"jsonrpc":"2.0","result":{"status":"SUCCESS","marketId":"1.126122473","instructionReports":[{"status":"SUCCESS","instruction":{"selectionId":11576316,"handicap":0.0,"limitOrder":{"price":10.0,"betTargetSize":10.0,"persistenceType":"LAPSE","betTargetType":"PAYOUT"},"orderType":"LIMIT","side":"LAY"},"betId":"72671531256","placedDate":"2016-08-12T13:05:45.000Z","averagePriceMatched":4.2,"sizeMatched":2.38}]}}] ``` -------------------------------- ### Example Usage: Client Initialization and API Call Source: https://betfair-developer-docs.atlassian.net/wiki/spaces/1smk3cen4v3lu3yomq5qye0ni/pages/2687074/C This example demonstrates how to initialize either a RescriptClient or a JsonRpcClient based on input arguments and then use it to call the listEventTypes method. ```csharp IClient client = null; string clientType = null; if (args.Length == 3) { clientType = args[2]; } // if rescript has been passed as the third argument use it otherwise default to json client if (!string.IsNullOrEmpty(clientType) && clientType.Equals("rescript")) { Console.WriteLine("Using RescriptClient"); client = new RescriptClient(Url, appkey, sessionToken); } else { Console.WriteLine("Using JsonRpcClient"); client = new JsonRpcClient(Url, appkey, sessionToken); } Console.WriteLine("\nBeginning sample run!\n"); var marketFilter = new MarketFilter(); marketFilter.TextQuery = "Horse Racing"; var eventTypes = client.listEventTypes(marketFilter); ``` -------------------------------- ### List Market Catalogue Response Example Source: https://betfair-developer-docs.atlassian.net/wiki/spaces/1smk3cen4v3lu3yomq5qye0ni/pages/2687786/Getting%2BStarted This snippet shows a sample response from the listMarketCatalogue API call, detailing market information such as market ID, name, start time, and runners. ```json { "marketId": "1.113197511", "marketName": "Over/Under 3.5 Goals", "marketStartTime": "2014-03-13T11:00:00.000Z", "totalMatched": 3934.41, "runners": [ { "selectionId": 1222344, "runnerName": "Under 3.5 Goals", "handicap": 0, "sortPriority": 1, "metadata": { "runnerId": "63123547" } }, { "selectionId": 1222345, "runnerName": "Over 3.5 Goals", "handicap": 0, "sortPriority": 2, "metadata": { "runnerId": "63123548" } } ], "eventType": { "id": "1", "name": "Soccer" }, "competition": { "id": "2356065", "name": "Pirveli Liga" }, "event": { "id": "27165685", "name": "FC Samtredia v FC Betlemi Keda", "countryCode": "GE", "timezone": "GMT", "openDate": "2014-03-13T11:00:00.000Z" } } ``` ```json { "marketId": "1.113197512", "marketName": "Asian Handicap", "marketStartTime": "2014-03-13T11:00:00.000Z", "totalMatched": 1599.38, "runners": [ { "selectionId": 6830593, "runnerName": "FC Samtredia", "handicap": -4, "sortPriority": 1 }, { "selectionId": 6843866, "runnerName": "FC Betlemi Keda", "handicap": 4, "sortPriority": 2 }, { "selectionId": 6830593, "runnerName": "FC Samtredia", "handicap": -3.75, "sortPriority": 3 }, { "selectionId": 6843866, "runnerName": "FC Betlemi Keda", "handicap": 3.75, "sortPriority": 4 }, { "selectionId": 6830593, "runnerName": "FC Samtredia", "handicap": -3.5, "sortPriority": 5 }, { "selectionId": 6843866, "runnerName": "FC Betlemi Keda", "handicap": 3.5, "sortPriority": 6 }, { "selectionId": 6830593, "runnerName": "FC Samtredia", "handicap": -3.25, "sortPriority": 7 }, { "selectionId": 6843866, "runnerName": "FC Betlemi Keda", "handicap": 3.25, "sortPriority": 8 }, { "selectionId": 6830593, "runnerName": "FC Samtredia", "handicap": -3, "sortPriority": 9 }, { "selectionId": 6843866, "runnerName": "FC Betlemi Keda", "handicap": 3, "sortPriority": 10 }, { "selectionId": 6830593, "runnerName": "FC Samtredia", "handicap": -2.75, "sortPriority": 11 }, { "selectionId": 6843866, "runnerName": "FC Betlemi Keda", "handicap": 2.75, "sortPriority": 12 }, { "selectionId": 6830593, "runnerName": "FC Samtredia", "handicap": -2.5, "sortPriority": 13 } ], "eventType": { "id": "1", "name": "Soccer" }, "competition": { "id": "2356065", "name": "Pirveli Liga" }, "event": { "id": "27165685", "name": "FC Samtredia v FC Betlemi Keda", "countryCode": "GE", "timezone": "GMT", "openDate": "2014-03-13T11:00:00.000Z" } } ``` -------------------------------- ### List Events Example Source: https://betfair-developer-docs.atlassian.net/wiki/spaces/1smk3cen4v3lu3yomq5qye0ni/pages/2687786/Getting%2BStarted This example demonstrates how to list events using the Betfair API. It shows the structure of the event data returned. ```json [ { "events": [ { "id": "27166336", "name": "Becamex Binh Duong U19 v Khanh Hoa U19", "countryCode": "VN", "timezone": "GMT", "openDate": "2014-03-13T11:00:00.000Z" }, { "id": "27163800", "name": "Lokomotiv Sofia v Chernomorets Burgas", "countryCode": "BG", "timezone": "GMT", "openDate": "2014-03-13T12:00:00.000Z" }, { "id": "27162481", "name": "Ljungskile v Torslanda", "countryCode": "SE", "timezone": "GMT", "openDate": "2014-03-13T18:00:00.000Z" }, { "id": "27166338", "name": "H Ironi Petah Tikva (W) v Maccabi Beer Sheva (W)", "countryCode": "IL", "timezone": "GMT", "openDate": "2014-03-13T18:15:00.000Z" }, { "id": "27163801", "name": "Concord Rangers v Havant and W", "countryCode": "GB", "timezone": "GMT", "openDate": "2014-03-13T19:45:00.000Z" }, { "id": "27166340", "name": "Maccabi Ironi Bat Yam v Hapoel Mahane Yehuda", "countryCode": "IL", "timezone": "GMT", "openDate": "2014-03-13T17:00:00.000Z" }, { "id": "27162418", "name": "Courts Young Lions v Woodlands Wellington", "countryCode": "SG", "timezone": "GMT", "openDate": "2014-03-13T11:30:00.000Z" }, { "id": "27162417", "name": "Balestier Khalsa v Tanjong Pagar Utd", "countryCode": "SG", "timezone": "GMT", "openDate": "2014-03-13T11:30:00.000Z" } ], "id": 1 } ] ``` -------------------------------- ### Place Orders - Fill or Kill Example Source: https://betfair-developer-docs.atlassian.net/wiki/spaces/1smk3cen4v3lu3yomq5qye0ni/pages/2687496/placeOrders Demonstrates placing a FILL_OR_KILL order that lapses if not fully filled. This example shows a basic LIMIT order with specific persistence and time-in-force settings. ```APIDOC ## POST placeOrders ### Description Places one or more orders on a market. This operation supports various order types including LIMIT and MARKET orders, with options for persistence, time-in-force, and specific matching conditions. ### Method POST ### Endpoint /SportsAPING/v1.0/placeOrders ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **marketId** (string) - Required - The unique identifier of the market on which to place orders. - **instructions** (array) - Required - A list of order instructions. - **selectionId** (string) - Required - The identifier of the selection within the market. - **handicap** (string) - Required - The handicap for the selection (usually 0 for most markets). - **side** (string) - Required - The side of the bet ('BACK' or 'LAY'). - **orderType** (string) - Required - The type of order ('LIMIT' or 'MARKET'). - **limitOrder** (object) - Required if orderType is 'LIMIT'. - **size** (string) - Required - The total amount of the bet. - **price** (string) - Required - The price at which to place the limit order. - **persistenceType** (string) - Optional - How long the order should remain active ('LAPSE' or 'PERSIST'). - **timeInForce** (string) - Optional - Specifies the time in force for the order ('FILL_OR_KILL', 'EXECUTE_CALCULATED_PRICE', 'IMMEDIATE_OR_CANCEL'). - **minFillSize** (string) - Optional - The minimum amount that must be filled for the order to be considered valid. - **marketVersion** (object) - Optional - Specifies the market version to ensure order is placed against a specific market state. - **version** (string) - Required - The version number of the market. ### Request Example ```json [ { "jsonrpc": "2.0", "method": "SportsAPING/v1.0/placeOrders", "params": { "marketId": "1.126124422", "instructions": [ { "selectionId": "10590221", "handicap": "0", "side": "BACK", "orderType": "LIMIT", "limitOrder": { "size": "5", "price": "21", "persistenceType": "LAPSE", "timeInForce": "FILL_OR_KILL", "minFillSize": "5" } } ] }, "id": 1 } ] ``` ### Response #### Success Response (200) - **status** (string) - The status of the overall operation. - **marketId** (string) - The identifier of the market. - **instructionReports** (array) - A list of reports for each instruction submitted. - **status** (string) - The status of the individual instruction. - **instruction** (object) - The details of the instruction that was processed. - **betId** (string) - The unique identifier for the placed bet. - **placedDate** (string) - The date and time the bet was placed. - **averagePriceMatched** (number) - The average price at which the bet was matched. - **sizeMatched** (number) - The total amount matched for the bet. #### Response Example ```json [ { "jsonrpc": "2.0", "result": { "status": "SUCCESS", "marketId": "1.126124422", "instructionReports": [ { "status": "SUCCESS", "instruction": { "selectionId": 10590221, "handicap": 0.0, "limitOrder": { "size": 5.0, "price": 21.0, "minFillSize": 5.0, "timeInForce": "FILL_OR_KILL" }, "orderType": "LIMIT", "side": "BACK" }, "betId": "72666364933", "placedDate": "2016-08-12T10:45:15.000Z", "averagePriceMatched": 0.0, "sizeMatched": 0.0 } ] }, "id": 1 } ] ``` ``` -------------------------------- ### List Market Catalogue Response Example Source: https://betfair-developer-docs.atlassian.net/wiki/spaces/1smk3cen4v3lu3yomq5qye0ni/pages/2687786/Getting%2BStarted This JSON snippet shows a sample response from the listMarketCatalogue API call, detailing market information such as market ID, name, start time, and runners. ```json { "id": "27165685", "name": "FC Samtredia v FC Betlemi Keda", "countryCode": "GE", "timezone": "GMT", "openDate": "2014-03-13T11:00:00.000Z" } }, { "marketId": "1.113197506", "marketName": "Over/Under 2.5 Goals", "marketStartTime": "2014-03-13T11:00:00.000Z", "totalMatched": 4149.36, "runners": [ { "selectionId": 47972, "runnerName": "Under 2.5 Goals", "handicap": 0, "sortPriority": 1, "metadata": { "runnerId": "63123522" } }, { "selectionId": 47973, "runnerName": "Over 2.5 Goals", "handicap": 0, "sortPriority": 2, "metadata": { "runnerId": "63123523" } } ], "eventType": { "id": "1", "name": "Soccer" }, "competition": { "id": "2356065", "name": "Pirveli Liga" }, "event": { "id": "27165685", "name": "FC Samtredia v FC Betlemi Keda", "countryCode": "GE", "timezone": "GMT", "openDate": "2014-03-13T11:00:00.000Z" } }, { "marketId": "1.113197504", "marketName": "Over/Under 5.5 Goals", "marketStartTime": "2014-03-13T11:00:00.000Z", "totalMatched": 2216.24, "runners": [ { "selectionId": 1485567, "runnerName": "Under 5.5 Goals", "handicap": 0, "sortPriority": 1, "metadata": { "runnerId": "63123503" } }, { "selectionId": 1485568, "runnerName": "Over 5.5 Goals", "handicap": 0, "sortPriority": 2, "metadata": { "runnerId": "63123504" } } ], "eventType": { "id": "1", "name": "Soccer" }, "competition": { "id": "2356065", "name": "Pirveli Liga" }, "event": { "id": "27165685", "name": "FC Samtredia v FC Betlemi Keda", "countryCode": "GE", "timezone": "GMT", "openDate": "2014-03-13T11:00:00.000Z" } }, { "marketId": "1.113197509", "marketName": "Half Time/Full Time", "marketStartTime": "2014-03-13T11:00:00.000Z", "totalMatched": 97.3, "runners": [ { "selectionId": 6830596, "runnerName": "FC Samtredia/FC Samtredia", "handicap": 0, "sortPriority": 1, "metadata": { "runnerId": "63123536" } }, { "selectionId": 6830599, "runnerName": "FC Samtredia/Draw", "handicap": 0, "sortPriority": 2, "metadata": { "runnerId": "63123537" } }, { "selectionId": 8380726, "runnerName": "FC Samtredia/FC Betlemi Ked", "handicap": 0, "sortPriority": 3, "metadata": { "runnerId": "63123538" } }, { "selectionId": 6830595, "runnerName": "Draw/FC Samtredia", "handicap": 0, "sortPriority": 4, "metadata": { "runnerId": "63123539" } }, { ``` -------------------------------- ### Betfair Certificate Login Request Example Source: https://betfair-developer-docs.atlassian.net/wiki/spaces/1smk3cen4v3lu3yomq5qye0ni/pages/2687915/Non-Interactive%2Bbot%2Blogin An example of an HTTP POST request to the Betfair certificate login endpoint. Includes the required X-Application header and URL-encoded username/password parameters. ```http POST https://identitysso-cert.betfair.com/api/certlogin Content-Type: application/x-www-form-urlencoded X-Application: YOUR_APPLICATION_KEY username=YOUR_USERNAME&password=YOUR_PASSWORD ``` -------------------------------- ### List Competitions Response Example Source: https://betfair-developer-docs.atlassian.net/wiki/spaces/1smk3cen4v3lu3yomq5qye0ni/pages/2687786/Getting%2BStarted Example response structure for listing competitions, showing market count and competition details. ```json { "jsonrpc": "2.0", "result": [ { "marketCount": 16, "competition": { "id": "833222", "name": "Turkish Division 2" } }, { "marketCount": 127, "competition": { "id": "5", "name": "A-League 2012/13" } }, { "marketCount": 212, "competition": { "id": "7", "name": "Austrian Bundesliga" } }, { "marketCount": 243, "competition": { "id": "11", "name": "Dutch Jupiler League" } }, { "marketCount": 206, "competition": { "id": "26207", "name": "Greek Cup" } }, { "marketCount": 117, "competition": { "id": "2129602", "name": "Professional Development League" } }, { "marketCount": 68, "competition": { "id": "803237", "name": "Argentinian Primera B" } }, { "marketCount": 1, "competition": { "id": "1842928", "name": "OTB Bank Liga" } } ], "id": 1 } ``` -------------------------------- ### List Competitions (JSON-RPC) Source: https://betfair-developer-docs.atlassian.net/wiki/spaces/1smk3cen4v3lu3yomq5qye0ni/pages/2687786/Getting%2BStarted This example shows how to use the JSON-RPC endpoint to call the listCompetitions operation. It includes an example of the JSON-RPC request data, specifying a filter for event type IDs. ```APIDOC ## POST /exchange/betting/json-rpc/v1 ### Description This endpoint allows you to interact with the Betfair API using JSON-RPC. You can call various operations by specifying the method and parameters in the JSON-RPC request payload. ### Method POST ### Endpoint https://api.betfair.com/exchange/betting/json-rpc/v1 ### Parameters #### Request Body - **jsonrpc** (string) - Required - The JSON-RPC protocol version, typically "2.0". - **method** (string) - Required - The API method to call, e.g., "SportsAPING/v1.0/listCompetitions". - **params** (object) - Required - The parameters for the API method. For listCompetitions, this can include a filter. - **filter** (object) - Optional - Filter criteria for the request. - **eventTypeIds** (array) - Optional - An array of event type IDs to filter by. - **id** (integer) - Required - A unique identifier for the request. ### Request Example ```json { "params": { "filter": { "eventTypeIds": [1] } }, "jsonrpc": "2.0", "method": "SportsAPING/v1.0/listCompetitions", "id": 1 } ``` ### Response #### Success Response (200) - **result** (object) - The result of the JSON-RPC call, containing the requested data. - **id** (integer) - The identifier of the request. #### Response Example ```json { "jsonrpc": "2.0", "result": { "competition": [ { "id": "1000001", "name": "Premier League", "ranking": 1 }, { "id": "1000002", "name": "Championship", "ranking": 2 } ] }, "id": 1 } ``` ``` -------------------------------- ### List Market Catalogue Response Example Source: https://betfair-developer-docs.atlassian.net/wiki/spaces/1smk3cen4v3lu3yomq5qye0ni/pages/2687786/Getting%2BStarted This snippet shows a sample response from the listMarketCatalogue API call, detailing market information and runners. ```json { "selectionId": 3710152, "runnerName": "Draw/Draw", "handicap": 0, "sortPriority": 5, "metadata": { "runnerId": "63123540" } }, { "selectionId": 6843869, "runnerName": "Draw/FC Betlemi Ked", "handicap": 0, "sortPriority": 6, "metadata": { "runnerId": "63123541" } }, { "selectionId": 8380727, "runnerName": "FC Betlemi Ked/FC Samtredia", "handicap": 0, "sortPriority": 7, "metadata": { "runnerId": "63123542" } }, { "selectionId": 6843873, "runnerName": "FC Betlemi Ked/Draw", "handicap": 0, "sortPriority": 8, "metadata": { "runnerId": "63123543" } }, { "selectionId": 6843870, "runnerName": "FC Betlemi Ked/FC Betlemi Ked", "handicap": 0, "sortPriority": 9, "metadata": { "runnerId": "63123544" } } ], "eventType": { "id": "1", "name": "Soccer" }, "competition": { "id": "2356065", "name": "Pirveli Liga" }, "event": { "id": "27165685", "name": "FC Samtredia v FC Betlemi Keda", "countryCode": "GE", "timezone": "GMT", "openDate": "2014-03-13T11:00:00.000Z" } }, { "marketId": "1.113197510", "marketName": "Over/Under 1.5 Goals", "marketStartTime": "2014-03-13T11:00:00.000Z", "totalMatched": 1879.69, "runners": [ { "selectionId": 1221385, "runnerName": "Under 1.5 Goals", "handicap": 0, "sortPriority": 1, "metadata": { "runnerId": "63123545" } }, { "selectionId": 1221386, "runnerName": "Over 1.5 Goals", "handicap": 0, "sortPriority": 2, "metadata": { "runnerId": "63123546" } } ], "eventType": { "id": "1", "name": "Soccer" }, "competition": { "id": "2356065", "name": "Pirveli Liga" }, "event": { "id": "27165685", "name": "FC Samtredia v FC Betlemi Keda", "countryCode": "GE", "timezone": "GMT", "openDate": "2014-03-13T11:00:00.000Z" } }, { "marketId": "1.113197507", "marketName": "Over/Under 4.5 Goals", "marketStartTime": "2014-03-13T11:00:00.000Z", "totalMatched": 3189.28, "runners": [ { "selectionId": 1222347, "runnerName": "Under 4.5 Goals", "handicap": 0, "sortPriority": 1, "metadata": { "runnerId": "63123524" } }, { "selectionId": 1222346, "runnerName": "Over 4.5 Goals", "handicap": 0, "sortPriority": 2, "metadata": { "runnerId": "63123525" } } ], "eventType": { "id": "1", "name": "Soccer" }, "competition": { "id": "2356065", "name": "Pirveli Liga" } } ``` -------------------------------- ### Get Market Book Best Offers (JSON-RPC) Source: https://betfair-developer-docs.atlassian.net/wiki/spaces/1smk3cen4v3lu3yomq5qye0ni/pages/2687059/Python This Python function uses JSON-RPC to call the listMarketBook API and retrieve available prices for a given market ID. It prints the request and response for debugging and returns the market book results. ```python def getMarketBookBestOffers(marketId): print 'Calling listMarketBook to read prices for the Market with ID :'+ marketId market_book_req ='{"jsonrpc": "2.0", "method": "SportsAPING/v1.0/listMarketBook", "params": {"marketIds":["'+ marketId +'"],"priceProjection":{"priceData":["EX_BEST_OFFERS"]}}, "id": 1}' """ print market_book_req """ market_book_response = callAping(market_book_req) """ print market_book_response """ market_book_loads = json.loads(market_book_response) try: market_book_result = market_book_loads['result'] return market_book_result except: print 'Exception from API-NG'+ str(market_book_result['error']) exit() ``` -------------------------------- ### Get Market Book (Rescript) Source: https://betfair-developer-docs.atlassian.net/wiki/spaces/1smk3cen4v3lu3yomq5qye0ni/pages/2687059/Python This Rescript function calls the listMarketBook API using a REST endpoint to retrieve market prices. It constructs the request payload and returns the parsed JSON response. ```rescript def getMarketBook(marketId): if( marketId is not None): print 'Calling listMarketBook to read prices for the Market with ID :'+ marketId market_book_req ='{"marketIds":["'+ marketId +'"],"priceProjection":{"priceData":["EX_BEST_OFFERS"]}}' endPoint ='https://api.betfair.com/rest/v1.0/listMarketBook/' market_book_response = callAping(endPoint, market_book_req) market_book_loads = json.loads(market_book_response) return market_book_loads ``` -------------------------------- ### C# API-NG Sample Application Command Line Execution Source: https://betfair-developer-docs.atlassian.net/wiki/spaces/1smk3cen4v3lu3yomq5qye0ni/pages/2687074/C Illustrates how to run the C# API-NG sample application from the command line, specifying app key, session token, and protocol. ```bash \Api-ng-sample-code\Api-ng-sample-code\bin\Release\Api-ng-sample-code.exe <(optional)rescript/jsonrpc> ``` -------------------------------- ### List Event Types Source: https://betfair-developer-docs.atlassian.net/wiki/spaces/1smk3cen4v3lu3yomq5qye0ni/pages/2687786/Getting%2BStarted This example demonstrates how to call the listEventTypes method via JSON-RPC to get a list of available event types and the number of markets associated with each. ```APIDOC ## POST /exchange/betting/json-rpc/v1 ### Description Retrieves a list of event types and their associated market counts. ### Method POST ### Endpoint /exchange/betting/json-rpc/v1 ### Parameters #### Request Body - **jsonrpc** (string) - Required - Specifies the JSON-RPC version. - **method** (string) - Required - The method to call, e.g., "SportsAPING/v1.0/listEventTypes". - **params** (object) - Required - Parameters for the method. An empty filter is used in this example. - **id** (integer) - Required - An identifier for the request. ### Request Example ```json { "jsonrpc": "2.0", "method": "SportsAPING/v1.0/listEventTypes", "params": {}, "id": 1 } ``` ### Response #### Success Response (200) - **jsonrpc** (string) - The JSON-RPC version. - **result** (array) - An array of event type objects, each containing: - **eventType** (object) - **id** (string) - The unique identifier for the event type. - **name** (string) - The name of the event type. - **marketCount** (integer) - The number of markets available for this event type. #### Response Example ```json [ { "jsonrpc": "2.0", "result": [ { "eventType": { "id": "468328", "name": "Handball" }, "marketCount": 11 }, { "eventType": { "id": "1", "name": "Soccer" }, "marketCount": 25388 } ] } ] ``` ``` -------------------------------- ### Python Example for Listing Competitions Source: https://betfair-developer-docs.atlassian.net/wiki/spaces/1smk3cen4v3lu3yomq5qye0ni/pages/2687786/Getting%2BStarted Demonstrates how to make a request to listCompetitions using Python's requests library. Ensure to replace APP_KEY_HERE and SESSION_TOKEN with your actual credentials. ```python import requests import json url="https://api.betfair.com/betting/json-rpc" header = { 'X-Application' : "APP_KEY_HERE", 'X-Authentication : 'SESSION_TOKEN', 'content-type' : 'application/json' } jsonrpc_req='{"jsonrpc": "2.0", "method": "SportsAPING/v1.0/listCompetitions", "params": {"filter":{ "eventTypeIds" : [1] }}, "id": 1}' print json.dumps(json.loads(jsonrpc_req), indent=3) print " " response = requests.post(url, data=jsonrpc_req, headers=header) print json.dumps(json.loads(response.text), indent=3) ``` -------------------------------- ### Place 'Keep' Bet (PERSIST) Source: https://betfair-developer-docs.atlassian.net/wiki/spaces/1smk3cen4v3lu3yomq5qye0ni/pages/2687496 This example demonstrates how to place a bet that will be kept and automatically placed into the in-play market if unmatched when the event starts. Use 'persistenceType': 'PERSIST' for this functionality. ```json [ { "jsonrpc": "2.0", "method": "SportsAPING/v1.0/placeOrders", "params": { "marketId": "1.109850906", "instructions": [ { "selectionId": "237486", "handicap": "0", "side": "LAY", "orderType": "LIMIT", "limitOrder": { "size": "2", "price": "3", "persistenceType": "PERSIST" } } ] }, "id": 1 } ] ``` ```json [ { "jsonrpc": "2.0", "result": { "marketId": "1.109850906", "instructionReports": [ { "instruction": { "selectionId": 237486, "handicap": 0, "limitOrder": { "size": 2, "price": 3, "persistenceType": "PERSIST" }, "orderType": "LIMIT", "side": "LAY" }, "betId": "31242604945", "placedDate": "2013-10-30T14:22:47.000Z", "averagePriceMatched": 0, "sizeMatched": 0, "status": "SUCCESS" } ], "status": "SUCCESS" }, "id": 1 } ] ``` -------------------------------- ### Place Fill or Kill Order (With Min Fill Size) Source: https://betfair-developer-docs.atlassian.net/wiki/spaces/1smk3cen4v3lu3yomq5qye0ni/pages/2687154 This example shows how to place a 'FILL_OR_KILL' limit order with a specified minimum fill size. The order will only be partially matched if at least the 'minFillSize' can be satisfied immediately; otherwise, it will be cancelled. ```json [{"jsonrpc": "2.0", "method": "SportsAPING/v1.0/placeOrders", "params": {"marketId":"1.126124422","instructions":[{"selectionId":"10590221","handicap":"0","side":"BACK","orderType":"LIMIT","limitOrder":{"size":"5","price":"21","persistenceType":"LAPSE","timeInForce":"FILL_OR_KILL","minFillSize":"3"}}]}, "id": 1}] ``` ```json [{"jsonrpc":"2.0","result":{"status":"SUCCESS","marketId":"1.126124422","instructionReports":[{"status":"SUCCESS","instruction":{"selectionId":10590221,"handicap":0.0,"limitOrder":{"size":5.0,"price":21.0,"minFillSize":3.0,"timeInForce":"FILL_OR_KILL"},"orderType":"LIMIT","side":"BACK"},"betId":"72666433304","placedDate":"2016-08-12T10:47:42.000Z","averagePriceMatched":21.32267441860465,"sizeMatched":3.4400000000000004}]},"id":1}] ``` -------------------------------- ### Request to List Market Book for Settled Market Source: https://betfair-developer-docs.atlassian.net/wiki/spaces/1smk3cen4v3lu3yomq5qye0ni/pages/2687786/Getting%2BStarted To get the result of a settled market, use the listMarketBook request after the market has been settled. This example requests best offers for a specific market ID. ```json [{"jsonrpc": "2.0", "method": "SportsAPING/v1.0/listMarketBook", "params": {"marketIds":["1.114363660"],"priceProjection":{"priceData":["EX_BEST_OFFERS"]}}, "id": 1}] ``` -------------------------------- ### Getting Next Available Horse Races Source: https://betfair-developer-docs.atlassian.net/wiki/spaces/1smk3cen4v3lu3yomq5qye0ni/pages/2687529/Java This example shows how to fetch the next available horse racing markets. It configures a MarketFilter to specify event type, country, and market type, then calls listMarketCatalogue. ```Java System.out.println("4.(listMarketCatalogue) Get next horse racing market in the UK...\n"); TimeRange time = new TimeRange(); time.setFrom(new Date()); Set countries = new HashSet(); countries.add("GB"); Set typesCode = new HashSet(); typesCode.add("WIN"); marketFilter = new MarketFilter(); marketFilter.setEventTypeIds(eventTypeIds); marketFilter.setMarketStartTime(time); marketFilter.setMarketCountries(countries); marketFilter.setMarketTypeCodes(typesCode); Set marketProjection = new HashSet(); marketProjection.add(MarketProjection.COMPETITION); marketProjection.add(MarketProjection.EVENT); marketProjection.add(MarketProjection.EVENT_TYPE); marketProjection.add(MarketProjection.MARKET_DESCRIPTION); marketProjection.add(MarketProjection.RUNNER_DESCRIPTION); String maxResult = "1"; List marketCatalogueResult = jsonOperations.listMarketCatalogue(marketFilter, marketProjection, MarketSort.FIRST_TO_START, maxResult, applicationKey, sessionToken); ``` -------------------------------- ### Place Orders - Minimum Fill Size Example Source: https://betfair-developer-docs.atlassian.net/wiki/spaces/1smk3cen4v3lu3yomq5qye0ni/pages/2687496/placeOrders Illustrates placing a LIMIT order with a specified minimum fill size. This ensures that only orders meeting or exceeding the minimum fill amount are executed. ```APIDOC ## POST placeOrders with Min Fill Size ### Description This example demonstrates placing a LIMIT order using the `placeOrders` operation, specifying a `minFillSize`. The order will only be executed if at least the specified amount can be filled. ### Method POST ### Endpoint /SportsAPING/v1.0/placeOrders ### Parameters (See general `placeOrders` documentation for full parameter details. This example highlights `minFillSize`) #### Request Body Example (focus on `minFillSize`) ```json [ { "jsonrpc": "2.0", "method": "SportsAPING/v1.0/placeOrders", "params": { "marketId": "1.126124422", "instructions": [ { "selectionId": "10590221", "handicap": "0", "side": "BACK", "orderType": "LIMIT", "limitOrder": { "size": "5", "price": "21", "persistenceType": "LAPSE", "timeInForce": "FILL_OR_KILL", "minFillSize": "3" } } ] }, "id": 1 } ] ``` ### Response Example (partial, showing matched details) ```json [ { "jsonrpc": "2.0", "result": { "status": "SUCCESS", "marketId": "1.126124422", "instructionReports": [ { "status": "SUCCESS", "instruction": { "selectionId": 10590221, "handicap": 0.0, "limitOrder": { "size": 5.0, "price": 21.0, "minFillSize": 3.0, "timeInForce": "FILL_OR_KILL" }, "orderType": "LIMIT", "side": "BACK" }, "betId": "72666433304", "placedDate": "2016-08-12T10:47:42.000Z", "averagePriceMatched": 21.32267441860465, "sizeMatched": 3.4400000000000004 } ] }, "id": 1 } ] ``` ``` -------------------------------- ### Place Fill or Kill Order (No Min Fill Size) Source: https://betfair-developer-docs.atlassian.net/wiki/spaces/1smk3cen4v3lu3yomq5qye0ni/pages/2687154 This example demonstrates placing a 'FILL_OR_KILL' limit order without specifying a minimum fill size. The entire order must be matched immediately, or it will be cancelled. ```json [{"jsonrpc": "2.0", "method": "SportsAPING/v1.0/placeOrders", "params": {"marketId":"1.126124422","instructions":[{"selectionId":"10590221","handicap":"0","side":"BACK","orderType":"LIMIT","limitOrder":{"size":"5","price":"21","persistenceType":"LAPSE","timeInForce":"FILL_OR_KILL","minFillSize":"5"}}]}, "id": 1}] ``` ```json [{"jsonrpc":"2.0","result":{"status":"SUCCESS","marketId":"1.126124422","instructionReports":[{"status":"SUCCESS","instruction":{"selectionId":10590221,"handicap":0.0,"limitOrder":{"size":5.0,"price":21.0,"minFillSize":5.0,"timeInForce":"FILL_OR_KILL"},"orderType":"LIMIT","side":"BACK"},"betId":"72666364933","placedDate":"2016-08-12T10:45:15.000Z","averagePriceMatched":0.0,"sizeMatched":0.0}]},"id":1}] ``` -------------------------------- ### Get Next Available Horse Races Source: https://betfair-developer-docs.atlassian.net/wiki/spaces/1smk3cen4v3lu3yomq5qye0ni/pages/2687529/www.atlassian.com This Java code retrieves the next available horse racing markets. It configures a MarketFilter with specific criteria including event type IDs, market start time, country codes ('GB'), and market type codes ('WIN'). It also specifies the desired market projections and limits the results to one. ```Java System.out.println("4.(listMarketCatalogue) Get next horse racing market in the UK...\n"); TimeRange time = new TimeRange(); time.setFrom(new Date()); Set countries = new HashSet(); countries.add("GB"); Set typesCode = new HashSet(); typesCode.add("WIN"); marketFilter = new MarketFilter(); marketFilter.setEventTypeIds(eventTypeIds); marketFilter.setMarketStartTime(time); marketFilter.setMarketCountries(countries); marketFilter.setMarketTypeCodes(typesCode); Set marketProjection = new HashSet(); marketProjection.add(MarketProjection.COMPETITION); marketProjection.add(MarketProjection.EVENT); marketProjection.add(MarketProjection.EVENT_TYPE); marketProjection.add(MarketProjection.MARKET_DESCRIPTION); marketProjection.add(MarketProjection.RUNNER_DESCRIPTION); String maxResult = "1"; List marketCatalogueResult = jsonOperations.listMarketCatalogue(marketFilter, marketProjection, MarketSort.FIRST_TO_START, maxResult, applicationKey, sessionToken); ```