ApiFootball 2.1.0

dotnet add package ApiFootball --version 2.1.0
                    
NuGet\Install-Package ApiFootball -Version 2.1.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="ApiFootball" Version="2.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="ApiFootball" Version="2.1.0" />
                    
Directory.Packages.props
<PackageReference Include="ApiFootball" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add ApiFootball --version 2.1.0
                    
#r "nuget: ApiFootball, 2.1.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package ApiFootball@2.1.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=ApiFootball&version=2.1.0
                    
Install as a Cake Addin
#tool nuget:?package=ApiFootball&version=2.1.0
                    
Install as a Cake Tool

CSharpApiFootball

Test NuGet

DI compatible C# API client for api-football.com. Only v3 endpoints will be supported. A list of availble endpoints can be found below, not a lot of them are there yet but this is a work in progress. It should work with both api-sports and rapidapi keys, but because I do not have a rapidapi key I cannot test this. If you would like to help out, feel free to open a pull request!

This project is not affiliated with api-football or api-sports.

Example

var key = "your api key";
var host = Host
    .CreateDefaultBuilder(Array.Empty<string>())
    .ConfigureServices(services => {
        services
            .AddApiFootball(key); // Configure ApiFootball client
    }).Build();

var serviceScope = host.Services.CreateScope();
var provider = serviceScope.ServiceProvider;

// Print Dutch Eredivisie games and final scores for the 2022 season
var fixturesClient = provider.GetRequiredService<IFixturesClient>();
var fixtures = await fixturesClient.GetFixtures(league:88, season:2022);

// To throw an exception in case of errors
timezones.EnsureSuccess();

fixtures.Response
    .Select(fix => $"{fix.Teams.Home.Name, 20}  -  {fix.Teams.Away.Name, -20} {" ", 10} {fix.Goals.Home} - {fix.Goals.Away}")
    .ToList()
    .ForEach(Console.WriteLine);
    
// Print all timezones
var timezoneClient = provider.GetRequiredService<ITimezoneClient>();
var timezones = await timezoneClient.GetTimezones();

// To throw an exception in case of errors
timezones.EnsureSuccess();

timezones.Response.ForEach(Console.WriteLine);

Free API keys are limited to 10 requests per minute at the time of writing. Use the EnsureSuccess() method to throw an ApiFootballException in case of errors or handle them yourself through the Errors object on the response.

Error handling

By default, no exception are thrown when ApiFootball returns a valid response object containing errors. You can enable throwing exceptions by setting the ThrowOnError property to true when you register it in the DI container.

services.AddApiFootball(options => 
{
    options.ApiKey = key;
    options.ThrowOnError = true;
});

Supported endpoints

Here you can find a list of all the endpoints that are currently supported and which interface to use to call them.

Endpoint C#
/countries ICountriesClient.GetCountries
/fixtures IFixturesClient.GetFixtures
/fixtures/rounds IFixturesClient.GetRounds
/leagues ILeaguesClient.GetLeagues
/leagues/seasons ILeaguesClient.GetSeasons
/standings IStandingsClient.GetStandings
/teams ITeamsClient.GetTeamsInformation
/teams/seasons ITeamsClient.GetTeamsSeasons
/teams/countries ITeamsClient.GetTeamsCountries
/timezone ITimezoneClient.GetTimezones
/venues IVenuesClient.GetVenues
Product Compatible and additional computed target framework versions.
.NET net7.0 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2.1.0 153 5/21/2025
2.0.0 147 5/21/2025
1.0.8 224 8/30/2023
1.0.7 352 12/21/2022