A MagicMirror² module to to get news from NewsData.io.
- luxon@2.0.2
- node-fetch@2.6.1
- qrious@4.0.2
In your terminal, go to your MagicMirror's Module folder:
cd ~/MagicMirror/modules
Clone this repository:
git clone https://github.com/thess/MMM-NewsData.git
Add the module to the modules array in the config/config.js
file:
{
module: "MMM-NewsData",
header: "NEWS",
position: "bottom_bar",
},
The following properties can be configured:
Option | Description |
---|---|
header |
The header text Default value: 'NEWS' |
pageSize |
The number of articles to be returned. Max = 100 Default value: 20 |
sortBy |
The order to sort the articles in. Possible values: relevancy , popularity , publishedAt only available for choice: "everything" |
drawInterval |
The amount of time each article is displayed Default value: 30 seconds |
templateFile |
The template file to use. You can create your own template file and reference here. For now use template.html |
fetchInterval |
The time interval between fetching new articles. There is a daily limit of 100 calls per apiKey. Best to set this to 1006060 |
apiKey |
You can obtain an API Key from NewsAPi.org |
QRCode |
Boolean true/false value to display QR code for article URL. Default is false. |
maxContent |
Maximum number of characters in article description display area. Default value: 600 |
The following query options can be defined
When specifying the query options take note of the following:
When using headlines
, country
and sources
cannot be used together.
The domains
option cannot be used on it's own, you have to specify any of the following parameters with it: sources
, q
, language
, country
, category
.
When using everything
, you cannot use the country
option.
To try more combinations you can visit NewsData.io
Option | Description |
---|---|
country |
The 2-letter ISO 3166-1 code of the country you want to get headlines for. Possible options: ae ar at au be bg br ca ch cn co cu cz de eg fr gb gr hk hu id ie ve za il in it jp kr lt lv ma mx my ng nl no nz ph pl pt ro rs ru sa se sg si sk th tr tw ua us . Note: you can't mix this param with the sources param |
category |
The category you want to get headlines for. Possible options: business entertainment general health science sports technology . Note: you can't mix this param with the sources param. |
q |
Keywords or phrases to search for in the article title and body |
qInTitle |
Keywords or phrases to search for in the article title only |
sources |
A comma-seperated string of identifiers (maximum 20) for the news sources or blogs you want headlines from |
domain |
A comma-seperated string of domains (eg bbc.co.uk, techcrunch.com, engadget.com) to restrict the search to. |
language |
The 2-letter ISO-639-1 code of the language you want to get headlines for. Possible options: ar de en es fr he it nl no pt ru se ud zh |
{
module: "MMM-NewsData",
header: "news",
position: "bottom_bar",
config: {
apiKey: "",
pageSize: 10,
sortBy: "publishedAt",
drawInterval: 1000*30,
templateFile: "template.html",
fetchInterval: 1000*60*15,
QRCode: true,
maxContent: 500,
query: {
country: "",
category: "",
q: "",
qInTitle: "",
sources: "",
domain: "cnn.com,nytimes.com,news24.com",
language: ""
}
}
},
Notes
apiKey
is required. You should first create an account on https://newsdata.io/
To update the module to the latest version, use your terminal to go to your MMM-NewsData module folder and type the following command:
cd MMM-NewsData
git pull
npm install