Skip to content

DatanewsOrg/datanews-java

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

datanews-java

This repo contains the official Datanews client library for Java.

You can find full documentation on the official website.

Installation

First, add a jitpack repository to your build file. Example for gradle:

repositories {
    maven { url 'https://jitpack.io' }
}

Then, add datanews-java as a dependency (tag below is some GitHub tag name - e.g. v0.1):

dependencies {
    implementation 'com.github.DatanewsOrg:datanews-java:<tag>'
}

Usage

Here is a small example of how you can use this library to query search API.

NewsParams params = NewsParams.builder()
    .query("US elections")
    .size(25)
    .fromDate(LocalDate.of(2020, 10, 1))
    .build();

NewsResponse data = Datanews
    .search("Your API key")
    .news(params);

System.out.println(data.getArticles());

You can also set your API key once and use it later.

Datanews.setGlobalApiKey("Your API key");

NewsParams params = NewsParams.builder()
    .query("US elections")
    .size(25)
    .fromDate(LocalDate.of(2020, 10, 1))
    .build();

NewsResponse data = Datanews
    .search()
    .news(params);

System.out.println(data.getArticles());

About

Datanews Java client

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages