Custom App Integration </>

CoWorkr is building integrations with industry leaders, see below for examples. 


 COMFY - COMING SOON

COMFY - COMING SOON

 iOffice "Hummingbird" - COMING SOON

iOffice "Hummingbird" - COMING SOON

 SPARK INTEGRATION EXAMPLE

SPARK INTEGRATION EXAMPLE

 FM INTEGRATION EXAMPLE

FM INTEGRATION EXAMPLE

 

CoWorkr API Documentation

The CoWorkr API allows users to integrate real-time Sensor data with any custom application. Interact with the CoWorkr Cloud from anything using a HTTP request. 

 

CoWorkr API

You will need an account on CoWorkr and additional permissions to access our API. Contact CoWorkr to enable the account for API use.

 

To get started:

Go to either internal-us.coworkr.co or internal-asia.coworkr.co to create an account on the system you need access to. 
OAUTH accounts will not work for accessing the API

REST Calls

All calls are over HTTPS and the returns are all in JSON.

EndPoint Servers

  • internal-us.coworkr.co - US staging server with latest API. Uses US production database.
  • internal-asia.coworkr.co - Asia staging server with latest API. Uses Asia production database.

Authentication

If using on the Asia servers replace us with asia in the below URLs.

A login call with curl

Notes:

  1. This is using the username and NOT the email address associated with the account.
  2. curl is reading the username and password from the command line and interprets it as a url string. So if your password has special url characters in it, '&', '?' etc., curl will fail to read them properly and the request will fail. This is only and issue with the below examples using curl and not an issue when using a coding library.
curl https://internal-us.coworkr.co/api/login/ -d "username=test&password=password"

or

curl https://internal-asia.coworkr.co/api/login/ -d "username=test&password=password"

Response

{ status: "success", data: {authToken: "f2KpRW7KeN9aPmjSZ", userId: fbdpsNf4oHiX79vMJ} }

You'll need to save the userId and token on the client, for subsequent authenticated requests.

Logging Out

You also have an authenticated POST /api/logout endpoint for logging a user out. If successful, the auth token that is passed in the request header will be invalidated (removed from the user account), so it will not work in any subsequent requests.

Make sure you logout before requesting another login token !!!

Not logging out will add latency to API calls !!!

curl https://internal-us.coworkr.co/api/logout -X POST -H "X-Auth-Token: f2KpRW7KeN9aPmjSZ" -H "X-User-Id: fbdpsNf4oHiX79vMJ"

or

curl https://internal-asia.coworkr.co/api/logout -X POST -H "X-Auth-Token: f2KpRW7KeN9aPmjSZ" -H "X-User-Id: fbdpsNf4oHiX79vMJ"

Authenticated Calls

For any endpoints that require the default authentication, you must include the userId and authToken with each request under the following headers: - X-User-Id - X-Auth-Token

curl -H "X-Auth-Token: f2KpRW7KeN9aPmjSZ" -H "X-User-Id: fbdpsNf4oHiX79vMJ" https://internal-us.coworkr.co/api/workPlaces

WorkPlaces

You can query the system for the workPlaces you have access to.

Example using curl

curl -H "X-Auth-Token: f2KpRW7KeN9aPmjSZ" -H "X-User-Id: fbdpsNf4oHiX79vMJ" https://internal-us.coworkr.co/api/workPlaces

Response

{
    "_id": "WvamDKDx6KD4QZh5g",
    "name": "Old House",
    "address": "1180 N Lemon Ave, Menlo Park, CA 94025, USA",
    "group": {
      "name": "Tim' Group",
      "id": "azYf5H8QNBYSgrRHJ"
    },
    "owner": "tim",
    "formattedAddress": "1180 N Lemon Ave, Menlo Park, CA 94025, USA",
    "location": {
      "type": "Point",
      "coordinates": [
        -122.197805,
        37.437403
      ]
    },
    "timezone": "America/Adak",
    "sleep": true,
    "start": "2015-01-01T10:00:00.000Z",
    "end": "",
    "activeStartHour": "8",
    "activeEndHour": "18"
  }

FloorPlans

You can query the system for the floorPlans of a workPlace.

Example using curl

curl -H "X-Auth-Token: f2KpRW7KeN9aPmjSZ" -H "X-User-Id: fbdpsNf4oHiX79vMJ" https://internal-us.coworkr.co/api/workPlace/[workPlaceId]/floorPlans

Response

[
 {
    "_id": "T6DbbqgA9eWG9ooat",
    "name": "Test Floor",
    "photo": {
      "width": 842,
      "height": 569
    },
    "workPlaceId": "WvamDKDx6KD4QZh5g",
    "owner": "tim",
    "workPlaceName": "Old House",
    "activeHours": {
      "start": "8",
      "end": "18"
    },
    "timezone": "America/Adak"
  }
]

WorkPoint Status and Full Record

You can query for the status and full record of workPoints for a workPlace. You would query this data to make sure that the workPoint record on your system is up to date with what is on ours. Pulling the full record more than once an hour is discouraged.

Example using curl

curl -H "X-Auth-Token: f2KpRW7KeN9aPmjSZ" -H "X-User-Id: fbdpsNf4oHiX79vMJ" https://internal-us.coworkr.co/api/workPlace/[workPlaceId]/workPoints

Response

[
 {
    "_id": "573dd1d496f05ee153d5d0c4",
    "uuid": "B0B448C04B82",
    "name": "Table Vibration",
    "firmwareVersion": "2:73",
    "workPlaceId": "A8wBquS5vzGaCacYx",
    "workPlaceName": "Scruffholm",
    "lastConnect": "2016-08-22T01:14:32.820Z",
    "connected": true,
    "recentlyConnected": true,
    "occupied": true,
    "occupiedBy": "decay",
    "occupyReason": "VIBRATION ACTIVE BY DECAY 79 (25:0 var=11.6)",
    "occupancyChanged": "2016-08-22T01:12:00.530Z",
    "rssi": -91,
    "battery": 37,
    "optical": 8.77,
    "floorPlanId": "vC6QuGrXvofEHQFGz",
    "floorPlanX": 679,
    "floorPlanY": 306,
    "floorPlanName": "Greatroom",
    "tags": {
      "type": "simplelink",
      "room": "dinning"
    },
    "notes": "Battery?"
  }
]

You can query for the status and full record of workPoints for a floorPlan

Example using curl

curl -H "X-Auth-Token: f2KpRW7KeN9aPmjSZ" -H "X-User-Id: fbdpsNf4oHiX79vMJ" https://internal-us.coworkr.co/api/workPlace/[workPlaceId]/floorPlan/[floorPlanId]/workPoints

Response

[
 {
    "_id": "573dd1d496f05ee153d5d0c4",
    "uuid": "B0B448C04B82",
    "name": "Table Vibration",
    "firmwareVersion": "2:73",
    "workPlaceId": "A8wBquS5vzGaCacYx",
    "workPlaceName": "Scruffholm",
    "lastConnect": "2016-08-22T01:14:32.820Z",
    "connected": true,
    "recentlyConnected": true,
    "occupied": true,
    "occupiedBy": "decay",
    "occupyReason": "VIBRATION ACTIVE BY DECAY 79 (25:0 var=11.6)",
    "occupancyChanged": "2016-08-22T01:12:00.530Z",
    "rssi": -91,
    "battery": 37,
    "optical": 8.77,
    "floorPlanId": "vC6QuGrXvofEHQFGz",
    "floorPlanX": 679,
    "floorPlanY": 306,
    "floorPlanName": "Greatroom",
    "tags": {
      "type": "simplelink",
      "room": "dinning"
    },
    "notes": "Battery?"
  }
]

You can also request just the status in the above calls by postfixing /status to the end of the URL. This would be used if you are trying to keep a map or a list on your system up to date with the current workPoint occupancy state. There can be a delay of up to a few minutes in what is reported here and what the actual current state of the sensor is. So if pulling this data for a real time realize that the data can be out of sync. Pulling this data for a given location more than once per minute will lead to throttle and is a violation of our API.

For a workPlace the call would be:

Example using curl

curl -H "X-Auth-Token: f2KpRW7KeN9aPmjSZ" -H "X-User-Id: fbdpsNf4oHiX79vMJ" https://internal-us.coworkr.co/api/workPlace/[workPlaceId]/workPoints/status

Response

[
 {
    "_id": "573dd1d496f05ee153d5d0c4",
    "lastConnect": "2016-08-22T01:14:32.820Z",
    "occupancyChanged": "2016-08-22T01:12:00.530Z",
    "connected": true,
    "occupied": true
  }
]

It is left up to the reader to realize what the call would be for a floorPlan.

WorkPoint Activity

You can query for the all the activity data for a workPoint on a specific day. The date in the call is a string that can be read by moment. This will return all the activity 5 minute 'buckets' for that day for the given workPoint.

The activity records occupied flag is true for the given 5 minute period if at any time in that period the workPoint was occupied.

This data is useful if you are trying to create your own heat map or do some analytics with the data. Summing this data will yield the activity % for larger time periods.

You may only query for the data up to the previous day. Repeatedly querying for the same workPoint and day will lead to a nasty phone call.

Example using curl

curl -H "X-Auth-Token: f2KpRW7KeN9aPmjSZ" -H "X-User-Id: fbdpsNf4oHiX79vMJ" https://internal-us.coworkr.co/api/workPlace/[workPlaceId]/workPoint/[workPointId]/activity/date/[date]

Response

[
 {
    "_id": "573dd1d496f05ee153d5d0c4",
    "workPlaceId": "A8wBquS5vzGaCacYx",
    "floorPlanId": "vC6QuGrXvofEHQFGz",
    "workPointId" : "589a381adbea7e7a46b8c449",
    "time" : ISODate("2017-11-04T09:55:00Z"),
    "timeOffset" : 25200000,
    "uuid": "B0B448C04B82",
    "occupied": 'true'
 }
]

Streaming

For use in hot desking, you can stream workPoint updates using 3rd party DDP client libraries. We have example code, see link below, for Node that subscribes to workPoint status updates.

coWorkr workPoint Streamer

node js application to connect via DDP to coWorkr servers and stream workPoint updates.

Prereqs

  1. Install node. Packages available at https://nodejs.org
  2. Install the npm libraries needs in this application directory. cd coWorkrWorkPointStreamer npm install

  3. Run the sample app specifying which coWorkr servers you want to connect to. [test,us,asia]. It will ask for your username and password. node coWorkrWorkPointStreamer.js [us|asia|test]

Subscription

The sample app subscribed to the workPointStatus publication on the server. This monitors the workPoints records and will notify you if there are changes in the following fields in that record.

  • name
  • uuid - this would happen if there was a sensor change
  • connected - false if the sensor has not reported in
  • occupied - true if the workPoint is occupied
  • occupiedBy - string with info on the occupied state
  • flags.press - workPoint button press
  • flags.button1 - button 1 pressed
  • flags.button2 - button 2 pressed if on sensor

Notes

This is a sample program to use as a base for your own client. There are other DDP libraries available on the internet if you want to connect with something other than node. Search meteor ddp clients

Main Dependencies