Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/niyiomotoso/the-guardian-api-java-client
Java client library for TheGuardian APIs
https://github.com/niyiomotoso/the-guardian-api-java-client
api client-library java java-library java-sdk news-sdk news-search the-guardian-api theguardian theguardian-client-library
Last synced: 14 days ago
JSON representation
Java client library for TheGuardian APIs
- Host: GitHub
- URL: https://github.com/niyiomotoso/the-guardian-api-java-client
- Owner: niyiomotoso
- License: apache-2.0
- Created: 2023-07-23T19:23:30.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-10-12T09:09:38.000Z (over 1 year ago)
- Last Synced: 2024-11-19T17:56:21.149Z (3 months ago)
- Topics: api, client-library, java, java-library, java-sdk, news-sdk, news-search, the-guardian-api, theguardian, theguardian-client-library
- Language: Java
- Homepage:
- Size: 67.4 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# The Guardian API Java Client
Java client library for the Guardian APIs. See documentation [here](https://open-platform.theguardian.com/documentation/).
All available API modules are supported - Content, Tags, Sections, Editions, and Single Item.### Installation
It is installable with any of the jvm package managers such as Gradle, Maven, sbt e.t.c.Example gradle command:
```java
implementation 'io.github.niyiomotoso:the-guardian-api-java-client:1.1.0'
```### Get API key
Sign up for an API key [here](https://open-platform.theguardian.com/access)
### Making Requests
The primary `Client\GuardianApi` class is a factory class that creates objects for each of the API modules, allowing you to make requests to any of them with your desired request parameters. You have to first create an object for it, then access your desired API module via the object. See the code snippets below:
```java
GuardianApi guardianApi = this.guardianApi = new GuardianApi(THE_GUARDIAN_API_KEY);
```**For Content:**
```java
ContentResponse response = this.guardianApi.content().setQuery("12 years a slave").setTag("film/film,tone/reviews").setFromDate("2023-03-20").setShowTags("contributor").setShowFields("starRating,headline,thumbnail,short-url").setOrderBy("relevance").fetch();
```**For Tags:**
```java
TagsResponse response = this.guardianApi.tags().setQuery("apple").setSection("technology").setShowReferences("all").fetch();
```**For Sections:**
```java
SectonsResponse response = tthis.guardianApi.sections().setQuery("business").fetch();
```**For Editions:**
```java
EditionsResponse response = this.guardianApi.editions().setQuery("uk").fetch();
```**For Single Item:**
```java
SingleItemResponse response = this.guardianApi.singleItem().setId("/sport/2022/oct/07/cricket-jos-buttler-primed-for-england-comeback-while-phil-salt-stays-focused").setShowStoryPackage(true).setShowEditorsPicks(true).setShowMostViewed(true).setShowRelated(true).fetch();
```### Community support
You can reach out to us on the Google Group here https://groups.google.com/g/guardian-api-talk for support