Note: There is a newer version (1.5.1) of this package available. Click here to view docs for the latest version.
Module newsapi
ballerinax/newsapi Ballerina library
1.1.0
Overview
This is a generated connector for News API v2.0.0 OpenAPI specification.
News API used to fetch news(articles, headlines and sources) from news sources and blogs across the web.
Prerequisites
Before using this connector in your Ballerina application, complete the following:
- Create News API Account
 - Obtaining tokens
- Log into News API Account
 - Get API key by clicking to 
Get API Key 
 
Quickstart
Step 1: Import connector
Import the ballerinax/newsapi module into the Ballerina project.
import ballerinax/newsapi;
Step 2: Create a new connector instance
newsapi:ApiKeysConfig config = { apiKey : "<your apiKey>" }; newsapi:Client myclient = check new newsapi:Client(config, {}, "https://newsapi.org/v2");
Step 3: Invoke connector operation
- You can get top headlines as follows with 
listTopHeadlinesmethod by passing country as a parameter.newsapi:WSNewsTopHeadlineResponse result = check myclient->listTopHeadlines(country="us"); - Use 
bal runcommand to compile and run the Ballerina program.