No Translation available yet
You have Czech selected as language but this page has not been translated yet. Translate the page or view the content in the default space language below.
Display default
When to create API endpoint
There are several situations, where you need a specific endpoint for your application:
- Custom business logic is required
- Calling 3rd party systems is necessary
- Client API does not offer desired functions
Specification
An API Endpoint is Groovy/Java class compiled and executed on the server at runtime. It may use 3rd party JAR libraries provided as JAR resource inside the extension.
On the source code level, it's possible to use variety of classes and methods, including access to basic BellaDati objects and data - Data sets, Reports, Machine Learning.
API Endpoint is exposed to the outter world using HTTP server and is accepting HTTP GET, POST, DELETE and PUT requests.
Endpoint URL |
---|
http://belladati_host/extension/detail:endpoint/EXT_ID/ENDPOINT_NAME |
http://belladati_host/ext/detail?id=EXT_ID&action=ENDPOINT_NAME |
Structure
API Endpoint a class written is Groovy/Java and overriding doGet(), doPost(), doPut() and doDelete() methods.
package com.belladati;
import com.belladati.extension.BaseExtensionEndpoint;
import org.apache.tapestry5.StreamResponse;
public class MyEndpoint extends BaseExtensionEndpoint {
@Override
public StreamResponse doGet() {
String text = "GET method called with parameter: " + getParameter("say")
return createStreamResponse(text, "text/plain", 200)
}
@Override
public StreamResponse doPost() {
String text = "POST method called with parameter: " + getParameter("say")
return createStreamResponse(text, "text/plain", 200)
}
}
Types whitelist
Beside types and packages below, all types and packages from provided JAR library are on white list too.
DecimalFormat.class, NumberFormat.class, LocalDate.class, LocalTime.class, DateTime.class, Arrays.class, ArrayUtils.class, SystemOutputInterceptor.class, Integer.class, Long.class, Double.class, Float.class, BigDecimal.class, String.class, StringUtils.class, JSON.class, JSONObject.class, JSONArray.class, Filter.class, OperationType.class, Map.class
Package name |
---|
java.util |
java.util.regex |
org.apache.commons.logging |
com.belladati.json |