News-API-csharp

所属分类:C/C++工具库
开发工具:C#
文件大小:0KB
下载次数:0
上传日期:2022-06-23 12:42:52
上 传 者sh-1993
说明:  我们官方支持的用于访问新闻API的C#客户端库。
(Our officially supported C# client library for accessing News API.)

文件列表:
LICENSE (1065, 2018-01-28)
NewsAPI.Tests/ (0, 2018-01-28)
NewsAPI.Tests/App.config (75, 2018-01-28)
NewsAPI.Tests/NewsAPI.Tests.csproj (4629, 2018-01-28)
NewsAPI.Tests/Properties/ (0, 2018-01-28)
NewsAPI.Tests/Properties/AssemblyInfo.cs (1402, 2018-01-28)
NewsAPI.Tests/Tests.cs (3918, 2018-01-28)
NewsAPI.sln (1453, 2018-01-28)
NewsAPI/ (0, 2018-01-28)
NewsAPI/Constants/ (0, 2018-01-28)
NewsAPI/Constants/Categories.cs (442, 2018-01-28)
NewsAPI/Constants/Countries.cs (2487, 2018-01-28)
NewsAPI/Constants/ErrorCodes.cs (587, 2018-01-28)
NewsAPI/Constants/Languages.cs (1632, 2018-01-28)
NewsAPI/Constants/SortBys.cs (524, 2018-01-28)
NewsAPI/Constants/Statuses.cs (367, 2018-01-28)
NewsAPI/Models/ (0, 2018-01-28)
NewsAPI/Models/ApiResponse.cs (450, 2018-01-28)
NewsAPI/Models/Article.cs (500, 2018-01-28)
NewsAPI/Models/ArticlesResult.cs (402, 2018-01-28)
NewsAPI/Models/Error.cs (298, 2018-01-28)
NewsAPI/Models/EverythingRequest.cs (2138, 2018-01-28)
NewsAPI/Models/Source.cs (265, 2018-01-28)
NewsAPI/Models/TopHeadlinesRequest.cs (1596, 2018-01-28)
NewsAPI/NewsAPI.csproj (3544, 2018-01-28)
NewsAPI/NewsAPI.nuspec (761, 2018-01-28)
NewsAPI/NewsApiClient.cs (7877, 2018-01-28)
NewsAPI/Properties/ (0, 2018-01-28)
NewsAPI/Properties/AssemblyInfo.cs (1072, 2018-01-28)
NewsAPI/packages.config (162, 2018-01-28)
icon.png (1907, 2018-01-28)

# News API client library for .NET (C#) News API is a simple HTTP REST API for searching and retrieving live articles from all over the web. It can help you answer questions like: - What top stories is the NY Times running right now? - What new articles were published about the next iPhone today? - Has my company or product been mentioned or reviewed by any blogs recently? You can search for articles with any combination of the following criteria: - Keyword or phrase. Eg: find all articles containing the word 'Microsoft'. - Date published. Eg: find all articles published yesterday. - Source name. Eg: find all articles by 'TechCrunch'. - Source domain name. Eg: find all articles published on nytimes.com. - Language. Eg: find all articles written in English. You can sort the results in the following orders: - Date published - Relevancy to search keyword - Popularity of source You need an API key to use the API - this is a unique key that identifies your requests. They're free for development, open-source, and non-commercial use. You can get one here: [https://newsapi.org](https://newsapi.org). ## Installation The News API client library is available on Nuget. You can install it either through the Nuget package management window in Visual Studio by searching for NewsAPI, or by running the following in the package manager console: ```shell PM> Install-Package NewsAPI ``` ## Usage example ```csharp using NewsAPI; using NewsAPI.Models; using NewsAPI.Constants; using System; namespace MyApplication { class Program { static void Main(string[] args) { // init with your API key (get this from newsapi.org) var newsApiClient = new NewsApiClient("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"); var articlesResponse = newsApiClient.GetEverything(new EverythingRequest { Q = "Apple", SortBy = SortBys.Popularity, Language = Languages.EN, From = new DateTime(2018, 1, 25) }); if (articlesResponse.Status == Statuses.Ok) { // total results found Console.WriteLine(articlesResponse.TotalResults); // here's the first 20 foreach (var article in articlesResponse.Articles) { // title Console.WriteLine(article.Title); // author Console.WriteLine(article.Author); // description Console.WriteLine(article.Description); // url Console.WriteLine(article.Url); // image Console.WriteLine(article.UrlToImage); // published at Console.WriteLine(article.PublishedAt); } } Console.ReadLine(); } } } ```

近期下载者

相关文件


收藏者