showing results for - "news api react native"
Grégoire
03 Jan 2017
1const NewsAPI = require('newsapi');
2const newsapi = new NewsAPI('ea06ed5a53cf44bcb49973b3bd593fea');
3// To query /v2/top-headlines
4// All options passed to topHeadlines are optional, but you need to include at least one of them
5newsapi.v2.topHeadlines({
6  sources: 'bbc-news,the-verge',
7  q: 'bitcoin',
8  category: 'business',
9  language: 'en',
10  country: 'us'
11}).then(response => {
12  console.log(response);
13  /*
14    {
15      status: "ok",
16      articles: [...]
17    }
18  */
19});
20// To query /v2/everything
21// You must include at least one q, source, or domain
22newsapi.v2.everything({
23  q: 'bitcoin',
24  sources: 'bbc-news,the-verge',
25  domains: 'bbc.co.uk, techcrunch.com',
26  from: '2017-12-01',
27  to: '2017-12-12',
28  language: 'en',
29  sortBy: 'relevancy',
30  page: 2
31}).then(response => {
32  console.log(response);
33  /*
34    {
35      status: "ok",
36      articles: [...]
37    }
38  */
39});
40// To query sources
41// All options are optional
42newsapi.v2.sources({
43  category: 'technology',
44  language: 'en',
45  country: 'us'
46}).then(response => {
47  console.log(response);
48  /*
49    {
50      status: "ok",
51      sources: [...]
52    }
53  */
54});
Flore
03 Mar 2020
1$ npm install newsapi --save
queries leading to this page
news api react nativenews api react native