Open zydjohnHotmail opened 2 days ago
The information from Betfair is returned in the response from the call to await client.MarketCatalogue(filter, query);
. Apologies, I didn't make that clear in my last reply.
So you should do something like this:
var credentials = new Credentials(UserName, Password, APIKey);
using var client = new BetfairApiClient(credentials);
var filter = new ApiMarketFilter()
.WithMarketTypes(MarketType.Win)
.WithCountries(Country.UnitedKingdom, Country.Ireland)
.WithEventTypes(EventType.GreyhoundRacing)
.FromMarketStart(DateTimeOffset.UtcNow)
.ToMarketStart(DateTimeOffset.UtcNow.AddDays(1));
var query = new MarketCatalogueQuery()
.Include(MarketProjection.Event)
.Include(MarketProjection.MarketStartTime)
.Include(MarketProjection.RunnerDescription);
var marketCatalogues = await client.MarketCatalogue(filter, query);
Debug.Print(JsonConvert.SerializeObject(marketCatalogues));
foreach (var market in marketCatalogues)
{
// Process each market.
}
The MarketCatalogueQuery()
object is the query sent to Betfair. It does not contain any response data. It is equivalent to the MarketProjection in the request you are sending to Betfair in your current code "marketProjection":["MARKET_START_TIME","RUNNER_DESCRIPTION","EVENT"]
.
If you do want to output that query to the debug window though, you just need to serialize it into a string first.
Let me know if you need more info.
Hi, Do you have code to receive the response, like this response: {"jsonrpc":"2.0","result":[{"marketId":"1.236266850","marketName":"A7 415m","marketStartTime":"2024-11-22T10:32:00.000Z","totalMatched":4.8028,"runners":[{"selectionId":55301333,"runnerName":"1. Foxwood Cardi","handicap":0.0,"sortPriority":1},{"selectionId":50748735,"runnerName":"2. Roscrea Karen","handicap":0.0,"sortPriority":2},{"selectionId":75235674,"runnerName":"3. Do It Bono","handicap":0.0,"sortPriority":3},{"selectionId":72963396,"runnerName":"4. Blazeaway Kiss","handicap":0.0,"sortPriority":4},
By the way, I think it is strange, today is Friday, so there were quite a number of Irish greyhound races, as I can see the from this url: https://www.grireland.ie/racing/upcoming-race-cards/ But all returned 158 races are from UK. Ireland should have at least 90 or nearly 100 races, but the response returned no such races at all. Can you check your code, just return some greyhound races in Ireland? But I want you show me the code to see the response in json format, not only the request in json format. Thanks,
Hi, Basically, I understand how to use your repo to do the job, but still I have some question about the returned results. Here is the json format request I made via Postman HTTP request, the payload: { "jsonrpc": "2.0", "method": "SportsAPING/v1.0/listMarketCatalogue", "params": { "filter": { "eventTypeIds": [ "4339" ], "marketCountries": [ "IE", "GB" ], "marketTypeCodes": [ "WIN" ], "marketStartTime": { "from": "2024-11-22T23:59:00+00:00", "to": "2024-11-23T23:59:00+00:00" } }, "maxResults": "300", "marketProjection": [ "MARKET_START_TIME", "RUNNER_DESCRIPTION", "EVENT" ] }, "id": 1 } => From the returned results, both from your repo & Postman HTTP response, I can see there are 181 greyhound races, only 12 races are from Ireland in one greyhound race course: Shelbourne Park However, according to this web page: https://www.grireland.ie/racing/upcoming-race-cards/ There are the following Irish greyhound race courses have races on November 23, 2024: 23-Nov-24 - Limerick 23-Nov-24 - Tralee 23-Nov-24 - Mullingar 23-Nov-24 - Dundalk 23-Nov-24 - Shelbourne Park 23-Nov-24 - Waterford 23-Nov-24 - Galway 23-Nov-24 - Drumbo Park 23-Nov-24 - Youghal 23-Nov-24 - Lifford 23-Nov-24 - Curraheen Park
=> But API returned results contained only one greyhound race course, but actually, total 11 Irish greyhound race courses have races on 23-Nov-2024, the API return only 1, but missing 10 Irish greyhound race courses' races, is there any issue with the API?
The issue is that Betfair does not cover every single Irish Greyhound race. If you check the Betfair website you'll see they only list one venue on 23-Nov, Shelbourne.
Hi, Thanks for your reply to my last issue. I show you my current code according to your code sample: private async void BetfairDogRaces1Day() { var credentials = new Credentials(UserName, Password, APIKey); using var client = new BetfairApiClient(credentials); var filter = new ApiMarketFilter() .WithMarketTypes(MarketType.Win) .WithCountries(Country.UnitedKingdom, Country.Ireland) .WithEventTypes(EventType.GreyhoundRacing) .FromMarketStart(DateTimeOffset.UtcNow) .ToMarketStart(DateTimeOffset.UtcNow.AddDays(1));
However, from debug window, I can't see any useful data. But I show you what I want to get from the Betfair API endpoint, here is my current code using HTTPS post request: public class DataStructure { public class BetfairResponse
{
public string Jsonrpc { get; set; }
public List Result { get; set; }
public int Id { get; set; }
}
=> The only thing different is that I create a dictionary to use first 3-letter as trackCode for each greyhound race course in both UK & Ireland.
The following is the json payload to request one day's greyhound race fixture: {"jsonrpc":"2.0","method":"SportsAPING/v1.0/listMarketCatalogue","params":{"filter":{"eventTypeIds":["4339"],"marketCountries":["GB","IE"],"marketTypeCodes":["WIN"],"marketStartTime":{"from":"2024-11-22T00:00:00Z","to":"2024-11-23T07:20:10Z"}},"maxResults":"300","marketProjection":["MARKET_START_TIME","RUNNER_DESCRIPTION","EVENT"]},"id":1}
=> The response looks like this: {"jsonrpc":"2.0","result":[{"marketId":"1.236266850","marketName":"A7 415m","marketStartTime":"2024-11-22T10:32:00.000Z","totalMatched":4.8028,"runners":[{"selectionId":55301333,"runnerName":"1. Foxwood Cardi","handicap":0.0,"sortPriority":1},{"selectionId":50748735,"runnerName":"2. Roscrea Karen","handicap":0.0,"sortPriority":2},{"selectionId":75235674,"runnerName":"3. Do It Bono","handicap":0.0,"sortPriority":3},{"selectionId":72963396,"runnerName":"4. Blazeaway Kiss","handicap":0.0,"sortPriority":4},{"selectionId":50748734,"runnerName":"5. Dunbolg Sif","handicap":0.0,"sortPriority":5},{"selectionId":42150090,"runnerName":"6. Keplar Isis","handicap":0.0,"sortPriority":6}],"event":{"id":"33805168","name":"Harlow 22nd Nov","countryCode":"GB","timezone":"Europe/London","venue":"Harlow","openDate":"2024-11-22T10:32:00.000Z"}},{"marketId":"1.236266852","marketName":"D5 238m","marketStartTime":"2024-11-22T10:48:00.000Z","totalMatched":42.64886400000001,"runners":[{"selectionId":61041122,"runnerName":"1. Chilteen Joy","handicap":0.0,"sortPriority":1},{"selectionId":43659624,"runnerName":"2. Glasmeen Tina","handicap":0.0,"sortPriority":2},{"selectionId":70869383,"runnerName":"3. Most Interesting","handicap":0.0,"sortPriority":3},{"selectionId":73964706,"runnerName":"4. Tousers Lad","handicap":0.0,"sortPriority":4},{"selectionId":62670031,"runnerName":"5. Buff Egan","handicap":0.0,"sortPriority":5},{"selectionId":43998090,"runnerName":"6. Burgess Mentor","handicap":0.0,"sortPriority":6}],"event":{"id":"33805168","name":"Harlow 22nd Nov","countryCode":"GB","timezone":"Europe/London","venue":"Harlow","openDate":"2024-11-22T10:32:00.000Z"}},{"marketId":"1.236266641","marketName":"A7 500m","marketStartTime":"2024-11-22T11:01:00.000Z","totalMatched":130.131866,"runners":[{"selectionId":52391251,"runnerName":"1. Insane Simone","handicap":0.0,"sortPriority":1},{"selectionId":57194876,"runnerName":"2. Antigua Anna","handicap":0.0,"sortPriority":2},{"selectionId":67127936,"runnerName":"3. Fatboy Stu","handicap":0.0,"sortPriority":3},{"selectionId":54380251,"runnerName":"4. Punk Rock => But I have to write rather complicated logic to parse the greyhound races fixture to get useful information. If you can provide some example to use your repo/Nuget package to get necessary information, then it will be much helpful. I show you some records I saved in SQL Server data table, but you don't have to use SQL Server database, just return a list of tuple, corresponding to the SQL Server data table is enough. Here is the data table design code: CREATE TABLE [dbo].[RaceFixture]( [Bookie] nvarchar NOT NULL, [Category] [int] NOT NULL, [CountryCode] nvarchar NOT NULL, [EventID] nvarchar NOT NULL, [MarketID] nvarchar NOT NULL, [MarketName] nvarchar NOT NULL, [RaceID] [int] NOT NULL, [RaceMeters] [int] NOT NULL, [TrackCode] nvarchar NOT NULL, [TrackName] nvarchar NOT NULL, [StartsGMT] [datetime] NOT NULL, CONSTRAINT [PK_RaceFixture] PRIMARY KEY CLUSTERED ( [Bookie] ASC, [EventID] ASC, [MarketID] ASC, [RaceID] ASC, [TrackCode] ASC, [StartsGMT] ASC) WITH (PAD_INDEX=OFF,STATISTICS_NORECOMPUTE=OFF,IGNORE_DUP_KEY=OFF,ALLOW_ROW_LOCKS=ON,ALLOW_PAGE_LOCKS=ON) ON [PRIMARY] )ON [PRIMARY] GO => RaceID is the order for each race during the day for the same greyhound race course, so its value can be: 1, 2, 3, 4, 5, 6, 7, 8, etc. RaceMeter is the distance of each race.
CREATE TABLE [dbo].[RunnerIDSelection]( [Bookie] nvarchar NOT NULL, [Category] nvarchar NOT NULL, [JsonRunners] nvarcharNOT NULL, [MarketID] nvarchar NOT NULL, [RaceID] [int] NOT NULL, [RaceDate] [DateTime] NOT NULL, [TrackCode] nvarchar NOT NULL, [TrackName] nvarchar NOT NULL, CONSTRAINT [PK_RunnerIDSelection] PRIMARY KEY CLUSTERED ( [Bookie] ASC, [MarketID] ASC, [RaceID] ASC, [TrackCode] ASC ) WITH(PAD_INDEX=OFF,STATISTICS_NORECOMPUTE=OFF,IGNORE_DUP_KEY=OFF,ALLOW_ROW_LOCKS=ON, ALLOW_PAGE_LOCKS=ON, OPTIMIZE_FOR_SEQUENTIAL_KEY=OFF)ON [PRIMARY] )ON [PRIMARY] GO => I want to use NewTonSoft.json to serialize all the dogs in one race. I show you some records for this table: SELECT * FROM RunnerIDSelection Bookie Category JsonRunners MarketID RaceID RaceDate TrackCode TrackName Betfair Greyhound [{"DogID":1,"SelectionID":52391251,"DogName":"Insane Simone"},{"DogID":2,"SelectionID":57194876,"DogName":"Antigua Anna"},{"DogID":3,"SelectionID":67127936,"DogName":"Fatboy Stu"},{"DogID":4,"SelectionID":54380251,"DogName":"Punk Rock Zelda"},{"DogID":5,"SelectionID":70217730,"DogName":"Sullane Biscuit"},{"DogID":6,"SelectionID":72455527,"DogName":"Pocket Penny"}] 1.236266641 1 2024-11-22 11:01:00.000 GBHOV Hove
The JsonRunners is something like this: [{"DogID":1,"SelectionID":52391251,"DogName":"Insane Simone"},{"DogID":2,"SelectionID":57194876,"DogName":"Antigua Anna"},{"DogID":3,"SelectionID":67127936,"DogName":"Fatboy Stu"},{"DogID":4,"SelectionID":54380251,"DogName":"Punk Rock Zelda"},{"DogID":5,"SelectionID":70217730,"DogName":"Sullane Biscuit"},{"DogID":6,"SelectionID":72455527,"DogName":"Pocket Penny"}]
I show you some records from data table [RaceFixture] SELECT * FROM RaceFixture Bookie Category CountryCode EventID MarketID MarketName RaceID RaceMeters TrackCode TrackName StartsGMT Betfair 4339 GB 33805140 1.236266641 A7 500m 1 500 GBHOV Hove 2024-11-22 11:01:00.000 Betfair 4339 GB 33805140 1.236266643 D2 285m 2 285 GBHOV Hove 2024-11-22 11:18:00.000 Betfair 4339 GB 33805140 1.236266645 A5 500m 3 500 GBHOV Hove 2024-11-22 11:34:00.000
=> I got total 159 races for today, unfortunately, none of them is from Ireland, I think maybe tomorrow, I can get some races from Ireland. So daily races count is around 140 to 160, averagely around 150, but in Weekend, if there are some Irish races, then the number could be more than 200; so I think a better to add more conditions, in Weekend, try to list UK & Irish races separately, but during weekdays (Monday to Friday), simply put them together. Thanks,