Skip to content

Latest commit

 

History

History
81 lines (65 loc) · 3.39 KB

README.md

File metadata and controls

81 lines (65 loc) · 3.39 KB

.NET Core GitHub license NuGet downloads

Quality Gate Status Bugs Code Smells Coverage Duplicated Lines (%)

Mutation testing badge

Betfair

Fast and simple classes for interacting with the Betfair API and Stream.

Full documentation.

Installation

Available on NuGet

dotnet add package Betfair

or

PM> Install-Package Betfair

How to Subscribe to a Market Stream

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
}

How to List Today's Horse Races

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);