Getting list of horse races with their start time and list of runner and prices

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • betchair
    Junior Member
    • Jun 2023
    • 9

    #1

    Getting list of horse races with their start time and list of runner and prices

    What is the best way to get list of horse races with their associated horses and prices? It seems the betfiar API is very different in structure compared to the other exchanges.
    It seems events in Betfair are more like venues. and the only way to get a horse race name and start time is to merge data from different requests together after iterating through all the markets for the venue.

    ListMarketCatalogue does not show the horse race start time., even if i put "MARKET_START_TIME" in the market projection.

    A point in the right direction would be great please.
    I need a horse race object (name and start time) with the runners (current prices) in an object eventually after making whatever calls are needed.

    Thanks so much in advance

    Gav
  • betchair
    Junior Member
    • Jun 2023
    • 9

    #2
    ListMarketCatalogue does not seem to return WIN markets is there a reason for this or are WIN markets renamed to something else?

    Comment

    • betchair
      Junior Member
      • Jun 2023
      • 9

      #3
      this legacy spaghetti is lovely to work with. Great work guys! loving it.

      Comment

      • jabe
        Senior Member
        • Dec 2014
        • 705

        #4
        It's all quite logical. My usual suggestion to new people is to code up classes for the data (you might want to add procedures eventually) for whatever can be retrieved by a call. Do that and you will begin to see how the data works and how it is related. But I'll give you some hints.

        Each event will have a number of markets. A market is anything that you can bet on. It might be a WIN market, a PLACE market, or any of several other things.

        When it comes to horse racing, a race is an EVENT of the EventType that denotes horse racing. The Event data includes the scheduled start time/date of the event.

        For each race, there is a number of MARKETS.

        A MarketCatalogue tells you the (supposedly) FIXED things about a market, including the Runners. In the case of horse racing, runners includes horse names and perhaps other details.

        For each MarketCatalogue there is a MarketBook. The MarketBook tells you the things about a market that are expected to change, such as the odds and related available money (or Size and Price, as they are called). TotalMatched for the market is on the MarketCatalogue, just to be awkward.

        MarketStartTime is when betting starts on the market, not when the event is due to kick off.

        The MarketType, such as WIN or PLACE is part of the Description on the MarketCataologue. Description is of type MarketDescription. Many data items are of some type that means they contain multiple data items. Runners is another.

        It's all in the documentation and searching on the forum will usually help with difficult questions. If not, ask away.

        Comment

        • betchair
          Junior Member
          • Jun 2023
          • 9

          #5
          Thanks so much for such a fast reply.Issue is when the listEvents endpoint is called with 7 as the event types only one event per venue is returned. so for example Cheltenham is returned but not all the races (events) for Cheltenham. Are other parameters needed to get such race data?

          Comment

          • jabe
            Senior Member
            • Dec 2014
            • 705

            #6
            Originally posted by betchair View Post
            Thanks so much for such a fast reply.Issue is when the listEvents endpoint is called with 7 as the event types only one event per venue is returned. so for example Cheltenham is returned but not all the races (events) for Cheltenham. Are other parameters needed to get such race data?
            Yes. I'm reminded that there is an odd level of iteration concerning horse racing. From what I remember, a race meeting is an event, and all the races at a race meeting are also events. (I need to verify this, so don't take it as fact yet)

            It's been a while since I've given it much thought. My main program is in Visual Basic.Net (but isn't about horse racing) and contains a number of pages, including one for testing calls. I'll fire it up tomorrow and see if I can remind myself how the meetings/races thing works. I'll get back to you.

            EDIT: Got some new error message coming up on code I wrote years ago, so it won't be today, I'm afraid.
            Last edited by jabe; 15-06-2023, 11:31 PM.

            Comment

            • jabe
              Senior Member
              • Dec 2014
              • 705

              #7
              I can see why you're confused. I've just been using the Demo thing and I was going round in circles until I discovered that the listMarketCatalogue call is set by default to retrieve

              ONE

              item,

              If you need more, you have to scroll down and change the

              ONE


              to a value that is actually useful. ONE is not useful. Not when you want a list. A list of ONE item when you know the list should contain more than ONE item is not useful. What a waste of time this has been.


              This is what you need to do.

              listEvents with EventType = 7 and restrict the dates however you wish. Note that the dates are TIMESTAMPS. To code the end of day use 23:59:59 and the largest bit of a second thereafter. You might want to restrict in other ways, including country code, venue, etc.

              Using the (Event)Id(s) from the Events list, listMarketCatalogue. I would suggest if you only want a list of races and runners, that you specify marketType = "WIN". This should bring you a list of the races for the day.

              If you cycle through the retrieved MarketCatalogues you can get the horses for each race from the runners array. You will see that the data type for runners is runnerCatalog. It includes the selectionId and name of each horse.

              You can use data retrieved so far to call the listMarketBook for the WIN market and obtain the prices (if there are any - sometimes there aren't) for each horse. Note that the MarketBook data includes an array called runners which is of type rRunnerCatalog and includes the current prices. Remember that there may be back and lay prices for each horse.


              Good luck, apologies for it taking longer than intended.




              Last edited by jabe; 19-06-2023, 01:44 PM.

              Comment

              • betchair
                Junior Member
                • Jun 2023
                • 9

                #8
                Thanks for the reply working on a weekend too I am still no closer unfortunately.

                ------------------------------------
                "listEvents with EventType = 7 and restrict the dates however you wish. Note that the dates are TIMESTAMPS. To code the end of day use 23:59:59 and the largest bit of a second thereafter. You might want to restricy in other ways, including country code, venue, etc.

                Using the MarketId(s) from the Events list, listMarketCatalogue, specifying the MarketId(s) from above. I would suggest if you only want a list of races and runners, that you specify marketType = "WIN". This should bring you a list of the races for the day.

                ------------------------
                ------------
                - when calling ListEvents with EventType=7 no MarketIDs are returned.
                Here is the POST request details:
                  1. [{"jsonrpc": "2.0", "method": "SportsAPING/v1.0/listEvents", "params": {"filter":{"eventTypeIds":["7"]}}, "id": 1}]

                The response from this does not contain any MarketIDs just a list of events (one per venue it seems)
                The only IDs are event IDs

                Perhaps the demo tool does not have option for market IDs?

                Thanks for much for the help, i really appreciate it.

                Comment

                • jabe
                  Senior Member
                  • Dec 2014
                  • 705

                  #9
                  Originally posted by betchair View Post
                  Thanks for the reply working on a weekend too I am still no closer unfortunately.

                  ------------------------------------
                  "listEvents with EventType = 7 and restrict the dates however you wish. Note that the dates are TIMESTAMPS. To code the end of day use 23:59:59 and the largest bit of a second thereafter. You might want to restricy in other ways, including country code, venue, etc.

                  Using the MarketId(s) from the Events list, listMarketCatalogue, specifying the MarketId(s) from above. I would suggest if you only want a list of races and runners, that you specify marketType = "WIN". This should bring you a list of the races for the day.

                  ------------------------
                  ------------
                  - when calling ListEvents with EventType=7 no MarketIDs are returned.
                  Here is the POST request details:
                    1. [{"jsonrpc": "2.0", "method": "SportsAPING/v1.0/listEvents", "params": {"filter":{"eventTypeIds":["7"]}}, "id": 1}]

                  The response from this does not contain any MarketIDs just a list of events (one per venue it seems)
                  The only IDs are event IDs

                  Perhaps the demo tool does not have option for market IDs?

                  Thanks for much for the help, i really appreciate it.
                  Apologies. It should have been the EventId, not the MarketId. I'll amend my post to make it easier.

                  The Events returned on the listEvents with type=7 are race meetings. I'd remembered wrongly about the individual races also being Events (it may be that the previous API did it that way, but I'm not going to check).

                  Let us know how you get on.
                  Last edited by jabe; 19-06-2023, 02:02 PM.

                  Comment

                  • betchair
                    Junior Member
                    • Jun 2023
                    • 9

                    #10
                    Thanks for the update. However how do i get the race start time and name of the race? Being able to view the race name and start time with runners is the end goal. I can get the runners with your steps but not the race name or start time. Any idea where those two attributes will be?

                    Thanks again for all your support

                    Comment

                    • geoffw123
                      Senior Member
                      • Mar 2014
                      • 250

                      #11
                      hi

                      Is this example C# program of any help ?

                      https://github.com/geoffw123/API-NG-Basic-WinForm-App

                      Comment

                      • jabe
                        Senior Member
                        • Dec 2014
                        • 705

                        #12
                        Looks like the race start time is the MarketStartTime on the MarketCatalogue, despite what I said before.

                        I've had a look at what's available and it appears the best you can do for race titles are Venue + Start Time + Market Name, so something like "Lingfield 14:30 1m3f HCap". Even the main Betfair site doesn't seem to show the more elaborate race titles, so nothing like "The Sir Henry Rawlinson Memorial Stakes", for instance.

                        The venue is on the listEvents data, but has the date on, which you can keep or lose. You might also want to start your prog with a call to listVenues for Event Type = 7 and whatever countries are of interest, and store them for the duration. Like a few other calls, venues will only be returned if there are upcoming races uploaded for them on Betfair.

                        I've no idea how much of a racing expert you are, but it's normally possible to determine whether GB races are flat or jumps by the race length and venue. The ages of the horses can be used too.

                        Comment

                        • betchair
                          Junior Member
                          • Jun 2023
                          • 9

                          #13
                          Originally posted by geoffw123 View Post
                          hi

                          Is this example C# program of any help ?

                          https://github.com/geoffw123/API-NG-Basic-WinForm-App
                          seems this is a private repo, when logged in a 404 is displayed for that page. I am coding in Golang, but could read C if needed. Thanks for the pointer.

                          Comment

                          • betchair
                            Junior Member
                            • Jun 2023
                            • 9

                            #14
                            Originally posted by jabe View Post
                            Looks like the race start time is the MarketStartTime on the MarketCatalogue, despite what I said before.

                            I've had a look at what's available and it appears the best you can do for race titles are Venue + Start Time + Market Name, so something like "Lingfield 14:30 1m3f HCap". Even the main Betfair site doesn't seem to show the more elaborate race titles, so nothing like "The Sir Henry Rawlinson Memorial Stakes", for instance.

                            The venue is on the listEvents data, but has the date on, which you can keep or lose. You might also want to start your prog with a call to listVenues for Event Type = 7 and whatever countries are of interest, and store them for the duration. Like a few other calls, venues will only be returned if there are upcoming races uploaded for them on Betfair.

                            I've no idea how much of a racing expert you are, but it's normally possible to determine whether GB races are flat or jumps by the race length and venue. The ages of the horses can be used too.
                            hmm this is what i was starting with at the start before making post, i should have been more clear. Having to iterate over each runner and put that runner in their respected horse race. Thanks for clearing up that the marketStartTime is the horse race start time and not the when money started coming in on that market.

                            Comment

                            • jabe
                              Senior Member
                              • Dec 2014
                              • 705

                              #15
                              Originally posted by betchair View Post

                              hmm this is what i was starting with at the start before making post, i should have been more clear. Having to iterate over each runner and put that runner in their respected horse race. Thanks for clearing up that the marketStartTime is the horse race start time and not the when money started coming in on that market.
                              Going back a few decades, I used to work in IT writing mainly in Cobol. It had a handy feature whereby one could set up hierarchies of data, so a file would consist of a number of records, and each would have a particular layout and contain a number of what were called fields, which were data items (and there could be assorted records in a file, and the record length might not be fixed, etc, etc). It allowed one to move a whole array, or the whole record, or any defined "group fields", etc, etc. A handy thing I found when setting up classes for my main API prog is that one could read the returned data item from a call straight into a new object of the relevant class, and the whole thing and all its data were where they ought to be, rather like moving a Cobol record or multi-part chunk of data in one go. I'm not familiar with Golang, but, alas, if there isn't an easy way to move chunks of data around, one has to resort to loops. But they are pretty much the basis of programming, and these days they do run very quickly.
                              Last edited by jabe; 19-06-2023, 05:29 PM.

                              Comment

                              Working...
                              X