NewsData

所属分类:工具库
开发工具:C#
文件大小:0KB
下载次数:0
上传日期:2023-11-27 21:22:09
上 传 者sh-1993
说明:  非官方。新闻数据api的NET客户端库(https:newsdata.io)
(Unofficial .NET Client library for news data api (https: newsdata.io ))

文件列表:
LICENSE.txt (1071, 2023-11-27)
NewsData.NET.Sample/ (0, 2023-11-27)
NewsData.NET.Sample/NewsData.NET.Sample.csproj (429, 2023-11-27)
NewsData.NET.Sample/Program.cs (735, 2023-11-27)
NewsData.NET.sln (1621, 2023-11-27)
NewsData.NET/ (0, 2023-11-27)
NewsData.NET/ClientType.cs (168, 2023-11-27)
NewsData.NET/Extensions/ (0, 2023-11-27)
NewsData.NET/Extensions/NewsDataClientsExtensions.cs (1734, 2023-11-27)
NewsData.NET/INewsDataClient.cs (373, 2023-11-27)
NewsData.NET/NewsData.NET.csproj (1145, 2023-11-27)
NewsData.NET/NewsDataClient.cs (3309, 2023-11-27)
NewsData.NET/ObjectModels/ (0, 2023-11-27)
NewsData.NET/ObjectModels/RequestModels/ (0, 2023-11-27)
NewsData.NET/ObjectModels/RequestModels/DefaultRequest.cs (525, 2023-11-27)
NewsData.NET/ObjectModels/ResponseModels/ (0, 2023-11-27)
NewsData.NET/ObjectModels/ResponseModels/BaseNewsDataResult.cs (234, 2023-11-27)
NewsData.NET/ObjectModels/ResponseModels/ErrorNewsDataResult.cs (261, 2023-11-27)
NewsData.NET/ObjectModels/ResponseModels/ErrorResult.cs (304, 2023-11-27)
NewsData.NET/ObjectModels/ResponseModels/NewsDataApiResult.cs (283, 2023-11-27)
NewsData.NET/ObjectModels/ResponseModels/SuccessNewsDataResult.cs (489, 2023-11-27)
NewsData.NET/ObjectModels/ResponseModels/SuccessResult.cs (1479, 2023-11-27)

# NewsData.NET [![NuGet](https://img.shields.io/nuget/v/NewsData.NET.svg)](https://www.nuget.org/packages/NewsData.NET/) [![NuGetCount](https://img.shields.io/nuget/dt/NewsData.NET.svg )](https://www.nuget.org/packages/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](https://github.com/dotnet/docs/blob/main/includes/net-standard-2.1.md). ## Documentation News Data API docs can be seen [here](https://newsdata.io/documentation). ## Installation ``` dotnet add package NewsData.NET ``` ## 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: ```csharp public enum ClientType { None = 0, LatestNews, CryptoNews, NewsArchive, NewsSources } ``` ```csharp 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 queryStringCollection, string pageIndex = null)``` including all the query string parameters. ```csharp var queryString = new Dictionary { // ... { "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. ```csharp // pass querystring as IDictionary 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) License.

近期下载者

相关文件


收藏者