News.Net 1.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package News.Net --version 1.0.0
NuGet\Install-Package News.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="News.Net" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add News.Net --version 1.0.0
#r "nuget: News.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 News.Net as a Cake Addin
#addin nuget:?package=News.Net&version=1.0.0

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

Image

🤔 How To Use

Creating a request to send to the API.

//Generate a new AllNewsRequest. This is where you create your query for the API.
var request = new AllNewsRequest("Arrow", SortType.PublishedDate);

//You can also set date from and to if you so wish.
//This will fetch all news regarding Arrow that have been published in the last 7 days.
var request = new AllNewsRequest("Arrow", SortType.PublishedDate, DateTime.UtcNow.AddDays(-7));

//This will fetch all news regarding Arrow 
//This request exmample states that articles are to be:
//No older than 7 days and also ignore articles from the last 2 days.
//For example if it where 10/1/2019, this would be news articles from The 3/1/2019 to 8/1/2019 
var request = new AllNewsRequest("Arrow", SortType.PublishedDate, DateTime.UtcNow.AddDays(-7), DateTime.UtcNow.AddDays(-2));

Using those requests.

//Initialise a NewClient & pass in your APIKey
//Get the NewsClient from your IOC Container if you are using one.
var newsClient = new NewsClient("API_Key Here");

//Send the request you created (as shown above)
var result = await newsClient.FetchNewsAsync(request);

//You will now have a NewsResult, of which you will want to check the status.
//If the status has not shown OK, you handle it.
if (result.ResponseStatus != ResponseStatus.Ok)
{
    Console.WriteLine($"There seems to have been an error. {result.Error.ToString()}")
}

//Else you can use the result.Articles to access the article information.
else
{
    foreach (var article in result.Articles)
    {
        Console.WriteLine(article.Title);
        Console.WriteLine(article.Description);
        Console.WriteLine(article.Author);
        Console.WriteLine(article.Source.Name);
    }
}

Getting top headline results for a desired source.

//as above, create your client or get it from your IOC Container.
//Use the NewsClient to send a request for the latest news from a desired source.
var result = await _newsClient.FetchNewsFromSource(NewsSource.BBC);

//You can also pass in an array of sources if you wish.
var sources = new NewsSource[] 
    { 
        NewsSource.ABCNews,
        NewsSource.BBC
    };

var result = await _newsClient.FetchNewsFromSource(sources);

While I do support a large amount of sources by default that are provided by the NewsApi.Org website. I DO NOT support them all. If you want to use a source I do not support, you are able to enter the source id like so. (Find the source ID's Here)

var result = await _newsClient.FetchNewsFromSource("buzzfeed");

The IServiceCollection extension method.

ℹ This is a simple way to add the service to your IOC Container.

public class Foo
{
    public void SetupServices()
    {
        serviceCollection.UseNewsAPI("YOUR_API_KEY_HERE");
    }
}
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 netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  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.1 660 10/30/2019
1.0.0 582 10/18/2019

Initial Release.