A client wrapper of the Holiday API for .NET projects (both Core & Framewok).
Build status | Last commit | Tests | Coverage | Code Smells | LoC |
---|---|---|---|---|---|
Download the latest zip file from the Release page.
Package | Version | Downloads |
---|---|---|
GuiStracini.HolidayAPI |
Implements all features of Holiday API available at HolidayAPI docs
- Get holidays list (country code and year required)
- Get filtered holidays (day, month, public, upcoming, previous, subdivisions, switch response language, search parameter)
- Get countries list
- Get filtered countries (search parameter)
- Get languages list
- Get filtered languages (search parameter)
- Get workday
- Get workdays
Get your API key at Holiday API site.
//Http Client - you should use your DI container for it
var client = HttpClientFactory.Create();
client.BaseAddress = new Uri("https://holidayapi.com/");
client.DefaultRequestHeaders.ExpectContinue = false;
client.DefaultRequestHeaders.Accept.Clear();
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
//Use your API key
var myKey = "00000000-0000-0000-0000-000000000000";
//Instantiate a holidayApi client with your API key (GUID/UUID)
var holidayClient = new HolidayApiClient(myKey, client);
//Getting all holidays in Brazil for the year 2019:
var holidays = await holidayClient.GetHolidaysAsync("BR", 2019, CancellationToken.None);
foreach(var holiday in holidays)
Console.WriteLine("Holiday: {0} | Date: {1}", holiday.Name, holiday.Date);
//Getting all available countries
var countries = await holidayClient.GetCountriesAsync(CancellationToken.None);
foreach(var country in countries)
Console.WriteLine("Country: {0} | Code: {1} | Flag: {2}", country.Name, country.Code, country.Flag);
//Getting all available languages
var languages = await holidayClient.GetLanguagesAsync(CancellationToken.None);
foreach(var language in languages)
Console.WriteLine("Code: {0} | Name: {1}", language.Code, language.Name);
//Getting workday
var workday = await holidayClient.GetWorkdayAsync("BR", "2019-06-23", 10, CancellationToken.None);
Console.WriteLine("Workday: {0}", workday.Date);
//Getting workdays between two dates
var workdays = await holidayClient.GetWorkdaysAsync("BR", "2021-01-01", "2021-06-01", CancellationToken.None);
Console.WriteLine("Workdays: {0}". workdays.Days);