API

Auth

You need this method to retrieve Short Access Token




Subscribe

Get short living accessToken to be able make all helpful requests.

Life time of this token just 1 day, then you need to renew it by this command

This method requires Long Access Token which you can retrieve using Database Connect method

Method

POST

URI

/api/auth/subscribe

Headers

Content-Type	application/json
Authorization   Bearer <long-access-token>

Body

{
    "data": [
        {
            "permissions": {
                "isAdmin": true,
                "tables": {}
            }
        }
    ],
    "context": {}
}

data: array - it's container for payload, it always should be an array of objects

data.permissions: object - allows to define permissions for admin and normal users

data.permissions.isAdmin: boolean - gives full access if is true

data.permissions.tables: object - allows to define special permissions per table, where 'key' of each object properties is 'tableName' from specific table access should be restricted to

{
  "c0a45736-6225-4fd0-bd3c-70e956b3e9d6": {
      "create": true,
      "read": true,
      "update": true,
      "delete": false
  }
}

Full view of permissions object should be like this:

{
  "permissions": {
    "isAdmin": false,
    "tables": {
      "c0a45736-6225-4fd0-bd3c-70e956b3e9d6": {
        "create": true,
        "read": true,
        "update": true,
        "delete": false
      }
    } 
  }
}

Result

{
    "accessToken": "<short-access-token>",
    "channel": "mycooldomain_net"
}

Examples

const myHeaders = new Headers()
myHeaders.append("Content-Type", "application/json")
myHeaders.append("Authorization", "Bearer <long-access-token>")

const apiURL = "https://api-test-tool.backend.spacemonopoly3d.com/"
const payload = {
  data: [{
      permissions: {
          isAdmin: false,
          tables: {
              "c0a45736-6225-4fd0-bd3c-70e956b3e9d6": {
                  create: true,
                  read: true,
                  update: true,
                  delete: false
              }
          }
      }
  }]
}

const requestOptions = {
  method: 'POST',
  headers: myHeaders,
  body: JSON.stringify(payload),
  redirect: 'follow'
}

fetch(apiURL + "api/auth/subscribe", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error))
const request = require('request')

const apiURL = 'https://api-test-tool.backend.spacemonopoly3d.com/'
const payload = {
  data: [{
      permissions: {
          isAdmin: false,
          tables: {
              "c0a45736-6225-4fd0-bd3c-70e956b3e9d6": {
                  create: true,
                  read: true,
                  update: true,
                  delete: false
              }
          }
      }
  }]
}
const options = {
  'method': 'POST',
  'url': apiURL + 'api/auth/subscribe',
  'headers': {
    'Content-Type': ['application/json'],
    'Authorization': 'Bearer <long-access-token>'
  },
  body: JSON.stringify(payload)
}

request(options, function (error, response) { 
  if (error) throw new Error(error)
  console.log(response.body)
})
<?php
require_once 'HTTP/Request2.php';

$request = new HTTP_Request2();
$request->setUrl('https://api-test-tool.backend.spacemonopoly3d.com/api/auth/subscribe');
$request->setMethod(HTTP_Request2::METHOD_POST);
$request->setConfig(array(
  'follow_redirects' => TRUE
));

$longAccessToken = 'long-access-token';
$request->setHeader(array(
  'Content-Type' => 'application/json',
  'Authorization' => "Bearer {$longAccessToken}"
));

$payload = array(
    'data' => array(
        'permissions' => array(
            'isAdmin' => false,
            'tables' => array(
                'c0a45736-6225-4fd0-bd3c-70e956b3e9d6' => array(
                    'create' => true,
                     'read' => true,
                     'update' => true,
                     'delete' => false
                )   
            )   
        )
    )
);
$request->setBody(json_encode($payload));
try {
  $response = $request->send();
  if ($response->getStatus() == 200) {
    echo $response->getBody();
  }
  else {
    echo 'Unexpected HTTP status: ' . $response->getStatus() . ' ' .
    $response->getReasonPhrase();
  }
}
catch(HTTP_Request2_Exception $e) {
  echo 'Error: ' . $e->getMessage();
}



Database

This API allows connect/disconnect your databases.




Connect

Connect to existing database or create new one.

This method returns Long Access Token which is required to get Short Access Token - main token for all requests.

Set parameter isNewUser: true to register new user.

Method

POST

URI

/api/database/connection

Headers

Content-Type	application/json

Body

{
    "data": [
        {
            "email": "some-user@example.com",
            "password": "some_secret_password",
            "name": "Some User"
        }
    ],
    "context": {
        "domain": "mycooldomain.net",
        "isNewUser": true,
        "location": "custom",
        "locale": "en"
    }
}

Result

{
    "accessToken": "<long-access-token>",
    "name": "Some User"
}

Examples

const myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");

const raw = JSON.stringify({
  "data": [
    {
      "email": "some-user@example.com",
      "password": "some_secret_password",
      "name": "Some User",
    }
  ],
  "context": {
    "domain": "mycooldomain.net",
    "isNewUser": true,
    "location": "custom",
    "locale": "en",
  },
});

const requestOptions = {
  method: 'POST',
  headers: myHeaders,
  body: raw,
  redirect: 'follow'
};

fetch("https://api-test-tool.backend.spacemonopoly3d.com/api/database/connection", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));
const request = require('request');
const options = {
  'method': 'POST',
  'url': 'https://api-test-tool.backend.spacemonopoly3d.com/api/database/connection',
  'headers': {
    'Content-Type': ['application/json'],
  },
  body: JSON.stringify({
    "data": [
      {
        "email": "some-user@example.com",
        "password": "some_secret_password",
        "name": "Some User",
      }
    ],
    "context": {
      "domain": "mycooldomain.net",
      "isNewUser": true,
      "location": "custom",
      "locale": "en",
    }
  }),
};

request(options, function (error, response) { 
  if (error) throw new Error(error);
  console.log(response.body);
});
<?php
require_once 'HTTP/Request2.php';
$request = new HTTP_Request2();
$request->setUrl('https://api-test-tool.backend.spacemonopoly3d.com/api/database/connection');
$request->setMethod(HTTP_Request2::METHOD_POST);
$request->setConfig(array(
  'follow_redirects' => TRUE
));
$request->setHeader(array(
  'Content-Type' => 'application/json'
));
$request->setBody(json_encode(array(
  "data" => [
    array(
      "email" => "some-user@example.com",
      "password" => "some_secret_password",
      "name" => "Some User",
    )
  ],
  "context" => array(
    "domain" => "mycooldomain.net",
    "isNewUser" => true,
    "location" => "custom",
    "locale" => "en",
  )
)));

try {
  $response = $request->send();
  if ($response->getStatus() == 200) {
    echo $response->getBody();
  }
  else {
    echo 'Unexpected HTTP status: ' . $response->getStatus() . ' ' .
    $response->getReasonPhrase();
  }
}
catch(HTTP_Request2_Exception $e) {
  echo 'Error: ' . $e->getMessage();
}



Disconnect

Disconnect database

Method

DELETE

URI

/api/database/connection

Headers

Content-Type	application/json
Authorization   Bearer <long-access-token>

Result

{}

Examples

const myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Authorization", "Bearer <long-access-token>");

const apiURL = 'https://api-test-tool.backend.spacemonopoly3d.com/'
const requestOptions = {
  method: 'DELETE',
  headers: myHeaders,
  redirect: 'follow'
};

fetch(apiURL + "api/database/connection", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));
const request = require('request');
const apiURL = 'https://api-test-tool.backend.spacemonopoly3d.com/'
const options = {
  'method': 'DELETE',
  'url': apiURL + 'api/database/connection',
  'headers': {
    'Content-Type': ['application/json'],
    'Authorization': 'Bearer <long-access-token>'
  }
};
request(options, function (error, response) { 
  if (error) throw new Error(error);
  console.log(response.body);
});
<?php
require_once 'HTTP/Request2.php';
$request = new HTTP_Request2();
$request->setUrl('https://api-test-tool.backend.spacemonopoly3d.com/api/database/connection');
$request->setMethod(HTTP_Request2::METHOD_DELETE);
$request->setConfig(array(
  'follow_redirects' => TRUE
));
$longAccessToken = 'long_access_token';
$request->setHeader(array(
  'Content-Type' => 'application/json',
  'Authorization' => "Bearer {$longAccessToken}"
));

try {
  $response = $request->send();
  if ($response->getStatus() == 200) {
    echo $response->getBody();
  }
  else {
    echo 'Unexpected HTTP status: ' . $response->getStatus() . ' ' .
    $response->getReasonPhrase();
  }
}
catch(HTTP_Request2_Exception $e) {
  echo 'Error: ' . $e->getMessage();
}



Metadata

This API works with database tables.

You can create, retrieve, update and delete your tables.




Create

Method

POST

URI

/api/metadata

Headers

Content-Type	application/json
Authorization   Bearer <short-access-token>

Body

{
    "data": [
        {
            "name": "Table 1"
        }
    ],
    "context": {}
}

Result

[
  {
    "id": 102,
    "name": "Table 1",
    "tableName": "5df11e6e-c9e3-4e29-a499-0fdbce0bd101",
    "description": "Some description",
    "fields": [
      {
        "id": 1,
        "name": "id",
        "allowNull": false,
        "autoIncrement": true,
        "primaryKey": true,
        "type": "integer",
        "extend": {
          "isSystem": true,
          "caption": "ID",
          "order": 0
        }
      },
      {
        "id": 2,
        "name": "createdAt",
        "allowNull": false,
        "type": "datetime",
        "extend": {
          "isSystem": true,
          "caption": "Created At",
          "order": 1000
        }
      },
      {
        "id": 3,
        "name": "updatedAt",
        "allowNull": false,
        "type": "datetime",
        "extend": {
          "isSystem": true,
          "caption": "Updated At",
          "order": 1001
        }
      }
    ],
    "options": {},
    "updatedAt": "2020-04-03T10:23:09.031Z",
    "createdAt": "2020-04-03T10:23:09.031Z"
  }
]

Examples

var myHeaders = new Headers();
myHeaders.append("Authorization", "Bearer <short-access-token>");
myHeaders.append("Content-Type", "application/json");

var raw = JSON.stringify({
  "data": [
    {
      "name": "Table 1"
    }
  ],
  "context": {}
});

var requestOptions = {
  method: 'POST',
  headers: myHeaders,
  body: raw,
  redirect: 'follow'
};

fetch("https://backend.spacemonopoly3d.com/api/metadata", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));
var request = require('request');
var options = {
  'method': 'POST',
  'url': 'https://backend.spacemonopoly3d.com/api/metadata',
  'headers': {
    'Authorization': 'Bearer <short-access-token>',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    "data": [
      {
        "name": "Table 1"
      }
    ],
    "context": {}
  })

};
request(options, function (error, response) { 
  if (error) throw new Error(error);
  console.log(response.body);
});

<?php
require_once 'HTTP/Request2.php';
$request = new HTTP_Request2();
$request->setUrl('https://backend.spacemonopoly3d.com/api/metadata');
$request->setMethod(HTTP_Request2::METHOD_POST);
$request->setConfig(array(
  'follow_redirects' => TRUE
));
$request->setHeader(array(
  'Authorization' => 'Bearer <short-access-token>',
  'Content-Type' => 'application/json'
));
$request->setBody(json_encode(array(
  "data" => [
    array(
      "name" => "Table 1"
    )
  ],
  "context" => array()
)));
try {
  $response = $request->send();
  if ($response->getStatus() == 200) {
    echo $response->getBody();
  }
  else {
    echo 'Unexpected HTTP status: ' . $response->getStatus() . ' ' .
    $response->getReasonPhrase();
  }
}
catch(HTTP_Request2_Exception $e) {
  echo 'Error: ' . $e->getMessage();
}



Get

Method

GET

URI

/api/metadata

Headers

Content-Type	application/json
Authorization   Bearer <short-access-token>

Body

{
    "filter": {
      "attributes": [
        {
            "column": "id",
            "alias": "metadataId"
        },
        "name",
        {
            "column": "tableName",
            "alias": "metaTableName"
        },
        "fields",
        "createdAt"
      ],
      "where": {
        "operator": "=",
        "args": ["id", 102]
      }
    },
    "context": {}
}

Result

{
  "count": 1,
  "rows": [
    {
        "metadataId": 102,
        "name": "Table 1",
        "metaTableName": "5df11e6e-c9e3-4e29-a499-0fdbce0bd101",
        "fields": [
          {
            "id": 1,
            "name": "id",
            "allowNull": false,
            "autoIncrement": true,
            "primaryKey": true,
            "type": "integer",
            "extend": {
              "isSystem": true,
              "caption": "ID",
              "order": 0
            }
          },
          {
            "id": 2,
            "name": "createdAt",
            "allowNull": false,
            "type": "datetime",
            "extend": {
              "isSystem": true,
              "caption": "Created At",
              "order": 1000
            }
          },
          {
            "id": 3,
            "name": "updatedAt",
            "allowNull": false,
            "type": "datetime",
            "extend": {
              "isSystem": true,
              "caption": "Updated At",
              "order": 1001
            }
          }
        ],
        "createdAt": "2020-04-03T10:23:09.031Z"
    }
  ]
}

Examples

var myHeaders = new Headers();
myHeaders.append("Authorization", "Bearer <short-access-token>");
myHeaders.append("Content-Type", "application/json");
myHeaders.append("X-HTTP-Method-Override", "GET");

var raw = JSON.stringify({
  "filter": {
    "attributes": [
      {
        "column": "id",
        "alias": "metadataId"
      },
      "name",
      {
        "column": "tableName",
        "alias": "metaTableName"
      },
      "fields",
      "createdAt"
    ],
    "where": {
      "operator": "=",
      "args": ["id", 131]
    }
  },
  "context": {}
});

var requestOptions = {
  method: 'POST',
  headers: myHeaders,
  body: raw,
  redirect: 'follow'
};

fetch("https://backend.spacemonopoly3d.com/api/metadata", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));
var request = require('request');
var options = {
  'method': 'POST',
  'url': 'https://backend.spacemonopoly3d.com/api/metadata',
  'headers': {
    'Authorization': 'Bearer <short-access-token>',
    'Content-Type': 'application/json',
    'X-HTTP-Method-Override': 'GET'
  },
  body: JSON.stringify({
    "filter": {
      "attributes": [
        {
          "column": "id",
          "alias": "metadataId"
        },
        "name",
        {
          "column": "tableName",
          "alias": "metaTableName"
        },
        "fields",
        "createdAt"
      ],
      "where": {
        "operator": "=",
        "args": ["id", 131]
      }
    },
    "context": {}
  })

};
request(options, function (error, response) { 
  if (error) throw new Error(error);
  console.log(response.body);
});

<?php
require_once 'HTTP/Request2.php';
$request = new HTTP_Request2();
$request->setUrl('https://backend.spacemonopoly3d.com/api/metadata');
$request->setMethod(HTTP_Request2::METHOD_POST);
$request->setConfig(array(
  'follow_redirects' => TRUE
));
$request->setHeader(array(
  'Authorization' => 'Bearer <short-access-token>',
  'Content-Type' => 'application/json',
  'X-HTTP-Method-Override' => 'GET'
));
$request->setBody(json_encode(array(
  "filter" => array(
    "attributes" => [
      array(
        "column" => "id",
        "alias" => "metadataId"
      ),
      "name",
      array(
        "column" => "tableName",
        "alias" => "metaTableName"
      ),
      "fields",
      "createdAt"
    ],
    "where" => array(
      "operator" => "=",
      "args" => ["id", 131]
    )
  ),
  "context" => array()
)));
try {
  $response = $request->send();
  if ($response->getStatus() == 200) {
    echo $response->getBody();
  }
  else {
    echo 'Unexpected HTTP status: ' . $response->getStatus() . ' ' .
    $response->getReasonPhrase();
  }
}
catch(HTTP_Request2_Exception $e) {
  echo 'Error: ' . $e->getMessage();
}



Update

This method allows change metadata of table like name, fields, description, options.

When changing property fields this applies changes to real table columns, so you can add new, rename, remove them, change their properties: make column Indexed, Mandatory, Encrypted.

Method

PUT

URI

/api/metadata

Headers

Content-Type	application/json
Authorization   Bearer <short-access-token>

Body

{
    "data": [
        {
            "id": 102,
            "name": "Table 2"
        }
    ],
    "context": {}
}

Result

[
  {
    "id": 102,
    "name": "Table 2",
    "tableName": "5df11e6e-c9e3-4e29-a499-0fdbce0bd101",
    "description": "Some description",
    "fields": [
      {
        "id": 1,
        "name": "id",
        "allowNull": false,
        "autoIncrement": true,
        "primaryKey": true,
        "type": "integer",
        "extend": {
          "isSystem": true,
          "caption": "ID",
          "order": 0
        }
      },
      {
        "id": 2,
        "name": "createdAt",
        "allowNull": false,
        "type": "datetime",
        "extend": {
          "isSystem": true,
          "caption": "Created At",
          "order": 1000
        }
      },
      {
        "id": 3,
        "name": "updatedAt",
        "allowNull": false,
        "type": "datetime",
        "extend": {
          "isSystem": true,
          "caption": "Updated At",
          "order": 1001
        }
      }
    ],
    "options": {},
    "updatedAt": "2020-04-07T10:10:09.031Z",
    "createdAt": "2020-04-03T10:23:09.031Z"
  }
]

Examples

var myHeaders = new Headers();
myHeaders.append("Authorization", "Bearer <short-access-token>");
myHeaders.append("Content-Type", "application/json");

var raw = JSON.stringify({
  "data": [
    {
      "id": 131,
      "name": "Table 2"
    }
  ],
  "context": {}
});

var requestOptions = {
  method: 'PUT',
  headers: myHeaders,
  body: raw,
  redirect: 'follow'
};

fetch("https://backend.spacemonopoly3d.com/api/metadata", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));
var request = require('request');
var options = {
  'method': 'PUT',
  'url': 'https://backend.spacemonopoly3d.com/api/metadata',
  'headers': {
    'Authorization': 'Bearer <short-access-token>',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    "data": [
      {
        "id": 131,
        "name": "Table 2"
      }
    ],
    "context": {}
  })
};
request(options, function (error, response) { 
  if (error) throw new Error(error);
  console.log(response.body);
});
<?php
require_once 'HTTP/Request2.php';
$request = new HTTP_Request2();
$request->setUrl('https://backend.spacemonopoly3d.com/api/metadata');
$request->setMethod(HTTP_Request2::METHOD_PUT);
$request->setConfig(array(
  'follow_redirects' => TRUE
));
$request->setHeader(array(
  'Authorization' => 'Bearer <short-access-token>',
  'Content-Type' => 'application/json'
));
$request->setBody(json_encode(array(
  "data" => [
    array(
      "id" => 131,
      "name" => "Table 2"
    )
  ],
  "context" => array()
)));
try {
  $response = $request->send();
  if ($response->getStatus() == 200) {
    echo $response->getBody();
  }
  else {
    echo 'Unexpected HTTP status: ' . $response->getStatus() . ' ' .
    $response->getReasonPhrase();
  }
}
catch(HTTP_Request2_Exception $e) {
  echo 'Error: ' . $e->getMessage();
}



Delete

This method allows to delete existing metadata with related table in DB

Method

DELETE

URI

/api/metadata

Headers

Content-Type	application/json
Authorization   Bearer <short-access-token>

Body

{
    "filter": {
      "where": {
        "operator": "=",
        "args": ["id", 102]
      }
    },
    "context": {}
}

Result

[
  {
    "id": 102,
    "name": "Table 2",
    "tableName": "5df11e6e-c9e3-4e29-a499-0fdbce0bd101",
    "description": "Some description",
    "fields": [
      {
        "id": 1,
        "name": "id",
        "allowNull": false,
        "autoIncrement": true,
        "primaryKey": true,
        "type": "integer",
        "extend": {
          "isSystem": true,
          "caption": "ID",
          "order": 0
        }
      },
      {
        "id": 2,
        "name": "createdAt",
        "allowNull": false,
        "type": "datetime",
        "extend": {
          "isSystem": true,
          "caption": "Created At",
          "order": 1000
        }
      },
      {
        "id": 3,
        "name": "updatedAt",
        "allowNull": false,
        "type": "datetime",
        "extend": {
          "isSystem": true,
          "caption": "Updated At",
          "order": 1001
        }
      }
    ],
    "options": {},
    "updatedAt": "2020-04-03T10:23:09.031Z",
    "createdAt": "2020-04-03T10:23:09.031Z"
  }
]

Examples

var myHeaders = new Headers();
myHeaders.append("Authorization", "Bearer <short-access-token>");
myHeaders.append("Content-Type", "application/json");
myHeaders.append("X-HTTP-Method-Override", "DELETE");

var raw = JSON.stringify({
  "filter": {
    "where": {
      "operator": "=",
      "args": ["id", 131]
    }
  },
  "context": {}
});

var requestOptions = {
  method: 'POST',
  headers: myHeaders,
  body: raw,
  redirect: 'follow'
};

fetch("https://backend.spacemonopoly3d.com/api/metadata", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));
var request = require('request');
var options = {
  'method': 'POST',
  'url': 'https://backend.spacemonopoly3d.com/api/metadata',
  'headers': {
    'Authorization': 'Bearer <short-access-token>',
    'Content-Type': 'application/json',
    'X-HTTP-Method-Override': 'DELETE'
  },
  body: JSON.stringify({
    "filter": {
      "where": {
        "operator": "=",
        "args": ["id", 131]
      }
    },
    "context": {}
  })
};
request(options, function (error, response) { 
  if (error) throw new Error(error);
  console.log(response.body);
});

<?php
require_once 'HTTP/Request2.php';
$request = new HTTP_Request2();
$request->setUrl('https://backend.spacemonopoly3d.com/api/metadata');
$request->setMethod(HTTP_Request2::METHOD_POST);
$request->setConfig(array(
  'follow_redirects' => TRUE
));
$request->setHeader(array(
  'Authorization' => 'Bearer <short-access-token>',
  'Content-Type' => 'application/json',
  'X-HTTP-Method-Override' => 'DELETE'
));
$request->setBody(json_encode(array(
  "filter" => array(
    "where" => array(
      "operator" => "=",
      "args" => ["id", 131]
    )
  ),
  "context" => array()
)));
try {
  $response = $request->send();
  if ($response->getStatus() == 200) {
    echo $response->getBody();
  }
  else {
    echo 'Unexpected HTTP status: ' . $response->getStatus() . ' ' .
    $response->getReasonPhrase();
  }
}
catch(HTTP_Request2_Exception $e) {
  echo 'Error: ' . $e->getMessage();
}



Objects

Main API which works with table rows.

Allows to add, get, change and delete table rows.

Each method has context: tableName - it should be table name of existing Metadata. We use UUID v4 as tableName.




Create

This method allows to create one or more objects for specific tableName as context.

Method

POST

URI

/api/objects

Headers

Content-Type	application/json
Authorization   Bearer <short-access-token>

Body

{
    "data": [
        {
            "customField": "Test value"
        }
    ],
    "context": {
        "tableName": "245ce633-796f-4dfa-ae6f-4b2762adbf44"
    }
}

Result

[
    {
        "id": 5,
        "customField": "Test value",
        "updatedAt": "2020-04-07T17:31:21.658Z",
        "createdAt": "2020-04-07T17:31:21.658Z"
    }
]

Examples

var myHeaders = new Headers();
myHeaders.append("Authorization", "Bearer <short-access-token>");
myHeaders.append("Content-Type", "application/json");

var raw = JSON.stringify({
  "data": [
    {
      "customField": "Test value"
    }
  ],
  "context": {
    "tableName": "245ce633-796f-4dfa-ae6f-4b2762adbf44"
  }
});

var requestOptions = {
  method: 'POST',
  headers: myHeaders,
  body: raw,
  redirect: 'follow'
};

fetch("https://backend.spacemonopoly3d.com/api/objects", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));
var request = require('request');
var options = {
  'method': 'POST',
  'url': 'https://backend.spacemonopoly3d.com/api/objects',
  'headers': {
    'Authorization': 'Bearer <short-access-token>',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    "data": [
      {
        "customField": "Test value"
      }
    ],
    "context": {
      "tableName": "245ce633-796f-4dfa-ae6f-4b2762adbf44"
    }
  })
};
request(options, function (error, response) { 
  if (error) throw new Error(error);
  console.log(response.body);
});
<?php
require_once 'HTTP/Request2.php';
$request = new HTTP_Request2();
$request->setUrl('https://backend.spacemonopoly3d.com/api/objects');
$request->setMethod(HTTP_Request2::METHOD_POST);
$request->setConfig(array(
  'follow_redirects' => TRUE
));
$request->setHeader(array(
  'Authorization' => 'Bearer <short-access-token>',
  'Content-Type' => 'application/json'
));
$request->setBody(json_encode(array(
  "data" => [
    array(
      "customField" => "Test value"
    )
  ],
  "context" => array(
    "tableName" => "245ce633-796f-4dfa-ae6f-4b2762adbf44"
  )
)));
try {
  $response = $request->send();
  if ($response->getStatus() == 200) {
    echo $response->getBody();
  }
  else {
    echo 'Unexpected HTTP status: ' . $response->getStatus() . ' ' .
    $response->getReasonPhrase();
  }
}
catch(HTTP_Request2_Exception $e) {
  echo 'Error: ' . $e->getMessage();
}



Get

This method allows to find existing object by its id and tableName as context.

Use Metadata Create to get tableName.

See Where for more details.

Method

GET

URI

/api/objects

Headers

Content-Type	application/json
Authorization   Bearer <short-access-token>

Body

{
    "filter": {
        "where": {
          "operator": "=",
          "args": ["id", 5]
        }
    },
    "context": {
        "tableName": "245ce633-796f-4dfa-ae6f-4b2762adbf44"
    }
}

Result

{
    "count": 1,
    "rows": [
        {
            "id": 5,
            "createdAt": "2020-04-07T17:31:21.658Z",
            "updatedAt": "2020-04-07T17:31:21.658Z",
            "customField": "Test value"
        }
    ]
}

Examples

var myHeaders = new Headers();
myHeaders.append("Authorization", "Bearer <short-access-token>");
myHeaders.append("Content-Type", "application/json");
myHeaders.append("X-HTTP-Method-Override", "GET");

var raw = JSON.stringify({
  "filter": {
    "where": {
      "operator": "=",
      "args": ["id", 5]
    }
  },
  "context": {
    "tableName": "245ce633-796f-4dfa-ae6f-4b2762adbf44"
  }
});

var requestOptions = {
  method: 'POST',
  headers: myHeaders,
  body: raw,
  redirect: 'follow'
};

fetch("https://backend.spacemonopoly3d.com/api/objects", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));
var request = require('request');
var options = {
  'method': 'POST',
  'url': 'https://backend.spacemonopoly3d.com/api/objects',
  'headers': {
    'Authorization': 'Bearer <short-access-token>',
    'Content-Type': 'application/json',
    'X-HTTP-Method-Override': 'GET'
  },
  body: JSON.stringify({
    "filter": {
      "where": {
        "operator": "=",
        "args": ["id", 5]
      }
    },
    "context": {
      "tableName": "245ce633-796f-4dfa-ae6f-4b2762adbf44"
    }
  })

};
request(options, function (error, response) { 
  if (error) throw new Error(error);
  console.log(response.body);
});
<?php
require_once 'HTTP/Request2.php';
$request = new HTTP_Request2();
$request->setUrl('https://backend.spacemonopoly3d.com/api/objects');
$request->setMethod(HTTP_Request2::METHOD_POST);
$request->setConfig(array(
  'follow_redirects' => TRUE
));
$request->setHeader(array(
  'Authorization' => 'Bearer <short-access-token>',
  'Content-Type' => 'application/json',
  'X-HTTP-Method-Override' => 'GET'
));
$request->setBody(json_encode(array(
  "filter" => array(
    "where" => array(
      "operator" => "=",
      "args" => ["id", 5]
    )
  ),
  "context" => array(
    "tableName" => "245ce633-796f-4dfa-ae6f-4b2762adbf44"
  )
)));
try {
  $response = $request->send();
  if ($response->getStatus() == 200) {
    echo $response->getBody();
  }
  else {
    echo 'Unexpected HTTP status: ' . $response->getStatus() . ' ' .
    $response->getReasonPhrase();
  }
}
catch(HTTP_Request2_Exception $e) {
  echo 'Error: ' . $e->getMessage();
}



Update

This method allows update existing object field by its id and tableName as context.

Method

PUT

URI

/api/objects

Headers

Content-Type	application/json
Authorization   Bearer <short-access-token>

Body

{
    "data": [
        {
            "id": 5,
            "customField": "Test value 1"
        }
    ],
    "context": {
        "tableName": "245ce633-796f-4dfa-ae6f-4b2762adbf44"
    }
}

Result

[
    {
        "id": 5,
        "createdAt": "2020-04-07T17:31:21.658Z",
        "updatedAt": "2020-04-07T17:41:31.561Z",
        "customField": "Test value 1"
    }
]

Examples

var myHeaders = new Headers();
myHeaders.append("Authorization", "Bearer <short-access-token>");
myHeaders.append("Content-Type", "application/json");

var raw = JSON.stringify({
  "data": [
    {
      "id": 5,
      "customField": "Test value 1"
    }
  ],
  "context": {
    "tableName": "245ce633-796f-4dfa-ae6f-4b2762adbf44"
  }
});

var requestOptions = {
  method: 'PUT',
  headers: myHeaders,
  body: raw,
  redirect: 'follow'
};

fetch("https://backend.spacemonopoly3d.com/api/objects", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));
var request = require('request');
var options = {
  'method': 'PUT',
  'url': 'https://backend.spacemonopoly3d.com/api/objects',
  'headers': {
    'Authorization': 'Bearer <short-access-token>',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    "data": [
      {
        "id": 5,
        "customField": "Test value 1"
      }
    ],
    "context": {
      "tableName": "245ce633-796f-4dfa-ae6f-4b2762adbf44"
    }
  })
};
request(options, function (error, response) { 
  if (error) throw new Error(error);
  console.log(response.body);
});
<?php
require_once 'HTTP/Request2.php';
$request = new HTTP_Request2();
$request->setUrl('https://backend.spacemonopoly3d.com/api/objects');
$request->setMethod(HTTP_Request2::METHOD_PUT);
$request->setConfig(array(
  'follow_redirects' => TRUE
));
$request->setHeader(array(
  'Authorization' => 'Bearer <short-access-token>',
  'Content-Type' => 'application/json'
));
$request->setBody(json_encode(array(
  "data" => [
    array(
      "id" => 5,
      "customField" => "Test value 1"
    )
  ],
  "context" => array(
    "tableName" => "245ce633-796f-4dfa-ae6f-4b2762adbf44"
  )
)));
try {
  $response = $request->send();
  if ($response->getStatus() == 200) {
    echo $response->getBody();
  }
  else {
    echo 'Unexpected HTTP status: ' . $response->getStatus() . ' ' .
    $response->getReasonPhrase();
  }
}
catch(HTTP_Request2_Exception $e) {
  echo 'Error: ' . $e->getMessage();
}



Delete

This method allows to delete existing objects by their id and tableName as context.

See Where for more details.

Method

DELETE

URI

/api/objects

Headers

Content-Type	application/json
Authorization   Bearer <short-access-token>

Body

{
    "filter": {
        "where": {
            "operator": "=",
            "args": [
                "id",
                5
            ]
        }
    },
    "context": {
        "tableName": "245ce633-796f-4dfa-ae6f-4b2762adbf44"
    }
}

Result

[
    {
        "id": 5,
        "createdAt": "2020-04-07T17:31:21.658Z",
        "updatedAt": "2020-04-07T17:41:31.561Z",
        "customField": "Test value 1"
    }
]

Examples

var myHeaders = new Headers();
myHeaders.append("Authorization", "Bearer <short-access-token>");
myHeaders.append("Content-Type", "application/json");
myHeaders.append("X-HTTP-Method-Override", "DELETE");

var raw = JSON.stringify({
  "filter": {
    "where": {
      "operator": "=",
      "args": ["id", 5]
    }
  },
  "context": {
    "tableName": "245ce633-796f-4dfa-ae6f-4b2762adbf44"
  }
});

var requestOptions = {
  method: 'POST',
  headers: myHeaders,
  body: raw,
  redirect: 'follow'
};

fetch("https://backend.spacemonopoly3d.com/api/objects", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));
var request = require('request');
var options = {
  'method': 'POST',
  'url': 'https://backend.spacemonopoly3d.com/api/objects',
  'headers': {
    'Authorization': 'Bearer <short-access-token>',
    'Content-Type': 'application/json',
    'X-HTTP-Method-Override': 'DELETE',
  },
  body: JSON.stringify({
    "filter": {
      "where": {
        "operator": "=",
        "args": ["id", 5]
      }
    },
    "context": {
      "tableName": "245ce633-796f-4dfa-ae6f-4b2762adbf44"
    }
  })

};
request(options, function (error, response) { 
  if (error) throw new Error(error);
  console.log(response.body);
});
<?php
require_once 'HTTP/Request2.php';
$request = new HTTP_Request2();
$request->setUrl('https://backend.spacemonopoly3d.com/api/objects');
$request->setMethod(HTTP_Request2::METHOD_POST);
$request->setConfig(array(
  'follow_redirects' => TRUE
));
$request->setHeader(array(
  'Authorization' => 'Bearer <short-access-token>',
  'Content-Type' => 'application/json',
  'X-HTTP-Method-Override' => 'DELETE',
));
$request->setBody(json_encode(array(
  "filter" => array(
    "where" => array(
      "operator" => "=",
      "args" => ["id", 5]
    )
  ),
  "context" => array(
    "tableName" => "245ce633-796f-4dfa-ae6f-4b2762adbf44"
  )
)));
try {
  $response = $request->send();
  if ($response->getStatus() == 200) {
    echo $response->getBody();
  }
  else {
    echo 'Unexpected HTTP status: ' . $response->getStatus() . ' ' .
    $response->getReasonPhrase();
  }
}
catch(HTTP_Request2_Exception $e) {
  echo 'Error: ' . $e->getMessage();
}



Enums

This API works with enums (pick lists).

Enum - container for list of any values which can be used to display in DropDown or List controls.




Create

Method

POST

URI

/api/enums

Headers

Content-Type	application/json
Authorization   Bearer <short-access-token>

Body

{
    "data": [
        {
            "name": "Enum 1"
        }
    ],
    "context": {}
}

Result

[
  {
    "id": 48,
    "systemName": "4ff7c4d6-8d26-4ab1-9d8d-8456c8d9894b",
    "name": "Enum 1",
    "options": {},
    "updatedAt": "2020-04-07T08:16:35.069Z",
    "createdAt": "2020-04-07T08:16:35.069Z",
    "description": null
  }
]

Examples

var myHeaders = new Headers();
myHeaders.append("Authorization", "Bearer <short-access-token>");
myHeaders.append("Content-Type", "application/json");

var raw = JSON.stringify({
  "data": [
    {
      "name": "Enum 1"
    }
  ],
  "context": {}
});

var requestOptions = {
  method: 'POST',
  headers: myHeaders,
  body: raw,
  redirect: 'follow'
};

fetch("https://backend.spacemonopoly3d.com/api/enums", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));
var request = require('request');
var options = {
  'method': 'POST',
  'url': 'https://backend.spacemonopoly3d.com/api/enums',
  'headers': {
    'Authorization': 'Bearer <short-access-token>',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    "data": [
      {
        "name": "Enum 1"
      }
    ],
    "context": {}
  })

};
request(options, function (error, response) { 
  if (error) throw new Error(error);
  console.log(response.body);
});
<?php
require_once 'HTTP/Request2.php';
$request = new HTTP_Request2();
$request->setUrl('https://backend.spacemonopoly3d.com/api/enums');
$request->setMethod(HTTP_Request2::METHOD_POST);
$request->setConfig(array(
  'follow_redirects' => TRUE
));
$request->setHeader(array(
  'Authorization' => 'Bearer <short-access-token>',
  'Content-Type' => 'application/json'
));
$request->setBody(json_encode(array(
  "data" => [
    array(
      "name" => "Enum 1"
    )
  ],
  "context" => array()
)));
try {
  $response = $request->send();
  if ($response->getStatus() == 200) {
    echo $response->getBody();
  }
  else {
    echo 'Unexpected HTTP status: ' . $response->getStatus() . ' ' .
    $response->getReasonPhrase();
  }
}
catch(HTTP_Request2_Exception $e) {
  echo 'Error: ' . $e->getMessage();
}



Get

This method allows to find existing enum by its 'name'.

See Where for more details.

Method

GET

URI

/api/enums

Headers

Content-Type	application/json
Authorization   Bearer <short-access-token>

Body

{
    "filter": {
        "where": {
          "operator": "=",
          "args": ["name", "Enum 1"]
        }
    },
    "context": {}
}

Result

{
  "count": 1,
  "rows": [
    {
        "id": 48,
        "systemName": "4ff7c4d6-8d26-4ab1-9d8d-8456c8d9894b",
        "name": "Enum 1",
        "options": {},
        "updatedAt": "2020-04-07T08:16:35.069Z",
        "createdAt": "2020-04-07T08:16:35.069Z",
        "description": null
      }
  ]
}

Examples

var myHeaders = new Headers();
myHeaders.append("Authorization", "Bearer <short-access-token>");
myHeaders.append("Content-Type", "application/json");
myHeaders.append("X-HTTP-Method-Override", "GET");

var raw = JSON.stringify({
  "filter": {
    "where": {
      "operator": "=",
      "args": ["name", "Enum 1"]
    }
  },
  "context": {}
});

var requestOptions = {
  method: 'POST',
  headers: myHeaders,
  body: raw,
  redirect: 'follow'
};

fetch("https://backend.spacemonopoly3d.com/api/enums", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));
var request = require('request');
var options = {
  'method': 'POST',
  'url': 'https://backend.spacemonopoly3d.com/api/enums',
  'headers': {
    'Authorization': 'Bearer <short-access-token>',
    'Content-Type': 'application/json',
    'X-HTTP-Method-Override': 'GET'
  },
  body: JSON.stringify({
    "filter": {
      "where": {
        "operator": "=",
        "args": ["name", "Enum 1"]
      }
    },
    "context": {}
  })

};
request(options, function (error, response) { 
  if (error) throw new Error(error);
  console.log(response.body);
});
<?php
require_once 'HTTP/Request2.php';
$request = new HTTP_Request2();
$request->setUrl('https://backend.spacemonopoly3d.com/api/enums');
$request->setMethod(HTTP_Request2::METHOD_POST);
$request->setConfig(array(
  'follow_redirects' => TRUE
));
$request->setHeader(array(
  'Authorization' => 'Bearer <short-access-token>',
  'Content-Type' => 'application/json',
  'X-HTTP-Method-Override' => 'GET'
));
$request->setBody(json_encode(array(
  "filter" => array(
    "where" => array(
      "operator" => "=",
      "args" => ["name", "Enum 1"]
    )
  ),
  "context" => array()
)));
try {
  $response = $request->send();
  if ($response->getStatus() == 200) {
    echo $response->getBody();
  }
  else {
    echo 'Unexpected HTTP status: ' . $response->getStatus() . ' ' .
    $response->getReasonPhrase();
  }
}
catch(HTTP_Request2_Exception $e) {
  echo 'Error: ' . $e->getMessage();
}



Update

Method

PUT

URI

/api/enums

Headers

Content-Type	application/json
Authorization   Bearer <short-access-token>

Body

{
    "data": [
        {
            "id": 48,
            "name": "Enum 2"
        }
    ],
    "context": {}
}

Result

[
  {
    "id": 48,
    "systemName": "4ff7c4d6-8d26-4ab1-9d8d-8456c8d9894b",
    "name": "Enum 2",
    "options": {},
    "updatedAt": "2020-04-07T10:00:12.069Z",
    "createdAt": "2020-04-07T08:16:35.069Z",
    "description": null
  }
]

Examples

var myHeaders = new Headers();
myHeaders.append("Authorization", "Bearer <short-access-token>");
myHeaders.append("Content-Type", "application/json");

var raw = JSON.stringify({
  "data": [
    {
      "id": 49,
      "name": "Enum 2"
    }
  ],
  "context": {}
});

var requestOptions = {
  method: 'PUT',
  headers: myHeaders,
  body: raw,
  redirect: 'follow'
};

fetch("https://backend.spacemonopoly3d.com/api/enums", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));
var request = require('request');
var options = {
  'method': 'PUT',
  'url': 'https://backend.spacemonopoly3d.com/api/enums',
  'headers': {
    'Authorization': 'Bearer <short-access-token>',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    "data": [
      {
        "id": 49,
        "name": "Enum 2"
      }
    ],
    "context": {}
  })

};
request(options, function (error, response) { 
  if (error) throw new Error(error);
  console.log(response.body);
});
<?php
require_once 'HTTP/Request2.php';
$request = new HTTP_Request2();
$request->setUrl('https://backend.spacemonopoly3d.com/api/enums');
$request->setMethod(HTTP_Request2::METHOD_PUT);
$request->setConfig(array(
  'follow_redirects' => TRUE
));
$request->setHeader(array(
  'Authorization' => 'Bearer <short-access-token>',
  'Content-Type' => 'application/json'
));
$request->setBody(json_encode(array(
  "data" => [
    array(
      "id" => 49,
      "name" => "Enum 2"
    )
  ],
  "context" => array()
)));
try {
  $response = $request->send();
  if ($response->getStatus() == 200) {
    echo $response->getBody();
  }
  else {
    echo 'Unexpected HTTP status: ' . $response->getStatus() . ' ' .
    $response->getReasonPhrase();
  }
}
catch(HTTP_Request2_Exception $e) {
  echo 'Error: ' . $e->getMessage();
}



Delete

This method allows to delete existing enum by its 'id'.

See Where for more details.

Method

DELETE

URI

/api/enums

Headers

Content-Type	application/json
Authorization   Bearer <short-access-token>

Body

{
    "filter": {
        "where": {
          "operator": "=",
          "args": ["id", 48]
        }
    },
    "context": {}
}

Result

[
  {
    "id": 48,
    "systemName": "4ff7c4d6-8d26-4ab1-9d8d-8456c8d9894b",
    "name": "Enum 1",
    "options": {},
    "updatedAt": "2020-04-07T10:00:12.069Z",
    "createdAt": "2020-04-07T08:16:35.069Z",
    "description": null
  }
]

Examples

var myHeaders = new Headers();
myHeaders.append("Authorization", "Bearer <short-access-token>");
myHeaders.append("Content-Type", "application/json");
myHeaders.append("X-HTTP-Method-Override", "DELETE");

var raw = JSON.stringify({
  "filter": {
    "where": {
      "operator": "=",
      "args": ["id", 49]
    }
  },
  "context": {}
});

var requestOptions = {
  method: 'POST',
  headers: myHeaders,
  body: raw,
  redirect: 'follow'
};

fetch("https://backend.spacemonopoly3d.com/api/enums", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));
var request = require('request');
var options = {
  'method': 'POST',
  'url': 'https://backend.spacemonopoly3d.com/api/enums',
  'headers': {
    'Authorization': 'Bearer <short-access-token>',
    'Content-Type': 'application/json',
    'X-HTTP-Method-Override': 'DELETE'
  },
  body: JSON.stringify({
    "filter": {
      "where": {
        "operator": "=",
        "args": ["id", 49]
      }
    },
    "context": {}
  })
};
request(options, function (error, response) { 
  if (error) throw new Error(error);
  console.log(response.body);
});
<?php
require_once 'HTTP/Request2.php';
$request = new HTTP_Request2();
$request->setUrl('https://backend.spacemonopoly3d.com/api/enums');
$request->setMethod(HTTP_Request2::METHOD_POST);
$request->setConfig(array(
  'follow_redirects' => TRUE
));
$request->setHeader(array(
  'Authorization' => 'Bearer <short-access-token>',
  'Content-Type' => 'application/json',
  'X-HTTP-Method-Override' => 'DELETE'
));
$request->setBody(json_encode(array(
  "filter" => array(
    "where" => array(
      "operator" => "=",
      "args" => ["id", 49]
    )
  ),
  "context" => array()
)));
try {
  $response = $request->send();
  if ($response->getStatus() == 200) {
    echo $response->getBody();
  }
  else {
    echo 'Unexpected HTTP status: ' . $response->getStatus() . ' ' .
    $response->getReasonPhrase();
  }
}
catch(HTTP_Request2_Exception $e) {
  echo 'Error: ' . $e->getMessage();
}



Enum Values

This API is part of Enums API.

Each method has context: enumId - it should be ID of existing Enum




Create

This method allows to create one or more enum values for specific 'enumId'

Method

POST

URI

/api/enum_values

Headers

Content-Type	application/json
Authorization   Bearer <short-access-token>

Body

{
    "data": [
        {
            "label": "Red",
            "options": {
                "order": 1
            }
        },
        {
            "label": "Green",
            "options": {
                "order": 2
            }
        },
        {
            "label": "Yellow",
            "options": {
                "order": 3
            }
        },
        {
            "label": "Black",
            "options": {
                "order": 4
            }
        },
        {
            "label": "White",
            "options": {
                "order": 5
            }
        }
    ],
    "context": {
        "enumId": 48
    }
}

Result

[
    {
        "id": 106,
        "label": "Red",
        "options": {
            "order": 1
        },
        "systemName": "5a546bb9-95f9-4d75-ab8b-babf69dd3083",
        "enumId": 48,
        "updatedAt": "2020-04-07T15:45:50.241Z",
        "createdAt": "2020-04-07T15:45:50.241Z"
    },
    {
        "id": 107,
        "label": "Green",
        "options": {
            "order": 2
        },
        "systemName": "2e57c867-84c2-40e1-842f-e076a6f662b0",
        "enumId": 48,
        "updatedAt": "2020-04-07T15:45:50.241Z",
        "createdAt": "2020-04-07T15:45:50.241Z"
    },
    {
        "id": 108,
        "label": "Yellow",
        "options": {
            "order": 3
        },
        "systemName": "8c80cef6-f587-4f16-9fb1-bc22d1998095",
        "enumId": 48,
        "updatedAt": "2020-04-07T15:45:50.242Z",
        "createdAt": "2020-04-07T15:45:50.242Z"
    },
    {
        "id": 109,
        "label": "Black",
        "options": {
            "order": 4
        },
        "systemName": "f1d8ebb4-7155-4d9e-bd16-11d503c354b2",
        "enumId": 48,
        "updatedAt": "2020-04-07T15:45:50.242Z",
        "createdAt": "2020-04-07T15:45:50.242Z"
    },
    {
        "id": 110,
        "label": "White",
        "options": {
            "order": 5
        },
        "systemName": "5b78d536-f938-4339-ab65-59748d0259c8",
        "enumId": 48,
        "updatedAt": "2020-04-07T15:45:50.242Z",
        "createdAt": "2020-04-07T15:45:50.242Z"
    }
]

Examples

var myHeaders = new Headers();
myHeaders.append("Authorization", "Bearer <short-access-token>");
myHeaders.append("Content-Type", "application/json");

var raw = JSON.stringify({
    "data": [
        {
            "label": "Red",
            "options": {
                "order": 1
            }
        },
        {
            "label": "Green",
            "options": {
                "order": 2
            }
        },
        {
            "label": "Yellow",
            "options": {
                "order": 3
            }
        }
    ],
    "context": {
        "enumId": 48
    }
});

var requestOptions = {
  method: 'POST',
  headers: myHeaders,
  body: raw,
  redirect: 'follow'
};

fetch("https://backend.spacemonopoly3d.com/api/enum_values", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));
var request = require('request');
var options = {
  'method': 'POST',
  'url': 'https://backend.spacemonopoly3d.com/api/enum_values',
  'headers': {
    'Authorization': 'Bearer <short-access-token>',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    "data": [
        {
            "label": "Red",
            "options": {
                "order": 1
            }
        },
        {
            "label": "Green",
            "options": {
                "order": 2
            }
        },
        {
            "label": "Yellow",
            "options": {
                "order": 3
            }
        }
    ],
    "context": {
        "enumId": 48
    }
  })
};
request(options, function (error, response) { 
  if (error) throw new Error(error);
  console.log(response.body);
});
<?php
require_once 'HTTP/Request2.php';
$request = new HTTP_Request2();
$request->setUrl('https://backend.spacemonopoly3d.com/api/enum_values');
$request->setMethod(HTTP_Request2::METHOD_POST);
$request->setConfig(array(
  'follow_redirects' => TRUE
));
$request->setHeader(array(
  'Authorization' => 'Bearer <short-access-token>',
  'Content-Type' => 'application/json'
));
$request->setBody(json_encode(array(
    "data" => [
        array(
            "label" => "Red",
            "options" => array(
                "order" => 1
            )
        ),
        array(
            "label" => "Green",
            "options" => array(
                "order" => 2
            )
        ),
        array(
            "label" => "Yellow",
            "options" => array(
                "order" => 3
            )
        )
    ],
    "context" => array(
        "enumId" => 48
    )
)));
try {
  $response = $request->send();
  if ($response->getStatus() == 200) {
    echo $response->getBody();
  }
  else {
    echo 'Unexpected HTTP status: ' . $response->getStatus() . ' ' .
    $response->getReasonPhrase();
  }
}
catch(HTTP_Request2_Exception $e) {
  echo 'Error: ' . $e->getMessage();
}



Get

This method allows to find existing enumValue by its 'label' and 'enumId'.

See Where for more details.

Method

GET

URI

/api/enum_values

Headers

Content-Type	application/json
Authorization   Bearer <short-access-token>

Body

{
    "filter": {
        "where": {
          "operator": "=",
          "args": ["label", "Red"]
        }
    },
    "context": {
        "enumId": 48
    }
}

Result

{
    "count": 1,
    "rows": [
        {
            "id": 106,
            "systemName": "5a546bb9-95f9-4d75-ab8b-babf69dd3083",
            "label": "Red",
            "options": {
                "order": 1
            },
            "enumId": 48,
            "createdAt": "2020-04-07T15:45:50.241Z",
            "updatedAt": "2020-04-07T15:45:50.241Z"
        }
    ]
}

Examples

var myHeaders = new Headers();
myHeaders.append("Authorization", "Bearer <short-access-token>");
myHeaders.append("Content-Type", "application/json");
myHeaders.append("X-HTTP-Method-Override", "GET");

var raw = JSON.stringify({
  "filter": {
    "where": {
      "operator": "=",
      "args": ["label", "Red"]
    }
  },
  "context": {
    "enumId": 42
  }
});

var requestOptions = {
  method: 'POST',
  headers: myHeaders,
  body: raw,
  redirect: 'follow'
};

fetch("https://backend.spacemonopoly3d.com/api/enum_values", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));
var request = require('request');
var options = {
  'method': 'POST',
  'url': 'https://backend.spacemonopoly3d.com/api/enum_values',
  'headers': {
    'Authorization': 'Bearer <short-access-token>',
    'Content-Type': 'application/json',
    'X-HTTP-Method-Override': 'GET'
  },
  body: JSON.stringify({
    "filter": {
      "where": {
        "operator": "=",
        "args": ["label", "Red"]
      }
    },
    "context": {
      "enumId": 42
    }
  })
};
request(options, function (error, response) { 
  if (error) throw new Error(error);
  console.log(response.body);
});
<?php
require_once 'HTTP/Request2.php';
$request = new HTTP_Request2();
$request->setUrl('https://backend.spacemonopoly3d.com/api/enum_values');
$request->setMethod(HTTP_Request2::METHOD_POST);
$request->setConfig(array(
  'follow_redirects' => TRUE
));
$request->setHeader(array(
  'Authorization' => 'Bearer <short-access-token>',
  'Content-Type' => 'application/json',
  'X-HTTP-Method-Override' => 'GET'
));
$request->setBody(json_encode(array(
  "filter" => array(
      "where" => array(
        "operator" => "=",
        "args" => ["label", "Red"]
      )
    ),
    "context" => array(
      "enumId" => 42
    )
)));
try {
  $response = $request->send();
  if ($response->getStatus() == 200) {
    echo $response->getBody();
  }
  else {
    echo 'Unexpected HTTP status: ' . $response->getStatus() . ' ' .
    $response->getReasonPhrase();
  }
}
catch(HTTP_Request2_Exception $e) {
  echo 'Error: ' . $e->getMessage();
}



Update

This method allows update existing enum value

Method

PUT

URI

/api/enum_values

Headers

Content-Type	application/json
Authorization   Bearer <short-access-token>

Body

{
    "data": [
        {
            "id": 106,
            "label": "Pink"
        }
    ],
    "context": {
        "enumId": 48
    }
}

Result

[
    {
        "id": 106,
        "systemName": "5a546bb9-95f9-4d75-ab8b-babf69dd3083",
        "label": "Pink",
        "options": {
            "order": 1
        },
        "enumId": 48,
        "createdAt": "2020-04-07T15:45:50.241Z",
        "updatedAt": "2020-04-07T16:50:34.562Z"
    }
]

Examples

var myHeaders = new Headers();
myHeaders.append("Authorization", "Bearer <short-access-token>");
myHeaders.append("Content-Type", "application/json");

var raw = JSON.stringify({
  "data": [
    {
      "id": 106,
      "label": "Pink"
    }
  ],
  "context": {
    "enumId": 42
  }
});

var requestOptions = {
  method: 'PUT',
  headers: myHeaders,
  body: raw,
  redirect: 'follow'
};

fetch("https://backend.spacemonopoly3d.com/api/enum_values", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));
var request = require('request');
var options = {
  'method': 'PUT',
  'url': 'https://backend.spacemonopoly3d.com/api/enum_values',
  'headers': {
    'Authorization': 'Bearer <short-access-token>',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    "data": [
      {
        "id": 106,
        "label": "Pink"
      }
    ],
    "context": {
      "enumId": 42
    }
  })

};
request(options, function (error, response) { 
  if (error) throw new Error(error);
  console.log(response.body);
});
<?php
require_once 'HTTP/Request2.php';
$request = new HTTP_Request2();
$request->setUrl('https://backend.spacemonopoly3d.com/api/enum_values');
$request->setMethod(HTTP_Request2::METHOD_PUT);
$request->setConfig(array(
  'follow_redirects' => TRUE
));
$request->setHeader(array(
  'Authorization' => 'Bearer <short-access-token>',
  'Content-Type' => 'application/json'
));
$request->setBody(json_encode(array(
  "data" => [
    array(
      "id" => 106,
      "label" => "Pink"
    )
  ],
  "context" => array(
    "enumId" => 42
  )
)));
try {
  $response = $request->send();
  if ($response->getStatus() == 200) {
    echo $response->getBody();
  }
  else {
    echo 'Unexpected HTTP status: ' . $response->getStatus() . ' ' .
    $response->getReasonPhrase();
  }
}
catch(HTTP_Request2_Exception $e) {
  echo 'Error: ' . $e->getMessage();
}



Delete

This method allows to delete existing enum value by its 'id'.

See Where for more details.

Method

DELETE

URI

/api/enum_values

Headers

Content-Type	application/json
Authorization   Bearer <short-access-token>

Body

{
    "filter": {
        "where": {
            "operator": "=",
            "args": [
                "id",
                106
            ]
        }
    },
    "context": {
        "enumId": 48
    }
}

Result

[
    {
        "id": 106,
        "systemName": "5a546bb9-95f9-4d75-ab8b-babf69dd3083",
        "label": "Pink",
        "options": {
            "order": 1
        },
        "enumId": 48,
        "createdAt": "2020-04-07T15:45:50.241Z",
        "updatedAt": "2020-04-07T16:50:34.562Z"
    }
]

Examples

var myHeaders = new Headers();
myHeaders.append("Authorization", "Bearer <short-access-token>");
myHeaders.append("Content-Type", "application/json");
myHeaders.append("X-HTTP-Method-Override", "DELETE");

var raw = JSON.stringify({
  "filter": {
    "where": {
      "operator": "=",
      "args": ["id", 105]
    }
  },
  "context": {
    "enumId": 48
  }
});

var requestOptions = {
  method: 'POST',
  headers: myHeaders,
  body: raw,
  redirect: 'follow'
};

fetch("https://backend.spacemonopoly3d.com/api/enum_values", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));
var request = require('request');
var options = {
  'method': 'POST',
  'url': 'https://backend.spacemonopoly3d.com/api/enum_values',
  'headers': {
    'Authorization': 'Bearer <short-access-token>',
    'Content-Type': 'application/json',
    'X-HTTP-Method-Override': 'DELETE'
  },
  body: JSON.stringify({
    "filter": {
      "where": {
        "operator": "=",
        "args": ["id", 105]
      }
    },
    "context": {
      "enumId": 48
    }
  })

};
request(options, function (error, response) { 
  if (error) throw new Error(error);
  console.log(response.body);
});
<?php
require_once 'HTTP/Request2.php';
$request = new HTTP_Request2();
$request->setUrl('https://backend.spacemonopoly3d.com/api/enum_values');
$request->setMethod(HTTP_Request2::METHOD_POST);
$request->setConfig(array(
  'follow_redirects' => TRUE
));
$request->setHeader(array(
  'Authorization' => 'Bearer <short-access-token>',
  'Content-Type' => 'application/json',
  'X-HTTP-Method-Override' => 'DELETE'
));
$request->setBody(json_encode(array(
  "filter" => array(
    "where" => array(
      "operator" => "=",
      "args" => ["id", 105]
    )
  ),
  "context" => array(
    "enumId" => 48
  )
)));
try {
  $response = $request->send();
  if ($response->getStatus() == 200) {
    echo $response->getBody();
  }
  else {
    echo 'Unexpected HTTP status: ' . $response->getStatus() . ' ' .
    $response->getReasonPhrase();
  }
}
catch(HTTP_Request2_Exception $e) {
  echo 'Error: ' . $e->getMessage();
}



API Test Tool

FortressDB isn’t just useful for forms, but for any custom WordPress development. We want developers to use our API to build awesome features for their websites. To enable this, we’ve created an API test tool, for both our REST and sockets APIs. The tool shows how to call the various methods, endpoints, etc. You can try it live on your own WordPress website.

The API tool can be enabled directly in the FortressDB plugin. There are 3 steps.

  1. Click on the Developers button from the FortressDB plugin.

  2. Check the "Enable API Tool" checkbox.

  3. The API Test Tool will now appear in the FortressDB plugin menu.




SQL Query Format

We use Sequelize library to communicate to PostgresQL database. This library can be used only inside source code of your apps, but to order allow use it remotely, we developed own format of SQL Queries.

Common view of this query looks like that:

const query = {
  filter: {
    attributes: [{}],
    where: {},
    limit: 0,
    offset: 0,
    order: [{}],
    group: {}
  },
  context: {}
}

See Type FDB Payload for more details.

Go to next chapter to get some more details




Types

FDB Payload

declare type FDBPayload = { 
  filter?: {
    attributes?: FDBAttribute,
    where?: FDBWhere,
    limit?: Number,
    offset?: Number,
    order?: FDBOrderBy,
    group?: FDBGrouopBy,
  }, 
  context?: Object 
}

FDB Attribute

declare type FDBAttribute = FDBColumn | FDBFunction | FDBValue | FDBSubQuery | string

FDB Function

declare type FDBFunction = { 
    func: string, 
    args: any[], 
    alias?: string 
}

FDB Column

declare type FDBColumn = { 
  column: string | FDBFunction, 
  alias?: string 
} | string

FDB Value

declare type FDBValue = { 
  value: string | number, 
  alias?: string 
}

FDB SubQuery

declare type FDBSubQuery = { 
  select: FDBPayload 
}

FDB Operator

declare type FDBOperator = string

FDB Where Clause

declare type FDBWhere = { 
  operator: string, 
  args: Array<FDBWhere | FDBWhereArgs> 
}

FDB Where Arguments

declare type FDBWhereArgs = Array<FDBWhereAttribute, FDBWhereLogic>

FDB Where Attribute

declare type FDBWhereAttribute = FDBColumn | FDBFunction

FDB Where logic

declare type FDBWhereLogic = FDBColumn | FDBFunction | Number | string

FDB Order By Clause

declare type FDBOrderBy = FDBColumn | Number | { 
  column: FDBColumn | Number, 
  direction?: FDBOrderDirection 
}

FDB Order Direction

declare type FDBOrderDirection = 'ASC' | 'DESC'

FDB Group By Clause

declare type FDBGroupBy = FDBColumn | FDBFunction | string

FDB Logic

declare type FDBLogic = FDBFunction | FDBWhere | FDBSubQuery | boolean

Go to the next chapter to know more about Attributes.




{% method %}

Attributes

Attributes allow to set a list of returning columns in resulting response. By default it's full set of columns which are defined in metadata of table.

See type FDB Attribute for more details.

{% sample lang="nodejs" -%}

const query = {
  filter: {
    attributes: [
      { column: 'id', alias: 'rowId' },
      { column: 'createdAt' },
      'updatedAt',
      { value: 1, alias: 'number' },
      { column: 'field1' },
      { func: 'LOWER', args: [{ column: 'field1' }], alias: 'lowerCaseField' }
    ]
  },
  context: {
    tableName: '245ce633-796f-4dfa-ae6f-4b2762adbf44'
  }
}

{% endmethod %}




{% method %}

Where

To filter table's rows by any value you can use where clause. Each item of where clause should return boolean value.

Main format of where clause looks like bellow:

const query = {
  filter: {
    where: {
      operator: FDBOperators,
      args: Array<FDBWhere | FDBWhereArgs>
    } 
  } 
}

See types descriptions of FDB Operator, FDB Where and FDB Where Arguments for more details.

operator: string: one of listed values:

Logic Operators

OperatorDescription
&, and(a = 5) AND (b = 6)
|, or(a = 5 OR a = 6)
!, notIS NOT TRUE

Math Operators

OperatorDescription
== 3
!=, <>, ne!= 3
>, gt> 5
>=, gte>= 5
<, lt< 7
<=, lte<= 7

Other Operators

OperatorDescription
inIN [1, 2]
notInNOT IN [1, 2]
likeLIKE '%hat'
notLikeNOT LIKE '%hat'
iLikeILIKE '%hat' (case insensitive)
notILikeNOT ILIKE '%hat'
startsWithLIKE 'hat%'
endsWithLIKE '%hat'
substringLIKE '%hat%'
regexpREGEXP/~ '^[h | a | t]'
notRegexpNOT REGEXP/~ '^[h | a | t]'
iRegexp~* '^[h | a | t]'
notIRegexp!~* '^[h | a | t]'
betweenBETWEEN 6 AND 10
notBetweenNOT BETWEEN 11 AND 15
isIS NULL
overlap&& [1, 2] (PG array overlap operator)
contains@> [1, 2] (PG array contains operator)
contained<@ [1, 2] (PG array contained by operator)
anyANY ARRAY[2, 3]::INTEGER
all> ALL (SELECT 1)

args: Array<FDBWhere | FDBWhereArgs>:

{
  args: ['id', 3]
}

Where id is column name and 3 is value

{% sample lang="nodejs" -%}

const query = {
  filter: {
    where: {
      operator: '=',
      args: [ 'id', 2 ] // id = 2
    } 
  },
  context: {
    tableName: '245ce633-796f-4dfa-ae6f-4b2762adbf44'
  }
}

This query will be converted to SQL statement:

SELECT * FROM "245ce633-796f-4dfa-ae6f-4b2762adbf44" WHERE "id" = 2;

{% endmethod %}




Limit

When you have a big table you don't want to wait while whole table's rows are retrieved from database. Limit allows to restrict number and speedup loading of resulting set of rows.

You can set parameter limit in query by such way:

const query = {
  filter: {
    limit: 50
  }
}

In result you will get maximum 50 rows.

But what if you need the next 50 rows from table?

Go to the next chapter to know that.




Offset

Offset allows to move you to the next limited set of rows when using of limit parameter in query. Such way, for example, if you set limit: 50 you should set offset: 50 to get rows in range 51 - 100.

const query = {
  filter: {
    limit: 50,
    offset: 50
  }
}

You will get rows in range from 51 to 100.

Main use case of this parameter often is implementation of pagination:

You have, say, 250 rows in table. It's impossible to show all rows to users in one screen. You can reach this through showing pages.

The query for first page can look like bellow:

const query = {
  filter: {
    limit: 25
  }
}

For the second one something like this:

const query = {
  filter: {
    limit: 25,
    offset: 25
  } 
}

For the third one:

const query = {
  filter: {
    limit: 25,
    offset: 50
  } 
}

And so on...

Go to the next chapter to know how you can get your rows in defined order.




Order

Sometimes you will need to get your rows from table in defined order. You can reach that using parameter order in query. Ordering can be done in two directions: ascending (ASC) and descending (DESC)

Say, to display price from bigger to less you can use such expression:

const query = {
  filter: {
    order: [
      { column: 'price', direction: 'DESC' }
    ]
  }
}

...or such one:

const query = {
  filter: {
    order: [
      { column: 3, direction: 'DESC' }
    ]
  }
}

...also such one:

const query = {
  filter: {
    order: [
      { column: { column: 'price' }, direction: 'DESC' }
    ]
  }
}

...and even such one:

const query = {
  filter: {
    order: [
      { column: { func: 'LOWER', args: [{ column: 'name' }] }, direction: 'DESC' }
    ]
  }
}

To use default ordering (ASC) you can:

...pass it explicitly:

const query = {
  filter: {
    order: [
      { column: 'price', direction: 'ASC' }
    ]
  }
}

...or omit direction parameter:

const query = {
  filter: {
    order: [
      { column: 'price' }
    ]
  }
}

...or just pass column name only:

const query = {
  filter: {
    order: 'price'
  }
}

...or pass FDB Column type

const query = {
  filter: {
    order: { column: 'price' }
  }
}

...also you can pass number of column instead of its name:

const query = {
  filter: {
    order: 3
  }
}

Simple rule: to make ordering by just one field use simple types like column name, number of column or FDB Column, to order by several fields - use an array of that values.

For more details see FDB Order By Clause type description.

Go to next chapter to understand how to use group parameter.




Group

Let's say you need to get max price in your table of products. Also you want get it in part of departments.

You should use aggregate function SUM for column price:

const query = {
  filter: {
    attributes: [
      { func: 'SUM', args: ['price'], alias: 'price' },
      { column: 'productId' }
    ],
    group: [
      'department',
      'productId'
    ]
  }
}

Result will be similar that:

const result = {
  count: [
    { department: 'dep1', productId: 1, count: 1 },
    { department: 'dep2', productId: 4, count: 1 }
  ],
  rows: [
    { department: 'dep1', productId: 1, price: 1999 },
    { department: 'dep2', productId: 4, price: 3000 }
  ]
}

All columns that doesn't take a part in aggregate functions in query should be put to group clause




Context

Part of query, object which allows to know parent data container.

For example: Metadata - it's table in DB, also it's container for data rows.

To manipulate objects we should pass tableName as context


Long Access Token

Access Token which is living very long time. This token can be retrieved using API call Database Connect.

When developing own plugin you can use it as Plugin Access Token and keep it in your storage.


Short Access Token

This Access Token is living just 1 day. Can be retrieved using API call Auth Subscribe.

To retrieve it you should call that endpoint with Long Access Token.