In this section, we present how to connect News API to MindsDB.

News API is a simple HTTP REST API for searching and retrieving live articles from all over the web.

Data from News API can be utilized within MindsDB for model training and predictions.

Prerequisites

Before proceeding, ensure the following prerequisites are met:

  1. Install MindsDB locally via Docker or use MindsDB Cloud.
  2. To connect News API to MindsDB, install the required dependencies following this instruction.
  3. Install or ensure access to News API.

Connection

This handler is implemented using the newsapi-python library.

The required arguments to establish a connection are as follows:

  • api_key News API key to use for authentication.

Check out this guide on how to create the API key.

It is recommended to use the API key to avoid the API rate limit exceeded error.

Here is how to connect News API to MindsDB:

CREATE DATABASE newsAPI
WITH ENGINE = 'newsapi'
PARAMETERS = {
	"api_key": "Your api key"
};

Usage

Simple Search for recent articles:

SELECT *
FROM newsAPI.article
WHERE query = 'Python';

Advanced search for recent articles per specific sources between dates:

SELECT *
FROM newsAPI.article
WHERE query = 'Python'
AND sources="bbc-news"
AND publishedAt >= "2021-03-23" AND  publishedAt <= "2023-04-23"
LIMIT 4;

For more information about available actions and development plans, visit this page.