SugarNewsAPI 1.0.2

Suggested Alternatives

SugarNewsAPI 1.0.0

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

// Install SugarNewsAPI as a Cake Tool
#tool nuget:?package=SugarNewsAPI&version=1.0.2

SugarNews API client library for .NET (C#)

SugarNews API is a simple .NET 7.0 HTTP REST API for searching and retrieving live articles from all over the web from NewsAPI.org. 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.

Installation

The SugarNews API client library is available on Nuget. You can install it either through the Nuget package management window in Visual Studio by searching for SugarNewsAPI, or by running the following in the package manager console:

PM> Install-Package SugarNewsAPI

Usage example

using SugarNewsAPI;
using SugarNewsAPI.Models;
using SugarNewsAPI.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 SugarNewsApiClient("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();
        }
    }
}
There are no supported framework assets in this package.

Learn more about Target Frameworks and .NET Standard.

This package has no dependencies.

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.2 164 6/24/2023
1.0.1 150 6/24/2023
1.0.0 154 6/23/2023
0.1.6 136 6/23/2023
0.1.5 134 6/23/2023
0.1.4 144 6/23/2023
0.1.3 144 6/23/2023
0.1.2 140 6/23/2023
0.1.1 148 6/23/2023
0.1.0 141 6/23/2023

Added icon