Retrieving Details of Bets on a Settled Market - including P&L & Commission paid.
The Betfair API offers three login flows for developers, depending on the use case of your application:.
Non-Interactive login - if you are building an application which will run autonomously, there is a separate login flow to follow to ensure your account remains secure.
Interactive login - API method - This flow makes use of a JSON API Endpoint and is the simplest way to get started if you are looking to create your own login form.
All requests must include a HTTP header named "X-Application" containing the Application Key assigned to you.
All requests must include a HTTP header "X-Authentication" containing your sessionToken.
Please note: The only exceptions to the above are some of the Account Operations (Vendor API ) which require the X-Authentication HTTP header only.
You can call the API at one of two endpoints, depending on which style of request you want to use.
You can make requests and place bets on UK & international markets by accessing the Global Exchange via the following endpoints.
You can make requests for your UK Exchange wallet information by accessing the Global Exchange via the following endpoints.
The POST data contains the request parameters. For listEventTypes, the only required parameter is a filter to select markets. You can pass an empty filter to select all markets, in which case listEventTypes returns the EventTypes associated with all available markets.
url = endpoint + "listEventTypes/"
The POST data should contain a valid JSON-RPC formatted request where the "params" field contains the request parameters and the "method" field contains the API method you are calling, specified like "SportsAPING/v1.0/<operation name>.
This section shows how you might call the Betting API to retrieve information.
You can make a request using the listEventTypes service which will return a response containing the eventTypes (e.g. Soccer, Horse Racing etc.) that are currently available on Betfair.
The below example demonstrates how to retrieve a list of events (eventIds) for a specific event type. The request shows how to retrieve all Soccer events that are taking place in a single day.
The below request is an example of retrieving the available win/place horse racing markets for a specific day. The marketStartTime (from & to) should be updated accordingly.
The "filter" selects all markets that have an eventTypeId of 1 (which is the event type for Football).
Once you have identified the market (marketId) that your interested in using the listMarketCatalogue service, you can request prices for that market using the listMarketBook API call.
This is an example showing a request for the best prices (back and lay) and trading volume including virtual bets.
Below is an example of an Betfair SP Bet - using the orderType LIMIT_ON_CLOSE . Please refer to Additional Information#CurrencyParameters for Min BSP liability.
You can use the listCurrentOrders request to retrieve of a bet/s placed on a specific market/s.
To retrieve the result of a settled market = make a request to listMarketBook after the market has been settled. The response will indicate whether the selection was settled as a 'WINNER' or 'LOSER' in the runners 'status' field. Settled market information is available for 90 days after settlement.
You can retrieve details of a settled bet/market using the listClearedOrders request. The below request uses a specific settledDatRange to limit the returned records and groupBy MARKET rollup to group results at markeId level.