NewsData.NET 1.0.0

dotnet add package NewsData.NET --version 1.0.0
NuGet\Install-Package NewsData.NET -Version 1.0.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="NewsData.NET" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add NewsData.NET --version 1.0.0
#r "nuget: NewsData.NET, 1.0.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.
// Install NewsData.NET as a Cake Addin
#addin nuget:?package=NewsData.NET&version=1.0.0

// Install NewsData.NET as a Cake Tool
#tool nuget:?package=NewsData.NET&version=1.0.0

NewsData.NET

NewsData.NET is an unofficial .NET client package for the News Data API, designed to facilitate easy access to various news-related data. This package is compatible with .NET Standard 2.1.

Documentation

News Data API docs can be seen here.

Usage

To start using the NewsData.NET package, first initialize the NewsDataClient. This requires specifying a ClientType from the NewsData.NET.ClientType enumeration and an API key.

NewsData.NET.ClientType:

public enum ClientType
{
    None = 0,
    LatestNews,
    CryptoNews,
    NewsArchive,
    NewsSources
}
string apiKey = "your_api_key_here";
// The NewsDataClient also supports passing an HttpClient as an optional parameter
using INewsDataClient client = new NewsDataClient(ClientType.LatestNews, apiKey/*, httpClient*/);

Then we call the GetAsync method and pass an DefaultRequest(IDictionary<string, string> queryStringCollection, string pageIndex = null) including all the query string parameters.

var queryString = new Dictionary<string, string>
{
    // ...
    { "country", "al" },
    { "language", "sq" },
    { "timezone", "Europe/Berlin" },
    { "size", "10" }, // free tier
    // ...
};

var result = await client.GetAsync(new DefaultRequest(queryString));
// Result will be of type NewsData.NET.ObjectModels.ResponseModels.NewsDataApiResult

Aggregating Paged News

For fetching a fixed amount of data across pages, use the AggregatePagedNewsAsync method.

// pass querystring as IDictionary<string, string> and articlesToBeFetched
var results = await client.AggregatePagedNewsAsync(queryString, articlesToBeFetched: 25);
// The result will be a list of NewsData.NET.ObjectModels.ResponseModels.SuccessResult

Dependencies

RestSharp

This package relies on the RestSharp library, a popular .NET library used for making HTTP requests. Ensure that you have the RestSharp package installed in your project. https://github.com/restsharp/RestSharp

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

License

Licensed under the MIT License.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  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 was computed.  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. 
.NET Core netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos 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
1.0.0 470 11/27/2023