Iotcon API documentation v2

Getting started

Iotcon's API exposes the entire infrastructure via a standardized programmatic interface. Using Iotcon's API, you can do just about anything you can do on Iotcon via the customer dashboard.

The Iotcon API is a RESTful API based on HTTPS requests and JSON responses. You can obtain your API key from Api page.

Endpoints

The API is accessed by making HTTPS OR HTTP requests to a specific version endpoint URL, in which GET, POST, PUT, PATCH, and DELETE methods dictate how your interact with the information available. Every endpoint is accessed only via the HTTPS (port 443) OR HTTP (port 80) protocol.

Everything (methods, parameters, etc.) is fixed to a version number, and every call must contain one.The latest version is Version 2.

The stable HTTPS endpoint for the latest version is: https://api.iotcon.top/client/v2/json

Requests

Requests must be sent over HTTPS with any payload formatted in JSON.

All requests must include both X-AUTH-USER and X-AUTH-HASH headers to authenticate.


Name cURL Format Ajax Format Description
Api Hash Key X-Auth-Hash hash API key generated on the "API" page
User Id X-Auth-User user User Id associated with your account

Example request
Requests are generally formatted as follows:

GET /object/:object_id


cURL (example)

curl -X GET "https://api.iotcon.top/client/v2/json/curl/:device_serial_no/view" \
     -H "Content-Type:application/json" \
     -H "X-Auth-Hash:asd12r5f3v1f6r6tg" \
     -H "X-Auth-User:example"

Ajax URL (example)

https://api.iotcon.top/client/v2/json/ajax/:device_serial_no/view?user=<user>&hash=<hash>

Responses

Each response is a JSON object. The data requested is wrapped in the RESULT tag. If you have a response, it will always be within the RESULT field. We also include a SUCCESS flag, an array of potential ERRORS, and MESSAGES in the response.

An error object will contain an integer CODE field and a MESSAGE

Example request
Requests are generally formatted as follows:

GET /object/:object_id


Success Response (example)

{
  "success": true,
  "result": {
    "raspberry" : [
      {
        "pin_no":"7",
        "pin_name":"Test1",
        "pin_status":"0"
      },
      {
        "pin_no":"12",
        "pin_name":"Test2",
        "pin_status":"1"
      }
    ],
    "last_call":"2016-12-18 16:20:21"
  },
  "errors": [],
  "messages": []
}

Error Response (example)

{
  "success": false,
  "result": null,
  "errors": {
    "code":1059,
    "message":"Authentication Failed Access Denied."
  },
  "messages": []
}

GET    View Devices

FREE

GET /device


cURL (example)

curl -X GET "https://api.iotcon.top/client/v2/json/curl/device" \
     -H "Content-Type:application/json" \
     -H "X-Auth-Hash:asd12r5f3v1f6r6tg" \
     -H "X-Auth-User:example"

Ajax URL (example)

https://api.iotcon.top/client/v2/json/ajax/device?user=<user>&hash=<hash>

Success Response (example)

{
  "success": true,
  "result": {
    "device" : [
      {
        "device_serial_no":"00000000000000",
        "device_type":"Raspberry Pi 2",
        "device_name":"Home",
        "last_call":"2016-12-18 16:30:55"
      }
    ],
    "last_call":"2016-12-18 16:20:21"
  },
  "errors": [],
  "messages": []
}

Error Response (example)

{
  "success": false,
  "result": null,
  "errors": {
    "code":1569,
    "message":"Device Not Found"
  },
  "messages": []
}

GET    View Ports

FREE

GET /:device_serial_no/view


cURL (example)

curl -X GET "https://api.iotcon.top/client/v2/json/curl/:device_serial_no/view" \
     -H "Content-Type:application/json" \
     -H "X-Auth-Hash:asd12r5f3v1f6r6tg" \
     -H "X-Auth-User:example"

Ajax URL (example)

https://api.iotcon.top/client/v2/json/ajax/:device_serial_no/view?user=<user>&hash=<hash>

Success Response (example)

{
  "success": true,
  "result": {
    "raspberry" : [
      {
        "pin_no":"7",
        "pin_name":"Test1",
        "pin_status":"0"
      },
      {
        "pin_no":"12",
        "pin_name":"Test2",
        "pin_status":"1"
      }
    ],
    "last_call":"2016-12-18 16:20:21"
  },
  "errors": [],
  "messages": []
}

Error Response (example)

{
  "success": false,
  "result": null,
  "errors": {
    "code":1059,
    "message":"Authentication Failed Access Denied."
  },
  "messages": []
}

GET    Switch [ON/OFF] Port With Status

FREE

GET /:device_serial_no/switch/:pin_no/:status


cURL (example)

curl -X GET "https://api.iotcon.top/client/v2/json/curl/:device_serial_no/switch/:pin_no/:status" \
     -H "Content-Type:application/json" \
     -H "X-Auth-Hash:asd12r5f3v1f6r6tg" \
     -H "X-Auth-User:example"

Ajax URL (example)

https://api.iotcon.top/client/v2/json/ajax/:device_serial_no/switch/:pin_no/:status?user=<user>&hash=<hash>

Success Response (example)

{
  "success": true,
  "result": {
    "pin":"35",
    "status":"1",
    "device_serial_no":00000000000000,
    "updated_time":"2016-12-21 19:54:47"
  },
  "errors": [],
  "messages": []
}

Error Response (example)

{
  "success": false,
  "result": null,
  "errors": {
    "code":1569,
    "message":"Device Not Found"
  },
  "messages": []
}

GET    Switch [ON/OFF] Port Without Status

FREE

GET /:device_serial_no/switch/:pin_no


cURL (example)

curl -X GET "https://api.iotcon.top/client/v2/json/curl/:device_serial_no/switch/:pin_no" \
     -H "Content-Type:application/json" \
     -H "X-Auth-Hash:asd12r5f3v1f6r6tg" \
     -H "X-Auth-User:example"

Ajax URL (example)

https://api.iotcon.top/client/v2/json/ajax/:device_serial_no/switch/:pin_no?user=<user>&hash=<hash>

Success Response (example)

{
  "success": true,
  "result": {
    "pin":"35",
    "status":"1",
    "device_serial_no":"00000000000000",
    "updated_time":"2016-12-21 19:54:47"
  },
  "errors": [],
  "messages": []
}

Error Response (example)

{
  "success": true,
  "result": {
    "pin":"35",
    "status":"1",
    "device_serial_no":"00000000000000",
    "updated_time":"2016-12-21 19:54:47"
  },
  "errors": [],
  "messages": []
}

POST    Add Device

FREE

POST /device/add


cURL (example)

curl -X POST "https://api.iotcon.top/client/v2/json/device/add" \
     -H "Content-Type:application/json" \
     -H "X-Auth-Hash:asd12r5f3v1f6r6tg" \
     -H "X-Auth-User:example" \
     --data '{"device_name":"Home","device_srno":"000000000000","device_type":"Raspberry Pi 2"}'

Ajax URL (example)

https://api.iotcon.top/client/v2/json/device/add
data={user: "example", hash: "asd12r5f3v1f6r6tg", device_srno : "000000000000", device_name : "Home", device_type : "Raspberry Pi 2" }

Success Response (example)

{
  "success": true,
  "messages": "Device Added To System",
  "errors": []
}

Error Response (example)

{
  "success": false,
  "result": null,
  "errors": {
    "code":1059,
    "message":"Authentication Failed Access Denied."
  },
  "messages": []
}

More....

More API Coming Soon