# gnews-node-api

> Node module for Gnews Api from gnews.io

Latest version **1.0.3** (published 2020-11-28) · MIT license · 0 weekly downloads

## Install

```sh
npm install gnews-node-api
pnpm add gnews-node-api
yarn add gnews-node-api
bun add gnews-node-api
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.3 |
| Published | 2020-11-28 |
| First published | 2020-10-07 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 4.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | elango ramar |
| Maintainers | elango_ramar |
| Keywords | news, api, newsapi, gnews |

## Links

- npm: https://www.npmjs.com/package/gnews-node-api
- Repository: https://github.com/elangoram1998/gnews-node-api
- Homepage: https://github.com/elangoram1998/gnews-node-api#readme
- Issues: https://github.com/elangoram1998/gnews-node-api/issues
- npm.io page: https://npm.io/package/gnews-node-api

## Dependencies (2)

- [node-fetch](https://npm.io/package/node-fetch.md) ^2.6.1
- [querystring](https://npm.io/package/querystring.md) ^0.2.0

## Alternatives

- [@opentelemetry/exporter-zipkin](https://npm.io/package/@opentelemetry/exporter-zipkin.md) — 14.8M weekly downloads
- [pusher-js](https://npm.io/package/pusher-js.md) — 2.0M weekly downloads
- [browserify](https://npm.io/package/browserify.md) — 1.7M weekly downloads
- [sqs-consumer](https://npm.io/package/sqs-consumer.md) — 1.7M weekly downloads
- [@sanity/eventsource](https://npm.io/package/@sanity/eventsource.md) — 930.8K weekly downloads

## Recent versions

- 1.0.3 (latest) — 2020-11-28
- 1.0.2 — 2020-10-07
- 1.0.1 — 2020-10-07
- 1.0.0 — 2020-10-07

## README

# gnews-node-api
Node module for Gnews Api from gnews.io

Top Headlines and search for articles from a variety of sources, including Google News.

you must need an API key from [https://gnews.io/](https://gnews.io/)

Please take a look at their [documentation](https://gnews.io/docs/v4#introduction) to know more about the gnews api.The convenience functions provided by this module
simply pass their querystring parameters to the REST API, so the [documentation](https://gnews.io/docs/v4#introduction)
is totally valid. There are some usage examples below to see how these querystring parameters should be passed in.

If you use this in a project, add a 'powered by' attribution link back to gnews.io

## Add to your project
```shell
$ npm i gnews-node-api
```

## Example usage

```js

const GnewsApi = require('gnews-node-api');
const newsApi = new GnewsApi('YOUR-API-KEY');

// to get the top headline news
// lang is must, other options are optional
newsApi.getTopHeadLines({
    topic: 'entertainment',
    lang: 'en',
    country: 'in'
}).then(
    data => {
        console.log(data);
        /*
        {
            totalArticles:"...",
            articles:[...]
        }
        */
    }
).catch(
    error=>{
        //Error message
    }
);

// to search for a news
//atleast one q is required, optional's (lang,country,from,to,sortby,nullable)
newsApi.searchNews({
    q: 'apple microsoft',
    lang: 'en',
    country: 'in',
    from: '2020-09-01',
    to: '2020-10-01',
    sortby: 'relevance',
    nullable: ''
}).then(
    data => {
        console.log(data);
        /*
        {
            totalArticles:"...",
            articles:[...]
        }
        */
    }
).catch(
    error=>{
        //Error message
    }
);
```

---
_Source: https://npm.io/package/gnews-node-api · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
