C# SDK provides access to the News API v3 from C# applications.

Installation

# Using the .NET CLI
dotnet add package NewscatcherApi

# Using NuGet Package Manager Console
Install-Package NewscatcherApi

Basic usage

using NewscatcherApi;

var client = new NewscatcherApiClient("YOUR_API_KEY");
await client.Search.PostAsync(
    new SearchPostRequest
    {
        Q = "renewable energy",
        PredefinedSources = new List<string>() { "top 50 US" },
        Lang = new List<string>() { "en" },
        From = new DateTime(2024, 01, 01, 00, 00, 00, 000),
        To = new DateTime(2024, 06, 30, 00, 00, 00, 000),
        AdditionalDomainInfo = true,
        IsNewsDomain = true,
    }
);

Error handling

using NewscatcherApi;

try {
    var response = await client.Search.PostAsync(...);
} catch (NewscatcherApiApiException e) {
    Console.WriteLine(e.Body);
    Console.WriteLine(e.StatusCode);
}

For complete documentation, including retry configuration and timeouts, see the GitHub repository.

If you use our legacy C# SDK (Konfig-based), see our Legacy SDKs documentation. We recommend migrating to this newer SDK for improved features and ongoing support.

Resources