An EspoCRM API client for Java
Minimum supported Java version: 11
The client can be found on MavenCentral
Maven:
<dependency>
<groupId>dev.array21</groupId>
<artifactId>espocrm-api-client</artifactId>
<version>VERSION</version>
</dependency>
Gradle:
repositories {
mavenCentral()
}
dependencies {
implementation 'dev.array21:espocrm-api-client:VERSION'
}
import java.io.IOException;
import java.security.InvalidKeyException;
import dev.array21.espocrm.client.ClientBuilder;
import dev.array21.espocrm.client.EspoApiClient;
import dev.array21.espocrm.client.RequestException;
import dev.array21.espocrm.types.Where;
import dev.array21.espocrm.types.FilterType;
import dev.array21.espocrm.types.Method;
import dev.array21.espocrm.types.Params;
public class ExampleClass {
public static void main(String[] args) {
EspoApiClient client = new ClientBuilder()
.setHost("YOUR ESPOCRM HOST")
.setApiKey("YOUR ESPOCRM API KEY")
.setSecretKey("YOUR ESPOCRM SECRET KEY")
.build();
Where[] whereFilter = new Where[] {
new Where(FilterType.EQUALS, "SomeEspoCrmField").setValue("itMustBeEqualToThis")
}
Params requestParams = new Params()
.setOffset(0)
.setMaxSize(50)
.setSelect("id")
.setOrderBy("id")
.setOrder(Order.DESC)
.setWhere(whereFilter);
try {
String jsonResponse = client.requestGet("Account", requestParams);
} catch(InvalidKeyException e) {
e.printStackTrace();
} catch(IOException e) {
e.printStackTrace();
} catch(RequestException e) {
e.printStackTrace();
}
}
}