Skip to content

apartx/apartx-api-docs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 

Repository files navigation

ApartX API Documentation

HTTP API

HTTP API endpoint available on https://apartx.co/api/v1/.

Some methods requires authorization read below.

We have limit in 2 calls per second from single account to authorization required methods and 100 calls per second from single IP address to public methods.

All HTTP methods accept JSON formats of requests and responses if it not specified by headers.

Authorization

In order for access to private API methods, generate authorization keys in profile settings.

All request to these methods must contain the following headers:

  • X-KEY - your key.
  • X-SIGNATURE - query’s POST data, sorted by keys and signed by your key’s “secret” according to the HMAC-SHA256 method.
  • X-NONCE - integer value, must be greater then nonce in previous api call.

Node.js

var crypto = require('crypto')
var _ = require('underscore')

var createSignature = function (options, secret) {
  options = _.omit(options, ['__proto__'])
  payload = Object
  .keys(options) // get keys of payload object
  .sort() // sort keys
  .map((key) => key + "=" + encodeURIComponent(options[key])) // each value should be url encoded. the most sensitive part for sign checking
  .join('&'); // to sting, separate with ampersand
  hmac = crypto.createHmac('sha256', secret)
  hmac.update(payload)
  hmac.digest('hex')
}

Locks

List all locks

!> This method requires authorization.

Returns information about all available locks.

HTTP Request

GET https://apartx.co/api/v1/locks

Query parameters

Parameter Required Description
limit No Limit
page No Page number

** Node.js **

var request = require('request');

var params = {

}

request.get({
    url: 'https://apartx.co/api/v1/locks',
    headers: getAuthHeaders(params)
  }, function (error, response, body) {
    // process response
  }
);

Example output

[
  {
    "_id": "lockId",
    "name": "LOCK_NAME",
    "userId": "userId",
    "brand": "lockBrand"
   }
]

List passcodes of lock

!> This method requires authorization.

Returns information about all generated passcodes for given lock.

HTTP Request

GET https://apartx.co/api/v1/locks/:lockId/passcodes

Url parameters

Parameter Description
lockId ID of lock

Query parameters

Parameter Required Description
limit No Limit
page No Page number

** Node.js **

var request = require('request');

var params = {

}
var lockId = 'lockId'

request.get({
    url: `https://apartx.co/api/v1/locks/${lockId}/passcodes`,
    headers: getAuthHeaders(params)
  }, function (error, response, body) {
    // process response
  }
);

Example output

[
  {
    "_id": "passcodeId",
    "lockId": "lockId",
    "passcode": "LOCK_NAME",
    "startDate": "",
    "endDate": ""
   }
]

Create Passcode

!> This method requires authorization.

Create new passcode for lock.

HTTP Request

POST https://apartx.co/api/v1/locks/:lockId/passcodes

Url parameters

Parameter Description
lockId ID of lock

Post parameters

Parameter Description
startDate Passcode start time (Date format YYYY-MM-DD HH:mm)
endDate Passcode end date (Date format YYYY-MM-DD HH:mm)

** Node.js **

var request = require('request');

var params = {
    lockId: 'lockId',
    startDate: '2020-01-01 15:00'
    endDate: '2020-01-01 16:00'
};
var lockId = 'lockId'

request.post({
    url: `https://apartx.co/api/v1/locks/${lockId}/passcodes`,
    form: params,
    headers: getAuthHeaders(params)
  }, function (error, response, body) {
    // process response
  }
);

Example output

{
  "success": true,
  "_id": "",
  "passcode": "1234567890",
  "startDate": "",
  "endDate": ""
}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published