Welcome to the LDC Via API! You can use our API to access LDC Via API endpoints, this allows you to access and modify documents within databases in your organisation.
If you're just getting started with LDC Via, we have a page dedicated to developers.
You can view code example POST and response data below each section and some of the sections contain code samples as well.
We're always looking to improve the documentation, so if you spot a mistake or have an idea, please contact us.
Every operation you perform with the API must be authenticated. You can authenticate two different ways: either pass an HTTP header called "apikey", or generate a session cookie and make sure that it is passed with each request.
To locate your API key, this video will be useful:
You can use whatever language you prefer to access the LDC Via API, most commonly this might be JavaScript, Java, .Net or PHP.
Below are a few examples of how to consume LDC Via services
/*
* Get the properties of the database "mydatabase" and log them to the browser console
*/
$.ajax({
dataType: 'json',
type: 'GET',
headers: { 'apikey': apikey },
url: 'https://eu.ldcvia.com/1.0/database/mydatabase',
success: function(res){
console.log(res);
},
error: function(xhr, status, error){
if (xhr.status == 401){
alert("You do not have the rights to access the database");
}else{
alert(status + '\n' + error);
}
}
}
);
/*
* Update the database properties to make the database readonly, have a title of "New Title",
* create a full text index and add some meta data
*/
var data = {readonly:true, title: "New Title", indexed: true, meta: {["unstructured array item"]}};
$.ajax({
dataType: 'json',
type: 'POST',
data: data,
headers: { 'apikey': apikey },
url: 'https://eu.ldcvia.com/1.0/database/mydatabase',
success: function(res){
//do something
},
error: function(xhr, status, error){
if (xhr.status == 401){
alert("You do not have the rights to access the database");
}else{
alert(status + '\n' + error);
}
}
});
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Map;
import org.apache.http.HttpResponse;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.HttpClientBuilder;
import com.google.gson.Gson;
public class GetDatabaseDetails {
public class DataInfo {
private String id = null;
private String name = null;
}
public class WebObjectResponse {
private Map details;
}
public static void main(String[] args) {
try {
// create HTTP Client
HttpClient httpClient = HttpClientBuilder.create().build();
// Create new getRequest with below mentioned URL
HttpGet getRequest = new HttpGet("https://eu.ldcvia.com/database/mydatabase");
getRequest.addHeader("accept", "application/json");
getRequest.addHeader("apikey", "mysupersecretapikey");
// Execute your request and catch response
HttpResponse response = httpClient.execute(getRequest);
// Check for HTTP response code: 200 = success
if (response.getStatusLine().getStatusCode() != 200) {
throw new RuntimeException("Failed : HTTP error code : " + response.getStatusLine().getStatusCode());
}
// Get-Capture Complete application/xml body response
BufferedReader br = new BufferedReader(new InputStreamReader((response.getEntity().getContent())));
String json = "";
String output;
// Simply iterate through XML response and show on console.
while ((output = br.readLine()) != null) {
json += output;
}
Gson gson = new Gson();
WebObjectResponse dbdetails = gson.fromJson(json, WebObjectResponse.class);
} catch (ClientProtocolException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
}
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Map;
import org.apache.http.HttpResponse;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.HttpClientBuilder;
public class SetDatabaseDetails {
public class DataInfo {
private String id = null;
private String name = null;
}
public class WebObjectResponse {
private Map details;
}
public static void main(String[] args) {
try {
// create HTTP Client
HttpClient httpClient = HttpClientBuilder.create().build();
// Create new postRequest with below mentioned URL
HttpPost postRequest = new HttpPost("https://eu.ldcvia.com/database/mydatabase");
StringEntity params =new StringEntity("{\"title\":\"New Title\",\"indexed\":true} ");
postRequest.setEntity(params);
postRequest.addHeader("Content-Type", "application/json");
postRequest.addHeader("apikey", "mysupersecretapikey");
// Execute your request and catch response
HttpResponse response = httpClient.execute(postRequest);
// Check for HTTP response code: 200 = success
if (response.getStatusLine().getStatusCode() != 200) {
throw new RuntimeException("Failed : HTTP error code : " + response.getStatusLine().getStatusCode());
}
// Get-Capture Complete application/xml body response
BufferedReader br = new BufferedReader(new InputStreamReader((response.getEntity().getContent())));
String json = "";
String output;
// Simply iterate through XML response and show on console.
while ((output = br.readLine()) != null) {
json += output;
}
Gson gson = new Gson();
WebObjectResponse dbdetails = gson.fromJson(json, WebObjectResponse.class);
} catch (ClientProtocolException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
}
Loading...