Football league matches

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ajw
    Junior Member
    • Sep 2018
    • 14

    #1

    Football league matches

    How would I go about getting the marketIDs for a particular football league ?

    e.g.

    https://www.betfair.com/exchange/plu...ompetition/228
    https://www.betfair.com/exchange/plu...et/1.150224812
  • BetfairDeveloperProgram
    Administrator
    • Oct 2008
    • 680

    #2
    Hi ajw

    You'd need to request details of all competitions for football (eventTypeIds 1) using listCompetitions and then make a request using the resulting competitionI'ds to listMarketCatalogue which will return the marketIds, see example below:

    listCompetitions

    Request

    Code:
    [{"jsonrpc": "2.0", "method": "SportsAPING/v1.0/listCompetitions", "params": {"filter":{"eventTypeIds":["1"]}}, "id": 1}]
    Response (snippet)

    Code:
    {"jsonrpc":"2.0","result":[{"competition":{"id":"2608550","name":"Specials"},"marketCount":2,"competitionRegion":"International"},{"competition":{"id":"88832","name":"International (W)"},"marketCount":149,"competitionRegion":"International"},{"competition":{"id":"42886","name":"English FA Trophy"},"marketCount":50,"competitionRegion":"GBR"},{"competition":{"id":"8312180","name":"UEFA U19 Championship Qualifying"},"marketCount":313,"competitionRegion":"International"},{"competition":{"id":"8580745","name":"Israeli Liga Bet - South A"},"marketCount":50,"competitionRegion":"ISR"},{"competition":{"id":"11463202","name":"Serie C"},"marketCount":33,"competitionRegion":"ITA"},{"competition":{"id":"141","name":"US Major League Soccer"},"marketCount":1,"competitionRegion":"USA"},{"competition":{"id":"13","name":"Brazilian Serie A"},"marketCount":393,"competitionRegion":"BRA"},{"competition":{"id":"4848838","name":"Czech U21"},"marketCount":25,"competitionRegion":"CZE"},{"competition":{"id":"4431442","name":"Algerian Ligue 1"},
    listMarketCatalogue for competitionId 11463202 (Serie C) markets

    Request

    Code:
    [{"jsonrpc": "2.0", "method": "SportsAPING/v1.0/listMarketCatalogue", "params": {"filter":{"competitionIds":["11463202"]},"maxResults":"1000"}, "id": 1}]
    Response

    Code:
    [{"jsonrpc":"2.0","result":[{"marketId":"1.150873302","marketName":"Over/Under 0.5 Goals","totalMatched":0.0},{"marketId":"1.150873303","marketName":"Over/Under 1.5 Goals","totalMatched":10.22},{"marketId":"1.150873299","marketName":"Match Odds","totalMatched":1980.07},{"marketId":"1.150873300","marketName":"Correct Score","totalMatched":9.74},{"marketId":"1.150873301","marketName":"Both teams to Score?","totalMatched":72.51},{"marketId":"1.150989478","marketName":"Over/Under 5.5 Goals","totalMatched":10.28},{"marketId":"1.150873306","marketName":"Over/Under 4.5 Goals","totalMatched":0.0},{"marketId":"1.150873304","marketName":"Over/Under 2.5 Goals","totalMatched":240.89},{"marketId":"1.150873305","marketName":"Over/Under 3.5 Goals","totalMatched":471.31},{"marketId":"1.150989517","marketName":"Half Time/Full Time","totalMatched":1.4},{"marketId":"1.150989516","marketName":"First Half Goals 1.5","totalMatched":0.0},{"marketId":"1.150989515","marketName":"First Half Goals 0.5","totalMatched":0.0},{"marketId":"1.150989480","marketName":"Asian Handicap","totalMatched":16.31},{"marketId":"1.150989514","marketName":"Half Time Score","totalMatched":0.0},{"marketId":"1.150989479","marketName":"Over/Under 6.5 Goals","totalMatched":0.0},{"marketId":"1.150989521","marketName":"Half Time","totalMatched":0.0},{"marketId":"1.150989520","marketName":"Pontedera +1","totalMatched":1.75},{"marketId":"1.150989519","marketName":"Double Chance","totalMatched":30.17},{"marketId":"1.150989518","marketName":"Next Goal","totalMatched":0.0},{"marketId":"1.150989525","marketName":"Over/Under 8.5 Goals","totalMatched":0.0},{"marketId":"1.150989524","marketName":"Entella +1","totalMatched":0.0},{"marketId":"1.150989523","marketName":"Draw no Bet","totalMatched":12.94},{"marketId":"1.150989522","marketName":"Over/Under 7.5 Goals","totalMatched":0.0},{"marketId":"1.150989527","marketName":"Goal Lines","totalMatched":80.67},{"marketId":"1.150989526","marketName":"First Half Goals 2.5","totalMatched":0.0},{"marketId":"1.151097975","marketName":"Over/Under 1.5 Goals","totalMatched":6.22},{"marketId":"1.151097974","marketName":"Over/Under 0.5 Goals","totalMatched":0.0},{"marketId":"1.151097977","marketName":"Over/Under 3.5 Goals","totalMatched":0.0},{"marketId":"1.151097976","marketName":"Over/Under 2.5 Goals","totalMatched":185.56},{"marketId":"1.151097971","marketName":"Match Odds","totalMatched":345.62},{"marketId":"1.151097973","marketName":"Both teams to Score?","totalMatched":46.28},{"marketId":"1.151097972","marketName":"Correct Score","totalMatched":228.54},{"marketId":"1.151097978","marketName":"Over/Under 4.5 Goals","totalMatched":0.0}],"id":1}]
    Thanks

    Neil

    Comment

    • Chris361
      Junior Member
      • Nov 2018
      • 3

      #3
      Hi

      I'm trying to do a similar thing but can't get a valid response for a listMarketCatalogue request. Just looking for any MarketIDs for now and once that's working will filter it down to what I want.

      Here's my code:

      Code:
      {
                  "jsonrpc": "2.0",
                  "method": "SportsAPING/v1.0/listMarketCatalogue",
                  "params": {
                      "filter": {
                          "eventTypeIds": [
                              "1"
                          ],
                          "marketStartTime": {
                              "from": "2018-11-24T00:00:00Z",
                              "to": "2018-11-30T23:59:00Z"
                          }
                      }
                  },
                  "maxResults": "50",
                  "id": 1
              }
      If I change listMarketCatalogue to, say, listMarketTypes it works perfectly fine so I'm not sure what I'm missing?

      I'm getting urllib.error.HTTPError: HTTP Error 400: Bad Request in callAping
      Last edited by Chris361; 24-11-2018, 06:30 PM.

      Comment

      • BetfairDeveloperProgram
        Administrator
        • Oct 2008
        • 680

        #4
        Hi Chris

        The request details look fine so please check the endpoint your sending the request to https://api.betfair.com/exchange/betting/json-rpc/v1

        Code:
        [{
            "jsonrpc": "2.0",
            "method": "SportsAPING/v1.0/listMarketCatalogue",
            "params": {
                "filter": {
                    "eventTypeIds": ["1"],
                    "marketStartTime": {
                        "from": "2018-11-24T00:00:00Z",
                        "to": "2018-11-30T23:45:00Z"
                    }
                },
                "maxResults": "50"
            },
            "id": 1
        }]

        Thanks

        Neil

        Comment

        • Chris361
          Junior Member
          • Nov 2018
          • 3

          #5
          Hi Neil

          Yes that is the URL I'm sending the request too.

          Here is my callAping, which should be fine as like I said it works for other requests e.g. listMarkerTypes

          Code:
          url="https://api.betfair.com/exchange/betting/json-rpc/v1"
          
          def callAping(jsonrpc_req):
          
              try:
                  req = urllib.request.Request(url, jsonrpc_req.encode('utf-8'), headers)
                  response = urllib.request.urlopen(req)
                  jsonResponse = response.read()
                  return jsonResponse.decode('utf-8')
          
              except urllib.error.URLError as e:
                  print (e.reason)
                  print ('Oops no service available at ' + str(url))
                  exit()
              except urllib.error.HTTPError:
                  print ('Oops not a valid operation from the service ' + str(url))
                  exit()

          Comment

          • LiamP
            Junior Member
            • Oct 2015
            • 284

            #6
            Note that your request and Neil’s are different, or you can save yourself a lot of effort:

            https://github.com/liampauling/betfair

            Comment

            • Chris361
              Junior Member
              • Nov 2018
              • 3

              #7
              Originally posted by LiamP View Post
              Note that your request and Neil’s are different, or you can save yourself a lot of effort:

              https://github.com/liampauling/betfair
              Thanks - have corrected mistake and it now works. Will have a look at your option though as the Betfair API is a bit finicky!

              Comment

              Working...
              X