listEvents question

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Keyser
    Junior Member
    • Dec 2013
    • 6

    #1

    listEvents question

    Hello,

    I am listing all football events for the Premier League, but it is also returning some events that I don't want (the ones in bold)

    using :

    var requestFilters = '{"filter":{"competitionIds":["' + competitionId + '"]}}';
    var jsonRequest = constructJsonRpcRequest('listEvents', requestFilters );

    (competitionId = 31 (Premier League))

    How do I filter so that I only receive the actual football matches? I've looked at the marketFilter parameters but nothing seems an obvious candidate

    Sorry for the beginner questions

    Thanks

    { event:
    { id: '2022802',
    name: 'Barclays Premier League',
    countryCode: 'GB',
    timezone: 'Europe/London',
    openDate: '2013-08-17T11:45:00.000Z' },
    marketCount: 22 }

    { event:
    { id: '27112895',
    name: 'Man City v Arsenal',
    countryCode: 'GB',
    timezone: 'Europe/London',
    openDate: '2013-12-14T12:45:00.000Z' },
    marketCount: 81 }
    { event:
    { id: '27112894',
    name: 'West Ham v Sunderland',
    countryCode: 'GB',
    timezone: 'Europe/London',
    openDate: '2013-12-14T15:00:00.000Z' },
    marketCount: 81 }
    { event:
    { id: '19478157',
    name: 'Head to Head Leagues',
    countryCode: 'GB',
    timezone: 'Europe/London',
    openDate: '2012-08-18T11:45:00.000Z' },
    marketCount: 5 }

    { event:
    { id: '5767793',
    name: 'Season Match Bets',
    countryCode: 'GB',
    timezone: 'Europe/London',
    openDate: '2012-08-18T14:00:00.000Z' },
    marketCount: 18 }
    { event:
    { id: '27049196',
    name: '3pm Kick-off Specials',
    countryCode: 'GB',
    timezone: 'Europe/London',
    openDate: '2013-12-14T15:00:00.000Z' },
    marketCount: 7 }

    { event:
    { id: '27113215',
    name: 'Norwich v Swansea',
    countryCode: 'GB',
    timezone: 'Europe/London',
    openDate: '2013-12-15T13:30:00.000Z' },
    marketCount: 81 }
    { event:
    { id: '27113214',
    name: 'Aston Villa v Man Utd',
    countryCode: 'GB',
    timezone: 'Europe/London',
    openDate: '2013-12-15T13:30:00.000Z' },
    marketCount: 80 }
    { event:
    { id: '27113213',
    name: 'Tottenham v Liverpool',
    countryCode: 'GB',
    timezone: 'Europe/London',
    openDate: '2013-12-15T16:00:00.000Z' },
    marketCount: 81 }
    { event:
    { id: '27112898',
    name: 'Everton v Fulham',
    countryCode: 'GB',
    timezone: 'Europe/London',
    openDate: '2013-12-14T15:00:00.000Z' },
    marketCount: 80 }
    { event:
    { id: '27112899',
    name: 'Hull v Stoke',
    countryCode: 'GB',
    timezone: 'Europe/London',
    openDate: '2013-12-14T17:30:00.000Z' },
    marketCount: 81 }
    { event:
    { id: '27112896',
    name: 'Chelsea v C Palace',
    countryCode: 'GB',
    timezone: 'Europe/London',
    openDate: '2013-12-14T15:00:00.000Z' },
    marketCount: 80 }
    { event:
    { id: '27112897',
    name: 'Cardiff v West Brom',
    countryCode: 'GB',
    timezone: 'Europe/London',
    openDate: '2013-12-14T15:00:00.000Z' },
    marketCount: 81 }
    { event:
    { id: '27112902',
    name: 'Newcastle v Southampton',
    countryCode: 'GB',
    timezone: 'Europe/London',
    openDate: '2013-12-14T15:00:00.000Z' },
    marketCount: 81 }
  • gus
    Senior Member
    • Jan 2009
    • 134

    #2
    One way to do it is to set the "to" field to the number of days' matches you want, and also to set the "turnInPlay" field to "true" e.g.

    https://api.betfair.com/exchange/betting/rest/v1.0/listEvents/{"filter":{"marketStartTime":{"to":"2013-12-18T00:0
    0:00.904Z","
    from":"2013-12-12T00:00:00.904Z"},"marketCountries":["GB","IE"],"turnInPlayEnabled":true,"competitionIds":[3
    1]}}
    to be honest I'm not sure which of those params has the desired effect, quite possibly it's the turnInPlay one
    and of course it assumes that you'll always know how many days in advance you want,so there may be better solutions, but that's what I do, and from that query/filter i get only the actual football matches:


    Code:
    [{"event":{"id":"27113215","name":"Norwich v Swansea","countryCode":"GB","timezone":"Europe/London","openDate":"2013-12-
    15T13:30:00.000Z"},"marketCount":58},{"event":{"id":"27113214","name":"Aston Villa v Man Utd","countryCode":"GB","timezo
    ne":"Europe/London","openDate":"2013-12-15T13:30:00.000Z"},"marketCount":57},{"event":{"id":"27113213","name":"Tottenham
     v Liverpool","countryCode":"GB","timezone":"Europe/London","openDate":"2013-12-15T16:00:00.000Z"},"marketCount":58},{"e
    vent":{"id":"27112895","name":"Man City v Arsenal","countryCode":"GB","timezone":"Europe/London","openDate":"2013-12-14T
    12:45:00.000Z"},"marketCount":58},{"event":{"id":"27112894","name":"West Ham v Sunderland","countryCode":"GB","timezone"
    :"Europe/London","openDate":"2013-12-14T15:00:00.000Z"},"marketCount":58},{"event":{"id":"27112898","name":"Everton v Fu
    lham","countryCode":"GB","timezone":"Europe/London","openDate":"2013-12-14T15:00:00.000Z"},"marketCount":57},{"event":{"
    id":"27112899","name":"Hull v Stoke","countryCode":"GB","timezone":"Europe/London","openDate":"2013-12-14T17:30:00.000Z"
    },"marketCount":58},{"event":{"id":"27112896","name":"Chelsea v C Palace","countryCode":"GB","timezone":"Europe/London",
    "openDate":"2013-12-14T15:00:00.000Z"},"marketCount":57},{"event":{"id":"27112897","name":"Cardiff v West Brom","country
    Code":"GB","timezone":"Europe/London","openDate":"2013-12-14T15:00:00.000Z"},"marketCount":58},{"event":{"id":"27112902"
    ,"name":"Newcastle v Southampton","countryCode":"GB","timezone":"Europe/London","openDate":"2013-12-14T15:00:00.000Z"},"
    marketCount":58}]
    Last edited by gus; 12-12-2013, 11:06 AM. Reason: forgot about turnInPlay

    Comment

    • Daggg
      Junior Member
      • Nov 2013
      • 7

      #3
      Filtering

      Code:
      $pid = 31;
      $date_from = '2013-12-12T00:00:00.000Z';
      $date_to = "2013-12-15T00:00:00.000Z";
      $mcountr = '"GB","IE"';
      $tipEn = 'false';
      //---- Gus sample
      $params = '{"filter":{
      	"competitionIds":['.$pid.'],
      	"marketStartTime":{
      		"from":"'.$date_from.'",
      		"to":"'.$date_to.'"
      		},
      	"marketCountries":['.$mcountr.'],
      	"turnInPlayEnabled":'.$tipEn.'
      	}}';
      Works as charm! Thanks Gus.
      Both of them: 'from'->'to' and 'turnInPlayEnabled' works separately as expected (as should).

      1. Gus, is it possible to list Competitions without ID1?
      This works:
      Code:
      $params = '{"filter":{"competitionId":["1"]}}';
      $zapros = sportsApingRequest($AppKey, $SesTok, 'listCompetitions', $params);
      but this not:
      Code:
      $params = '{"filter":{[]}}';
      $zapros = sportsApingRequest($AppKey, $SesTok, 'listCompetitions', $params);
      2. There are many CompetitionID equal to EventId. I can't imagine that BF table has the same numbers (IDs) in various columns(?).

      3. Just notice and were shocked (again); they have
      competitionsId and competitionIds... very tricky... didn't notice about other Id(s) (eventTypeIds for example...). Any page were BG JSON syntax is explained (or full list of all vars)?

      Are you sure about IE in Barclays league? No IE event in my results for Barclays id 31.

      Comment

      • gus
        Senior Member
        • Jan 2009
        • 134

        #4
        is it possible to list Competitions without ID1?s
        I just tried it in the Visualiser, and it does work with an empty filter, but it's a helluva long list!

        I think your query should have the filter:

        $params = '{"filter":{}}';

        not

        $params = '{"filter":{[]}}';

        IE was in the query because i was also listing Irish football, higher up in menu so, if you already know the competionIds, you probably don't need the marketCountries parameter at all.

        all the API-NG variables are in the Reference Guide, but not in one long list

        Comment

        • Keyser
          Junior Member
          • Dec 2013
          • 6

          #5
          Originally posted by gus View Post
          One way to do it is to set the "to" field to the number of days' matches you want, and also to set the "turnInPlay" field to "true" e.g.

          https://api.betfair.com/exchange/betting/rest/v1.0/listEvents/{"filter":{"marketStartTime":{"to":"2013-12-18T00:0
          0:00.904Z","
          from":"2013-12-12T00:00:00.904Z"},"marketCountries":["GB","IE"],"turnInPlayEnabled":true,"competitionIds":[3
          1]}}
          to be honest I'm not sure which of those params has the desired effect, quite possibly it's the turnInPlay one
          and of course it assumes that you'll always know how many days in advance you want,so there may be better solutions, but that's what I do, and from that query/filter i get only the actual football matches:


          Code:
          [{"event":{"id":"27113215","name":"Norwich v Swansea","countryCode":"GB","timezone":"Europe/London","openDate":"2013-12-
          15T13:30:00.000Z"},"marketCount":58},{"event":{"id":"27113214","name":"Aston Villa v Man Utd","countryCode":"GB","timezo
          ne":"Europe/London","openDate":"2013-12-15T13:30:00.000Z"},"marketCount":57},{"event":{"id":"27113213","name":"Tottenham
           v Liverpool","countryCode":"GB","timezone":"Europe/London","openDate":"2013-12-15T16:00:00.000Z"},"marketCount":58},{"e
          vent":{"id":"27112895","name":"Man City v Arsenal","countryCode":"GB","timezone":"Europe/London","openDate":"2013-12-14T
          12:45:00.000Z"},"marketCount":58},{"event":{"id":"27112894","name":"West Ham v Sunderland","countryCode":"GB","timezone"
          :"Europe/London","openDate":"2013-12-14T15:00:00.000Z"},"marketCount":58},{"event":{"id":"27112898","name":"Everton v Fu
          lham","countryCode":"GB","timezone":"Europe/London","openDate":"2013-12-14T15:00:00.000Z"},"marketCount":57},{"event":{"
          id":"27112899","name":"Hull v Stoke","countryCode":"GB","timezone":"Europe/London","openDate":"2013-12-14T17:30:00.000Z"
          },"marketCount":58},{"event":{"id":"27112896","name":"Chelsea v C Palace","countryCode":"GB","timezone":"Europe/London",
          "openDate":"2013-12-14T15:00:00.000Z"},"marketCount":57},{"event":{"id":"27112897","name":"Cardiff v West Brom","country
          Code":"GB","timezone":"Europe/London","openDate":"2013-12-14T15:00:00.000Z"},"marketCount":58},{"event":{"id":"27112902"
          ,"name":"Newcastle v Southampton","countryCode":"GB","timezone":"Europe/London","openDate":"2013-12-14T15:00:00.000Z"},"
          marketCount":58}]
          thanks Gus, i was intending to add the date range

          turnInPlayEnabled doesn't seem to be working for me, i cut and pasted your filter and it correctly restricts the list by date (thanks) but still includes 2 events that i don't want "Fixtures 14th December" and "Fixtures 15th December" in bold below

          having said that, i've tried it with the visualizer and it returns them as well http://i39.tinypic.com/2eebrds.png
          , it would be nice to just have a list of events that are just single events, on a different level of granularity maybe

          appreciate your help

          edit : I played around with the visualizer a bit more and if you select "Betting Types : ODDS" it returns only the games i wanted presumably because they have odds associated to them, so I added marketBettingTypes":["ODDS"] to the filter and it works sorry about the fragmented reply, i was trying stuff as i typed it, cheers

          { event:
          { id: '27113215',
          name: 'Norwich v Swansea',
          countryCode: 'GB',
          timezone: 'Europe/London',
          openDate: '2013-12-15T13:30:00.000Z' },
          marketCount: 58 }
          { event:
          { id: '27112893',
          name: 'Fixtures 14 December ',
          countryCode: 'GB',
          timezone: 'Europe/London',
          openDate: '2013-12-14T15:00:00.000Z' },
          marketCount: 1 }
          { event:
          { id: '27113214',
          name: 'Aston Villa v Man Utd',
          countryCode: 'GB',
          timezone: 'Europe/London',
          openDate: '2013-12-15T13:30:00.000Z' },
          marketCount: 57 }
          { event:
          { id: '27113213',
          name: 'Tottenham v Liverpool',
          countryCode: 'GB',
          timezone: 'Europe/London',
          openDate: '2013-12-15T16:00:00.000Z' },
          marketCount: 58 }
          { event:
          { id: '27112895',
          name: 'Man City v Arsenal',
          countryCode: 'GB',
          timezone: 'Europe/London',
          openDate: '2013-12-14T12:45:00.000Z' },
          marketCount: 58 }
          { event:
          { id: '27113212',
          name: 'Fixtures 15 December ',
          countryCode: 'GB',
          timezone: 'Europe/London',
          openDate: '2013-12-15T16:00:00.000Z' },
          marketCount: 1 }
          { event:
          { id: '27112894',
          name: 'West Ham v Sunderland',
          countryCode: 'GB',
          timezone: 'Europe/London',
          openDate: '2013-12-14T15:00:00.000Z' },
          marketCount: 58 }
          { event:
          { id: '27112898',
          name: 'Everton v Fulham',
          countryCode: 'GB',
          timezone: 'Europe/London',
          openDate: '2013-12-14T15:00:00.000Z' },
          marketCount: 57 }
          { event:
          { id: '27112899',
          name: 'Hull v Stoke',
          countryCode: 'GB',
          timezone: 'Europe/London',
          openDate: '2013-12-14T17:30:00.000Z' },
          marketCount: 58 }
          { event:
          { id: '27112896',
          name: 'Chelsea v C Palace',
          countryCode: 'GB',
          timezone: 'Europe/London',
          openDate: '2013-12-14T15:00:00.000Z' },
          marketCount: 57 }
          { event:
          { id: '27112897',
          name: 'Cardiff v West Brom',
          countryCode: 'GB',
          timezone: 'Europe/London',
          openDate: '2013-12-14T15:00:00.000Z' },
          marketCount: 58 }
          { event:
          { id: '27112902',
          name: 'Newcastle v Southampton',
          countryCode: 'GB',
          timezone: 'Europe/London',
          openDate: '2013-12-14T15:00:00.000Z' },
          marketCount: 58 }

          Comment

          • raptorjr
            Junior Member
            • May 2013
            • 8

            #6
            I'll add another question about listEvents.

            Even though i set to/from date and turn in play enabled in the visualizer i get events outside my date/time range. See attached picture.

            How do i get only the games for today, the same list that is shown on the Betfair webpage?

            Comment

            • betdynamics
              Junior Member
              • Sep 2010
              • 534

              #7
              I think the list may be correct.

              The display shows when the market is OPENED, not when the event starts - so if you were to take one of the Daily Goals events, and retrieve the information for that, then I think you may find that the market START time is between your two specified date/times.

              Not 100% sure, but it is easy enough to check with the visualiser.

              Comment

              • raptorjr
                Junior Member
                • May 2013
                • 8

                #8
                Yes, you were right. The start time is inside my time range. So it is not a bug. And if it was possible to search on Open Date it would have been included on the 25th.

                But that leaves the question, how do i get a list without those entries? I want a list that looks like the one on the webpage. I could do it in code but it would be much easier if it was possible to get it from the API.

                Comment

                • betdynamics
                  Junior Member
                  • Sep 2010
                  • 534

                  #9
                  Use the Navigation data? - see https://api.developer.betfair.com/se...r+Applications

                  Comment

                  Working...
                  X