Get ALL odds by event ID (PHP)

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Jake
    Junior Member
    • Aug 2019
    • 5

    #1

    Get ALL odds by event ID (PHP)

    Hi guys,

    I've created a function that displays all of the event IDs that are currently in play... what I want to do now is display all of the odds associated with that event ID.

    I've taken a look at listMarketCatalogue, but it returns an error for me.

    Any ideas on what endpoint to use and what filters?

    Thanks.
  • geoffw123
    Senior Member
    • Mar 2014
    • 250

    #2
    Hiya

    Your question is ambiguous, you are either using the wrong terminology, or you have misunderstood something fundamental. For example

    This Saturday's Arsenal v Burnley footy match has a single eventId = 29357696. For this single event there may be 40 or 50 separate markets, eg Match Odds, Correct Score, etc etc. For the Match Odds market it has a marketId = 1.160286846.

    To get Odds you need to tell Betfair which market you are interested in by sending the marketId using the listMarketBook API method.

    The listMarketCatalogue API methold you mentioned returns info about that event, but does not return odds
    You can send listMarketCatalogue either eventIds, or marketIds. If for example we sent it eventId = 29357696 then it would return 40 or 50 different markets associated with that event. (One of which would be Match Odds: marketId = 1.160286846.)

    Regards Geoff

    Comment

    • Jake
      Junior Member
      • Aug 2019
      • 5

      #3
      I understand that. However, I just get an error by doing this here:

      $params = '{"filter":{"eventTypeIds":["1"],
      "marketStartTime":{"from":"'.$DateTime->format("Y-m-d").'T'.$DateTime->format("H:i:s").'+00:00'.'"}},
      "inPlayOnly": true,
      "maxResults":"1000",
      "marketProjection":["EVENT"],
      "eventIds":[29118496]
      "id":1}';

      I only want to get the markets for in-play games.

      Comment

      • jabe
        Senior Member
        • Dec 2014
        • 705

        #4
        What are you trying to get with that call?

        What does the error say?

        Why is there no comma after the "eventIds" parameter?

        Comment

        • geoffw123
          Senior Member
          • Mar 2014
          • 250

          #5
          Hi

          You need to post a valid JSON snippet that you are sending down the wires to debug it. Here is an example for you

          Code:
          {"jsonrpc":"2.0","method":"SportsAPING/v1.0/listMarketCatalogue","params":{"filter":{"eventTypeIds":["7"],"eventIds":[],"marketIds":[],"marketCountries":["GB","IE"],"marketTypeCodes":["WIN"],"marketStartTime":{"from":"2019-08-15T23:00:00Z","to":"2019-08-16T23:00:00Z"}},"marketProjection":["EVENT","EVENT_TYPE","MARKET_START_TIME","COMPETITION","MARKET_DESCRIPTION"],"sort":"FIRST_TO_START","maxResults":"1000","locale":null},"id":1}
          if you paste that string into a JSON viewer like http://jsonviewer.stack.hu/ you will see that it validates OK, your example doesnt.

          The above snippet returns all todays horse racing Win markets for UK and Ireland.

          Hope that helps ?

          Geoff
          Last edited by geoffw123; 16-08-2019, 02:50 PM.

          Comment

          • Jake
            Junior Member
            • Aug 2019
            • 5

            #6
            Originally posted by geoffw123 View Post
            Hi

            You need to post a valid JSON snippet that you are sending down the wires to debug it. Here is an example for you

            Code:
            {"jsonrpc":"2.0","method":"SportsAPING/v1.0/listMarketCatalogue","params":{"filter":{"eventTypeIds":["7"],"eventIds":[],"marketIds":[],"marketCountries":["GB","IE"],"marketTypeCodes":["WIN"],"marketStartTime":{"from":"2019-08-15T23:00:00Z","to":"2019-08-16T23:00:00Z"}},"marketProjection":["EVENT","EVENT_TYPE","MARKET_START_TIME","COMPETITION","MARKET_DESCRIPTION"],"sort":"FIRST_TO_START","maxResults":"1000","locale":null},"id":1}
            if you paste that string into a JSON viewer like http://jsonviewer.stack.hu/ you will see that it validates OK, your example doesnt.

            The above snippet returns all todays horse racing Win markets for UK and Ireland.

            Hope that helps ?

            Geoff
            I'm trying to get all the current markets for all in play football games!

            When I'm doing it, it's literally just returning games that aren't even in play right now. What kind of from and to date should I look at when trying to get in-play footy games?

            Comment

            • geoffw123
              Senior Member
              • Mar 2014
              • 250

              #7
              Hi

              I am guessing you are missing the inPlayOnly flag

              This snippet works, you can see where it needs to go
              Code:
              {"jsonrpc":"2.0","method":"SportsAPING/v1.0/listMarketCatalogue","params":{"filter":{"eventTypeIds":["1"],"eventIds":[],"marketIds":[],"inPlayOnly":true,"marketCountries":[],"marketTypeCodes":["MATCH_ODDS"],"marketStartTime":{"from":"2019-08-16T23:00:00Z","to":"2019-08-17T23:00:00Z"}},"marketProjection":["EVENT","EVENT_TYPE","MARKET_START_TIME","COMPETITION"],"sort":"FIRST_TO_START","maxResults":"1000","locale":null},"id":1}
              Geoff

              Comment

              • Jake
                Junior Member
                • Aug 2019
                • 5

                #8
                Originally posted by geoffw123 View Post
                Hi

                I am guessing you are missing the inPlayOnly flag

                This snippet works, you can see where it needs to go
                Code:
                {"jsonrpc":"2.0","method":"SportsAPING/v1.0/listMarketCatalogue","params":{"filter":{"eventTypeIds":["1"],"eventIds":[],"marketIds":[],"inPlayOnly":true,"marketCountries":[],"marketTypeCodes":["MATCH_ODDS"],"marketStartTime":{"from":"2019-08-16T23:00:00Z","to":"2019-08-17T23:00:00Z"}},"marketProjection":["EVENT","EVENT_TYPE","MARKET_START_TIME","COMPETITION"],"sort":"FIRST_TO_START","maxResults":"1000","locale":null},"id":1}
                Geoff
                Just tried this, this is the response:

                Code:
                Array ( [0] => Array ( [jsonrpc] => 2.0 [result] => Array ( ) [id] => 1 ) )

                Comment

                • jabe
                  Senior Member
                  • Dec 2014
                  • 705

                  #9
                  Once you've got the relevant football MarketCatalogues, I believe you'll need to loop through them to get the related MarketBooks.

                  Comment

                  Working...
                  X