API-LIB for JavaScript

Usage no npm install needed!

<script type="module">
  import aemsApilib from 'https://cdn.skypack.dev/@aems/apilib';


apilib (v0.0.4)

This class library is meant to be used for communication with the AEMS-Main-API (TODO: Insert link once repository has been created) within JavaScript/TypeScript.

:exclamation: Version notice

As indicated by the version number, the API should not be considered stable yet.


npm install @aems/apilib --save

// Optional dependency to map JSON data to actual TypeScript objects
npm install @aems/core-classlib --save 


You can use the ApiService class to perform authentication and requests to the API. You will probably want to make it some sort of singleton in your project.

const apiService = new ApiService('http://localhost:8085'); // Replace with real API url

Before you can query stuff or insert stuff you will need to authenticate.

// Preferred:
apiService.authenticate("username", "password")
    .then(token => {
        console.log(`Login OK, token: ${token}`);
        // do whatever you wanna do after login was successful
    .catch((error: AxiosError) => console.log(`Login has failed!`, error.message));

// OR: Set the API token manually if you obtained it somehow
// Note that this token will not be checked for correctness or validity.

Then you can use the QueryRequestBuilder and the DmlRequestBuilder in order to configure your requests.

const aemsQuery = `
users {
    id ? between $MIN and $MAX
const queryBuilder = new QueryRequestBuilder(aemsQuery);
queryBuilder.addPlaceholder("MIN", 0);  // Placeholders in query are signified by a leading '

queryBuilder.addPlaceholder("MAX", 10);
const dmlBuilder = new DmlRequestBuilder()
    .insert("appliance", {
        appliance_id: "38569",
        name: "AT000000039482",
        user: 21
    .update("appliance", "38569", {     // Second argument is ID of entity you are wishing to update
        name: "DE0000004858493"         // Third argument is object with properties you want changed
    .delete("appliance", "38569");      

And then to execute your requests call:

const myBuilder = new QueryRequestBuilder();
// ...