How to access Runner METAINFO

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • monkeymagix
    Junior Member
    • Jul 2010
    • 105

    #1

    How to access Runner METAINFO

    I am using the C# Api_ng_sample_code project as the basis to work from and build my own code.

    However I noticed that the MarketProjection definition didn't contain the RUNNER_METADATA parameter in it, so I added it e.g

    Code:
    [JsonConverter(typeof(StringEnumConverter))]
        public enum MarketProjection
        {
            COMPETITION, EVENT, EVENT_TYPE, MARKET_DESCRIPTION, RUNNER_DESCRIPTION, MARKET_START_TIME, [B]RUNNER_METADATA[/B]
        }
    Now when I call

    Code:
    ISet<MarketProjection> marketProjections = new HashSet<MarketProjection>();
    marketProjections.Add(MarketProjection.COMPETITION);                marketProjections.Add(MarketProjection.RUNNER_DESCRIPTION);
    marketProjections.Add(MarketProjection.COMPETITION);
    marketProjections.Add(MarketProjection.EVENT);
    marketProjections.Add(MarketProjection.EVENT_TYPE);                marketProjections.Add(MarketProjection.MARKET_START_TIME);
    marketProjections.Add(MarketProjection.RUNNER_METADATA);
    I don't get anything else in my results from this call apart from the usual e.g no runner meta info (silks etc)

    Code:
    var marketCatalogues = client.listMarketCatalogue(marketFilter, marketProjections, marketSort, maxResults);

    This is most certainly because the marketCatalouges definition doesn't provide any way for the runner metadata to be returned. The problem is I don't know HOW it is supposed to be formatted to add it in to the code.

    The current definition for marketCatalouges is:


    Code:
    public class MarketCatalogue
        {
            [JsonProperty(PropertyName = "marketId")]
            public string MarketId { get; set; }
    
            [JsonProperty(PropertyName = "marketStartTime")]
            public string MarketStartTime { get; set; }
    
            [JsonProperty(PropertyName = "marketName")]
            public string MarketName { get; set; }
    
            [JsonProperty(PropertyName = "isMarketDataDelayed")]
            public bool IsMarketDataDelayed { get; set; }
    
            [JsonProperty(PropertyName = "description")]
            public MarketDescription Description { get; set; }
    
            [JsonProperty(PropertyName = "runners")]
            public List<RunnerDescription> Runners { get; set; }
    
            [JsonProperty(PropertyName = "eventType")]
            public EventType EventType { get; set; }
    
            [JsonProperty(PropertyName = "event")]
            public Event Event { get; set; }
    
            [JsonProperty(PropertyName = "competition")]
            public Competition Competition { get; set; }
    
            public override string ToString()
            {
                // well, don't bother displaying event/event type/competition
                var sb = new StringBuilder().AppendFormat("{0}", "MarketCatalogue")
                            .AppendFormat(" : Market={0}[{1}]", MarketId, MarketName)
                            .AppendFormat(" : IsMarketDataDelayed={0}", IsMarketDataDelayed);
    
                if (Description != null)
                {
                    sb.AppendFormat(" : {0}", Description);
                }
    
                if (EventType != null)
                {
                    sb.AppendFormat(" : {0}", EventType);
                }
    
                if (Event != null)
                {
                    sb.AppendFormat(" : {0}", Event);
                }
    
                if (Competition != null)
                {
                    sb.AppendFormat(" : {0}", Competition);
                }
    
    
                if (Runners != null && Runners.Count > 0)
                {
                    int idx = 0;
                    foreach (var runner in Runners)
                    {
                        sb.AppendFormat(" : Runner[{0}]={1}", idx++, runner);                   
                    }
                }
    
                return sb.ToString();
            }
        }

    I have tried playing around with the Runners loop as I guess that is where the meta data will come from but I have had no luck getting anything to output.

    How am I supposed to reformat this method to return the meta data I need for silks and other runner meta information etc?

    Any help would be much appreciated. I really don't want to have to keep relying on screen scraping for this info!

    Thanks
  • gus
    Senior Member
    • Jan 2009
    • 134

    #2
    I'm using REST, so, I'm not sure how helpful it is, but, for what its worth, my params to listMarketCatalogue look like this:

    {"sort":"FIRST_TO_START","marketProjection":["MARKET_START_TIME","RUNNER_DESCRIPTION","EVENT_TY PE","RUNNER_METADATA","MA
    RKET_DESCRIPTION"],"maxResults":15,"filter":{"eventIds":["27060050"]}}


    and that definitely returns the METADATA, like so:

    {"WEIGHT_UNITS":"pounds","ADJUSTED_RATING":null,"D AM_YEAR_BORN":"2002","DAYS_SINCE_LAST_RUN":"40","W EARING":null,"SIRE_B
    RED":"UK","DAMSIRE_YEAR_BORN":"1987","TRAINER_NAME ":"Ronald Harris","STALL_DRAW":"1","SEX_TYPE":"g","SIRE_NAME ":"Pastora
    l Pursuits","OWNER_NAME":"Mr Balding & Ridge House Stables","FORECASTPRICE_NUMERATOR":"100","JOCKEY_C LAIM":null,"FORECAS
    TPRICE_DENOMINATOR":"1","WEIGHT_VALUE":"131","DAM_ NAME":"Palais Polaire","AGE":"2","COLOUR_TYPE":"ch","DAMSIRE_BRE D":"US
    A","DAMSIRE_NAME":"Polar Falcon","SIRE_YEAR_BORN":"2001","OFFICIAL_RATING": null,"BRED":"GB","FORM":"67","runnerId":"5508
    9004","JOCKEY_NAME":"Luke Morris","DAM_BRED":"UK","COLOURS_DESCRIPTION":"Bro wn, turquoise blue sleeves and cap.","COLOUR
    S_FILENAME":"c20130904lin\/00081952.jpg","CLOTH_NUMBER":"6"}


    so I can get the Silks for that runner from:

    http://content-cache.betfair.com/fee...n/00081952.jpg

    Comment

    • monkeymagix
      Junior Member
      • Jul 2010
      • 105

      #3
      Meta

      Hi

      Thanks for that.

      Yes it seems that the data is there and possible to get with simple REST calls but I would have thought the actual example libraries that the Betfair dev team wrote for people to make use of would have included all the features otherwise it's a bit hard when you are expecting to just pass a parameter like "RUNNER_METADATA" and get a load of info back but then find they haven't even implemented it.

      Frustrating.

      If I just knew the object it was derived from maybe I could hack the function but I just cannot seem to find any property or method in that code I posted which would allow me to access the data so I can return it in a format I can use.

      I have contacted BDP but I don't know if they will be able to help me.

      Thanks though - screen scraping will continue by the looks of things until I can sort it!

      Comment

      • gus
        Senior Member
        • Jan 2009
        • 134

        #4
        Well, my knowledge of C# is practically zero.

        I'm using Java and JSON.simple (the simple bit influenced my choice), but I don't see where in your code you're actually looking for the RUNNER_METADA from the returned marketCatalogue.

        In my code, once I've got the marketCatalogue, i simply (that word again!) 'unpack' it, and to get the info on each Runner i have (roughly):

        Code:
        String runnerName;
        JSONObject metadata;
        Long selectionId;
        JSONArray runnerList;
        
        if(marketCat.containsKey("runners"))
        	{
        		runnerList = (JSONArray)marketCat.get("runners");
        
        		if(runnerList != null)
        			{
        				JSONObject runner;
        
        				for(int i = 0; i < runnerList.size(); i++)
        					{
        						runner = (JSONObject)runnerList.get(i);
        						
        						if(runner.containsKey("runnerName"))
        							runnerName =  (String)runnerObject.get("runnerName");
        
        						if(runner.containsKey("selectionId"))
        							selectionId =  (Long)runnerObject.get("selectionId ");
        
        						if(runner.containsKey("metadata"))
        							{
        								metadata = (JSONObject)runner.get("metadata");
        								System.out.println(metadata);
        							}
        					}
        			}
        	}
        Last edited by gus; 04-09-2013, 04:10 PM. Reason: forgot to declare runnerList

        Comment

        • monkeymagix
          Junior Member
          • Jul 2010
          • 105

          #5
          I know

          I know that is the problem! I am using the actual Betfair API_ING example code for C# and it doesn't contain any code I can see for returning the RUNNER_METADATA. What I want to know is HOW I can change that code that they are using (this bit)

          Code:
          public class MarketCatalogue
              {
                  [JsonProperty(PropertyName = "marketId")]
                  public string MarketId { get; set; }
          
                  [JsonProperty(PropertyName = "marketStartTime")]
                  public string MarketStartTime { get; set; }
          
                  [JsonProperty(PropertyName = "marketName")]
                  public string MarketName { get; set; }
          
                  [JsonProperty(PropertyName = "isMarketDataDelayed")]
                  public bool IsMarketDataDelayed { get; set; }
          
                  [JsonProperty(PropertyName = "description")]
                  public MarketDescription Description { get; set; }
          
                  [JsonProperty(PropertyName = "runners")]
                  public List<RunnerDescription> Runners { get; set; }
          
                  [JsonProperty(PropertyName = "eventType")]
                  public EventType EventType { get; set; }
          
                  [JsonProperty(PropertyName = "event")]
                  public Event Event { get; set; }
          
                  [JsonProperty(PropertyName = "competition")]
                  public Competition Competition { get; set; }
          
                  public override string ToString()
                  {
                      // well, don't bother displaying event/event type/competition
                      var sb = new StringBuilder().AppendFormat("{0}", "MarketCatalogue")
                                  .AppendFormat(" : Market={0}[{1}]", MarketId, MarketName)
                                  .AppendFormat(" : IsMarketDataDelayed={0}", IsMarketDataDelayed);
          
                      if (Description != null)
                      {
                          sb.AppendFormat(" : {0}", Description);
                      }
          
                      if (EventType != null)
                      {
                          sb.AppendFormat(" : {0}", EventType);
                      }
          
                      if (Event != null)
                      {
                          sb.AppendFormat(" : {0}", Event);
                      }
          
                      if (Competition != null)
                      {
                          sb.AppendFormat(" : {0}", Competition);
                      }
          
          
                      if (Runners != null && Runners.Count > 0)
                      {
                          int idx = 0;
                          foreach (var runner in Runners)
                          {
                              sb.AppendFormat(" : Runner[{0}]={1}", idx++, runner);                   
                          }
                      }
          
                      return sb.ToString();
                  }
              }
          To return the runner meta data as at the moment it isn't and I don't know how to change it so that it does.

          This is my problem. I want to access the runner metadata but their sample code isn't including it. I already had to add the ENUM for it as that was missing in their market_projection code e.g

          Code:
          [JsonConverter(typeof(StringEnumConverter))]
              public enum MarketProjection
              {
                  COMPETITION, EVENT, EVENT_TYPE, MARKET_DESCRIPTION, RUNNER_DESCRIPTION, MARKET_START_TIME, [B]RUNNER_METADATA[/B]
              }
          So that bolded bit I had to add. But then I found it didn't actually do anything. So I delved deeper into their code and found their MarketCatalogue class and as you can see there is nothing to return the runner metadata. This is what I am trying to figure out - how to extend / edit their class so it returns this data. So far I have had no answer from BDP. I am just wondering if there are J++, C++ or VB.NET examples I could see and try and hack for c#??

          Comment

          • monkeymagix
            Junior Member
            • Jul 2010
            • 105

            #6
            Quick question, maybe if I can see the whole REST response from your marketCatalogue request (with all the event, competition AND runner metadata) then maybe I can work out the hierarchy of how the data is structured. At the moment I am trying to see if there are methods/properties on any of the objects I have in the API_ING marketCatalogue class but nothing lets me access the meta data.

            Comment

            • gus
              Senior Member
              • Jan 2009
              • 134

              #7
              OK:

              Here's the response for the Match Odds on a football match (the responses for Horse Races are too big to fit onto anything I can cut'n'paste on here, but the principle is presumably the same).

              The match is Stoke U21 v West Brom U21 tomorrow ... an event i know you're desperate to invest in.

              I've left out MARKET_DESCRIPTION from the query, just to simplify the response, so the Query looks like this:

              {"sort":"FIRST_TO_START","marketProjection":["MARKET_START_TIME","RUNNER_DESCRIPTION","EVENT_TY PE","RUNNER_METADATA"],"m
              axResults":28,"filter":{"eventIds":["27057986"]}}

              and the response looks like this:

              {"marketId":"1.110741182","marketName":"Match Odds","marketStartTime":"2013-09-05T13:00:00.000Z","runners":[{"selectionI
              d":6630666,"sortPriority":1,"handicap":0.0,"runner Name":"Stoke U21","metadata":{"runnerId":"54868297"}},{"selecti onId":6
              601846,"sortPriority":2,"handicap":0.0,"runnerName ":"West Brom U21","metadata":{"runnerId":"54868298"}},{"selecti onId":5
              8805,"sortPriority":3,"handicap":0.0,"runnerName": "The Draw","metadata":{"runnerId":"54868299"}}],"eventType":{"id":"1",
              "name":"Soccer"}}

              god knows what the runnerId in the metadata is all about, but at least there's something in metadata.

              Comment

              • betdynamics
                Junior Member
                • Sep 2010
                • 534

                #8
                You could try adding a new field to the RunnerCatalog class:

                Code:
                [JsonProperty(PropertyName = "metadata")]
                public Dictionary<string, string> Metadata { get; set; }
                Then when you deserialise the MarketCatalogue, you end up with the metadata for each runner in a dictionary object with each field accessible separately.

                You would still need to know what metadata is returned for each type of market that you were interested in, but I guess you could use the data visualiser to see what the metadata contains.
                Last edited by betdynamics; 06-09-2013, 12:58 PM.

                Comment

                • monkeymagix
                  Junior Member
                  • Jul 2010
                  • 105

                  #9
                  Thanks

                  Hi

                  I just got this message back from the BDP support team.
                  Hi Rob,

                  Thanks for contacting us and sorry for the extended delay in getting back to you regarding this issue.

                  The initial API sample code was created to provide guidance relating to the main API call functions (navigation, get prices, place bet, error handling) in as many languages as possible.

                  We do intend to create more comprehensive code libraries containing all API operations.

                  I have asked our development team to look at adding an example of a request, including RUNNER_METADATA, to the published C# sample code.

                  Kind Regards

                  Neil

                  Betfair Developer Program

                  So they haven't built an example yet and hopefully they will do soon!

                  Thanks

                  Comment

                  • monkeymagix
                    Junior Member
                    • Jul 2010
                    • 105

                    #10
                    RUNNER_METADATA Now in Example Code

                    Just thought I would let you all know that the BDP team have kindly put together a new example API_ING code base with an example of how to call and use the RUNNER_METADATA.

                    From their team

                    Hi Rob,

                    An example that include METADATA has now been added to the API-NG sample code.

                    https://github.com/betfair/API-NG-sample-code/

                    I hope this helps.

                    Kind Regards

                    Neil

                    Betfair Developer Program

                    Comment

                    Working...
                    X