Fast and simple classes for interacting with the Betfair API and Stream.
Available on NuGet
dotnet add package Betfair
or
PM> Install-Package Betfair
Create a Subscription. Then use a MarketFilter to start a stream.
Full subscription documentation.
var credentials = new Credentials("USERNAME", "PASSWORD", "APP_KEY");
using var subscription = new Subscription(credentials);
await subscription.Subscribe(new StreamMarketFilter().WithMarketIds("MARKET_ID"));
await foreach (var change in subscription.ReadLines(default))
{
// Handle changes
}
var credentials = new Credentials("USERNAME", "PASSWORD", "APP_KEY");
using var client = new BetfairApiClient(credentials);
var filter = new ApiMarketFilter()
.WithMarketTypes(MarketType.Win)
.WithCountries(Country.UnitedKingdom, Country.Ireland)
.WithEventTypes(EventType.HorseRacing)
.FromMarketStart(DateTimeOffset.UtcNow)
.ToMarketStart(DateTimeOffset.UtcNow.AddDays(1));
var query = new MarketCatalogueQuery()
.Include(MarketProjection.Event)
.Include(MarketProjection.MarketStartTime)
.Include(MarketProjection.MarketDescription)
.Include(MarketProjection.RunnerDescription)
.OrderBy(MarketSort.FirstToStart)
.Take(200);
var marketCatalogues = await client.MarketCatalogue(filter, query);
Or use the helper extension.
var filter = new ApiMarketFilter()
.TodaysCard();
var query = new MarketCatalogueQuery()
.Include(MarketProjection.Event)
.Include(MarketProjection.MarketStartTime)
.Include(MarketProjection.MarketDescription)
.Include(MarketProjection.RunnerDescription)
.OrderBy(MarketSort.FirstToStart)
.Take(200);
var marketCatalogues = await client.MarketCatalogue(filter, query);