https://github.com/taboola/api-java-client-core
https://github.com/taboola/api-java-client-core
api java rest-api taboola
Last synced: 5 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/taboola/api-java-client-core
- Owner: taboola
- License: apache-2.0
- Created: 2021-06-23T13:21:09.000Z (almost 5 years ago)
- Default Branch: main
- Last Pushed: 2025-04-30T20:48:08.000Z (about 1 year ago)
- Last Synced: 2025-07-06T13:19:06.790Z (11 months ago)
- Topics: api, java, rest-api, taboola
- Language: Java
- Homepage:
- Size: 79.1 KB
- Stars: 2
- Watchers: 4
- Forks: 6
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## Rest API SDK Core
[](https://maven-badges.herokuapp.com/maven-central/com.taboola/api-java-client-core)
### Table of Contents
1. [Getting Started](#1-getting-started)
2. [Exceptions](#2-exceptions)
3. [Usage](#3-usage)
### Intro
Easily create Rest API clients by defining endpoint mappings and models that is going to be filled by JSON over HTTP
## 1. Getting Started
### 1.1 Create Rest Client
First you will need _RestAPIClient.java_ object
```
RestAPIClient restClient = RestAPIClient.builder()
.setBaseUrl("your_base_url")
.build();
```
### 1.2 Create Model And Mapping
To know what is possible when creating endpoints interface please refer to [Retrofit2 documentation](https://square.github.io/retrofit/)
```
public class EntityModelExample {
private String id;
private String name;
public String getId() { return id; }
public void setId(String id) { this.id = id; }
public String getName() { return name; }
public void setName(String name) { this.name = name; }
}
public interface EntityModelEndpoint {
@POST("/{account_id}")
@Headers("Content-Type: application/json")
EntityModelExample update(@Header("Authorization") String accessToken,
@Path("account_id") String accountId,
@Body EntityModelExample entity) throws RestAPIException;
}
```
### 1.3 Create Rest Client Endpoint
```
EntityModelEndpoint endpoint = restClient.createRetrofitEndpoint(EntityModelEndpoint.class);
// use endpoint...
```
### 2. Exceptions
- **RestAPIUnauthorizedException** - Token is expired or bad credentials were supplied (HTTP status 401)
- Can be resolved by re-authentication or making sure that supplied credentials are correct
- **RestAPIRequestException** - Bad request (HTTP status 4xx)
- Can be resolved by fixing the request to a valid one
- **RestAPIConnectivityException** - Connectivity issues (HTTP status 5xx)
- Can be resolved by retrying or fixing networking issues
### 3. Usage
If your project is built with Maven add following to your pom file:
```
com.taboola
api-java-client-core
x.y.z
```
If your project is built with Gradle add following to your gradle setting file:
```
// https://mvnrepository.com/artifact/com.taboola/api-java-client-core
compile group: 'com.taboola', name: 'api-java-client-core', version: 'x.y.z'
```
Replace 'x.y.z' with the latest available version from [Maven Central](https://mvnrepository.com/artifact/com.taboola/api-java-client-core)