Working Days is a simple tool for getting the number of working days in a month. It returns the number of working days in the given month.
$ dotnet add package APIVerve.API.WorkingDaysWorking Days is a simple tool for getting the number of working days in a month. It returns the number of working days in the given month.
This is a .NET Wrapper for the WorkingDays API
Using the .NET CLI:
dotnet add package APIVerve.API.WorkingDays
Using the Package Manager:
nuget install APIVerve.API.WorkingDays
Using the Package Manager Console:
Install-Package APIVerve.API.WorkingDays
From within Visual Studio:
Before using the workingdays API client, you have to setup your account and obtain your API Key. You can get it by signing up at https://apiverve.com
Here's a simple example to get you started quickly:
using System;
using APIVerve;
class Program
{
static async Task Main(string[] args)
{
// Initialize the API client
var apiClient = new WorkingDaysAPIClient("[YOUR_API_KEY]");
var queryOptions = new QueryOptions {
country = "US",
month = 10,
year = 2026
};
// Make the API call
try
{
var response = await apiClient.ExecuteAsync(queryOptions);
if (response.Error != null)
{
Console.WriteLine($"API Error: {response.Error}");
}
else
{
Console.WriteLine("Success!");
// Access response data using the strongly-typed ResponseObj properties
Console.WriteLine(Newtonsoft.Json.JsonConvert.SerializeObject(response, Newtonsoft.Json.Formatting.Indented));
}
}
catch (Exception ex)
{
Console.WriteLine($"Exception: {ex.Message}");
}
}
}
The WorkingDays API documentation is found here: https://docs.apiverve.com/ref/workingdays. You can find parameters, example responses, and status codes documented here.
WorkingDays API uses API Key-based authentication. When you create an instance of the API client, you can pass your API Key as a parameter.
// Create an instance of the API client
var apiClient = new WorkingDaysAPIClient("[YOUR_API_KEY]");
The modern async/await pattern provides the best performance and code readability:
using System;
using System.Threading.Tasks;
using APIVerve;
public class Example
{
public static async Task Main(string[] args)
{
var apiClient = new WorkingDaysAPIClient("[YOUR_API_KEY]");
var queryOptions = new QueryOptions {
country = "US",
month = 10,
year = 2026
};
var response = await apiClient.ExecuteAsync(queryOptions);
if (response.Error != null)
{
Console.WriteLine($"Error: {response.Error}");
}
else
{
Console.WriteLine(Newtonsoft.Json.JsonConvert.SerializeObject(response, Newtonsoft.Json.Formatting.Indented));
}
}
}
If you need to use synchronous code, you can use the Execute method:
using System;
using APIVerve;
public class Example
{
public static void Main(string[] args)
{
var apiClient = new WorkingDaysAPIClient("[YOUR_API_KEY]");
var queryOptions = new QueryOptions {
country = "US",
month = 10,
year = 2026
};
var response = apiClient.Execute(queryOptions);
if (response.Error != null)
{
Console.WriteLine($"Error: {response.Error}");
}
else
{
Console.WriteLine(Newtonsoft.Json.JsonConvert.SerializeObject(response, Newtonsoft.Json.Formatting.Indented));
}
}
}
The API client provides comprehensive error handling. Here are some examples:
using System;
using System.Threading.Tasks;
using APIVerve;
public class Example
{
public static async Task Main(string[] args)
{
var apiClient = new WorkingDaysAPIClient("[YOUR_API_KEY]");
var queryOptions = new QueryOptions {
country = "US",
month = 10,
year = 2026
};
try
{
var response = await apiClient.ExecuteAsync(queryOptions);
// Check for API-level errors
if (response.Error != null)
{
Console.WriteLine($"API Error: {response.Error}");
Console.WriteLine($"Status: {response.Status}");
return;
}
// Success - use the data
Console.WriteLine("Request successful!");
Console.WriteLine(Newtonsoft.Json.JsonConvert.SerializeObject(response, Newtonsoft.Json.Formatting.Indented));
}
catch (ArgumentException ex)
{
// Invalid API key or parameters
Console.WriteLine($"Invalid argument: {ex.Message}");
}
catch (System.Net.Http.HttpRequestException ex)
{
// Network or HTTP errors
Console.WriteLine($"Network error: {ex.Message}");
}
catch (Exception ex)
{
// Other errors
Console.WriteLine($"Unexpected error: {ex.Message}");
}
}
}
using System;
using System.Threading.Tasks;
using APIVerve;
public class Example
{
public static async Task Main(string[] args)
{
var apiClient = new WorkingDaysAPIClient("[YOUR_API_KEY]");
// Configure retry behavior (max 3 retries)
apiClient.SetMaxRetries(3); // Retry up to 3 times (default: 0, max: 3)
apiClient.SetRetryDelay(2000); // Wait 2 seconds between retries
var queryOptions = new QueryOptions {
country = "US",
month = 10,
year = 2026
};
try
{
var response = await apiClient.ExecuteAsync(queryOptions);
if (response.Error != null)
{
Console.WriteLine($"API Error: {response.Error}");
}
else
{
Console.WriteLine("Success!");
Console.WriteLine(Newtonsoft.Json.JsonConvert.SerializeObject(response, Newtonsoft.Json.Formatting.Indented));
}
}
catch (Exception ex)
{
Console.WriteLine($"Failed after retries: {ex.Message}");
}
}
}
Add custom headers to your requests:
var apiClient = new WorkingDaysAPIClient("[YOUR_API_KEY]");
// Add custom headers
apiClient.AddCustomHeader("X-Custom-Header", "custom-value");
apiClient.AddCustomHeader("X-Request-ID", Guid.NewGuid().ToString());
var queryOptions = new QueryOptions {
country = "US",
month = 10,
year = 2026
};
var response = await apiClient.ExecuteAsync(queryOptions);
// Remove a header
apiClient.RemoveCustomHeader("X-Custom-Header");
// Clear all custom headers
apiClient.ClearCustomHeaders();
Enable logging for debugging:
var apiClient = new WorkingDaysAPIClient("[YOUR_API_KEY]", isDebug: true);
// Or use a custom logger
apiClient.SetLogger(message =>
{
Console.WriteLine($"[LOG] {DateTime.Now:yyyy-MM-dd HH:mm:ss} - {message}");
});
var queryOptions = new QueryOptions {
country = "US",
month = 10,
year = 2026
};
var response = await apiClient.ExecuteAsync(queryOptions);
Customize retry behavior for failed requests:
var apiClient = new WorkingDaysAPIClient("[YOUR_API_KEY]");
// Set retry options
apiClient.SetMaxRetries(3); // Retry up to 3 times (default: 0, max: 3)
apiClient.SetRetryDelay(1500); // Wait 1.5 seconds between retries (default: 1000ms)
var queryOptions = new QueryOptions {
country = "US",
month = 10,
year = 2026
};
var response = await apiClient.ExecuteAsync(queryOptions);
The API client implements IDisposable for proper resource cleanup:
var queryOptions = new QueryOptions {
country = "US",
month = 10,
year = 2026
};
using (var apiClient = new WorkingDaysAPIClient("[YOUR_API_KEY]"))
{
var response = await apiClient.ExecuteAsync(queryOptions);
Console.WriteLine(Newtonsoft.Json.JsonConvert.SerializeObject(response, Newtonsoft.Json.Formatting.Indented));
}
// HttpClient is automatically disposed here
{
"status": "ok",
"error": null,
"data": {
"workingDaysCount": 21,
"nonWorkingDaysCount": 10,
"workingDays": [
"2023-10-02",
"2023-10-03",
"2023-10-04",
"2023-10-05",
"2023-10-06",
"2023-10-10",
"2023-10-11",
"2023-10-12",
"2023-10-13",
"2023-10-16",
"2023-10-17",
"2023-10-18",
"2023-10-19",
"2023-10-20",
"2023-10-23",
"2023-10-24",
"2023-10-25",
"2023-10-26",
"2023-10-27",
"2023-10-30",
"2023-10-31"
],
"nonWorkingDays": [
{
"date": "2023-10-01",
"reasons": [
"weekend"
],
"holiday_name": null
},
{
"date": "2023-10-07",
"reasons": [
"weekend"
],
"holiday_name": null
},
{
"date": "2023-10-08",
"reasons": [
"weekend"
],
"holiday_name": null
},
{
"date": "2023-10-09",
"reasons": [
"public holiday"
],
"holiday_name": "Columbus Day"
},
{
"date": "2023-10-14",
"reasons": [
"weekend"
],
"holiday_name": null
},
{
"date": "2023-10-15",
"reasons": [
"weekend"
],
"holiday_name": null
},
{
"date": "2023-10-21",
"reasons": [
"weekend"
],
"holiday_name": null
},
{
"date": "2023-10-22",
"reasons": [
"weekend"
],
"holiday_name": null
},
{
"date": "2023-10-28",
"reasons": [
"weekend"
],
"holiday_name": null
},
{
"date": "2023-10-29",
"reasons": [
"weekend"
],
"holiday_name": null
}
]
}
}
Need any assistance? Get in touch with Customer Support.
Stay up to date by following @apiverveHQ on Twitter.
All usage of the APIVerve website, API, and services is subject to the APIVerve Terms of Service and all legal documents and agreements.
Licensed under the The MIT License (MIT)
Copyright (©) 2026 APIVerve, and EvlarSoft LLC
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.