Logic

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • kiwis
    Junior Member
    • Feb 2022
    • 4

    #1

    Logic

    I want to get individual rugby games from specific competitions.


    So far I've got Rugby Union as event type 5

    I've done listCompetitions to get the Super Rugby Pacific ID of 10536616

    I've then done, listEvents with the competitionIds as a filter.

    This shows games (events).

    How can I now get the individual head to head odds for each event ID


  • BetfairDeveloperProgram
    Administrator
    • Oct 2008
    • 680

    #2
    Hi kiwis,

    You can request the Head to Head markets (marketId's) by making the following request:

    Request

    Code:
    [{"jsonrpc": "2.0", "method": "SportsAPING/v1.0/listMarketCatalogue", "params": {"filter":{"competitionIds":["10536616"],"marketTypeCodes":["MATCH_ODDS"]},"maxResults":"200","marketProjection":["EVENT_TYPE","COMPETITION","EVENT","RUNNER_DESCRIPTION","RUNNER_METADATA","MARKET_START_TIME"]}, "id": 1}
    ]

    Response

    Code:
    [{"jsonrpc":"2.0","result":[{"marketId":"1.195125639","marketName":"Head To Head","marketStartTime":"2022-02-26T03:35:00.000Z","totalMatched":438.72,"runners":[{"selectionId":362091,"runnerName":"Brumbies","han dicap":0.0,"sortPriority":1,"metadata":{"runnerId" :"362091"}},{"selectionId":14582963,"runnerName":" Fijian Drua","handicap":0.0,"sortPriority":2,"metadata":{ "runnerId":"14582963"}}],"eventType":{"id":"5","name":"Rugby Union"},"competition":{"id":"10536616","name":"Sup er Rugby Pacific"},"event":{"id":"31255376","name":"Brumbie s v Fijian Drua","countryCode":"AU","timezone":"Australia/Sydney","openDate":"2022-02-26T03:35:00.000Z"}},{"marketId":"1.195125849","mar ketName":"Head To Head","marketStartTime":"2022-02-26T06:05:00.000Z","totalMatched":0.0,"runners":[{"selectionId":339662,"runnerName":"Blues","handic ap":0.0,"sortPriority":1,"metadata":{"runnerId":"3 39662"}},{"selectionId":339640,"runnerName":"Hurri canes","handicap":0.0,"sortPriority":2,"metadata": {"runnerId":"339640"}}],"eventType":{"id":"5","name":"Rugby Union"},"competition":{"id":"10536616","name":"Sup er Rugby Pacific"},"event":{"id":"31255375","name":"Blues v Hurricanes","countryCode":"NZ","timezone":"Austral ia/Sydney","openDate":"2022-02-26T06:05:00.000Z"}},{"marketId":"1.195126059","mar ketName":"Head To Head","marketStartTime":"2022-02-26T08:45:00.000Z","totalMatched":0.0,"runners":[{"selectionId":2502119,"runnerName":"Rebels","hand icap":0.0,"sortPriority":1,"metadata":{"runnerId": "2502119"}},{"selectionId":42862739,"runnerName":" W.Force","handicap":0.0,"sortPriority":2,"metadata ":{"runnerId":"42862739"}}],"eventType":{"id":"5","name":"Rugby Union"},"competition":{"id":"10536616","name":"Sup er Rugby Pacific"},"event":{"id":"31255374","name":"Rebels v Western Force","countryCode":"AU","timezone":"Australia/Sydney","openDate":"2022-02-26T08:45:00.000Z"}}],"id":1}]
    You can then request market prices for each or all markets using listMarketBook:

    Request

    Code:
    [{"jsonrpc": "2.0", "method": "SportsAPING/v1.0/listMarketBook", "params": {"marketIds":["1.195125639"],"priceProjection":{"priceData":["EX_BEST_OFFERS","EX_TRADED"],"virtualise":"true"}}, "id": 1}]
    Response

    Code:
    [{"jsonrpc":"2.0","result":[{"marketId":"1.195125639","isMarketDataDelayed":fa lse,"status":"OPEN","betDelay":0,"bspReconciled":f alse,"complete":true,"inplay":false,"numberOfWinne rs":1,"numberOfRunners":2,"numberOfActiveRunners": 2,"lastMatchTime":"2022-02-24T22:48:28.130Z","totalMatched":441.73,"totalAvai lable":521.44,"crossMatching":true,"runnersVoidabl e":false,"version":4370149064,"runners":[{"selectionId":362091,"handicap":0.0,"status":"ACT IVE","lastPriceTraded":1.05,"totalMatched":441.73, "ex":{"availableToBack":[{"price":1.01,"size":99.0}],"availableToLay":[{"price":1.05,"size":343.24}],"tradedVolume":[{"price":1.02,"size":173.04},{"price":1.05,"size": 268.69}]}},{"selectionId":14582963,"handicap":0.0,"status" :"ACTIVE","totalMatched":0.0,"ex":{"availableToBac k":[{"price":22.0,"size":1.93},{"price":21.0,"size":15 .14},{"price":1.02,"size":33.5}],"availableToLay":[],"tradedVolume":[]}}]}],"id":1}]
    Kind Regards

    Neil

    Comment

    • kiwis
      Junior Member
      • Feb 2022
      • 4

      #3

      Many thanks. I have this now.

      In the listMarketCatalogue I have runners which are the two teams.

      In the listMarketBook is have availableToBack, how do I align/join runners to available to back or does the array order they show in the catalogue align with this order?

      Comment

      • faulknernolan
        Junior Member
        • Aug 2022
        • 1

        #4
        Originally posted by kiwis View Post
        Many thanks. I have this now.

        In the listMarketCatalogue I have runners which are the two teams.

        In the listMarketBook is have availableToBack, how do I align/join runners to available to back or does the array order they show in the catalogue align with this order?
        I also want to know the answer fall guys

        Comment

        • jabe
          Senior Member
          • Dec 2014
          • 705

          #5
          My earlier answer was not entirely accurate, but this should do the trick.

          For each Event there are several MarketCatalogues.

          MarketCatalogues contain the (mostly) fixed data for each market, including the name of the market.

          The runners (or outcomes) for the market are listed in the runners() array.

          The datatype for this array is runnerCatalogue it includes the
          selectionName and selectionId

          The selectionName is only of use for (1) reporting on the event and (2) allowing identification of a runner/outcome, to match it with choosing a selection, either manually or programmatically. After that, it's the selectionId that is used.

          MarketBooks contain the ongoing changing data for a market. There is one MarketBook for each MarketCatalogue.

          The MarketBook contains an array called runners().

          The datatype for this is ClassRunner.

          ClassRunner includes selectionId, which tells you the selectionId for a particular outcome of the market and allows the selectionName from the MarketCatalogue to be associated with the selectionId.

          Also of major interest are orders() and matches() for each runner.


          It is my opinion that the first thing anyone new to the API-NG should do is create classes (just for data) for all datatypes mentioned in the documentation. That will help in understanding where everything is and how it all relates.

          I also spent some early time considering what data should exist and how it would have fitted together had I been designing the whole thing.

          I understand that my IT background gives me an advantage in recognizing these things. The same would apply to other with IT experience.
          Last edited by jabe; 16-08-2022, 12:45 AM.

          Comment

          • hena
            Junior Member
            • Feb 2023
            • 2

            #6
            Originally posted by kiwis View Post
            I want to get individual rugby games from specific competitions.


            So far I've got Rugby Union as event type 5 drive mad

            I've done listCompetitions to get the Super Rugby Pacific ID of 10536616

            I've then done, listEvents with the competitionIds as a filter.

            This shows games (events).

            How can I now get the individual head to head odds for each event ID

            To get the individual head-to-head odds for each event ID, you can use the Betfair API to retrieve the market information for each event. Here are the steps:
            1. Use the listMarketCatalogue operation with the filter parameter set to filter by event ID and market type. For rugby union, the market type for head-to-head odds is usually "Match Odds". Set the maxResults parameter to retrieve all available markets for the event.
            2. From the response of listMarketCatalogue, you can get the marketId of the "Match Odds" market for each event.
            3. Use the listMarketBook operation with the marketIds parameter set to the marketId from step 2. Set the priceProjection parameter to include the odds and any other relevant information you need.
            4. From the response of listMarketBook, you can get the head-to-head odds for the event.

            Comment

            Working...
            X