Returns a list of all instructions belonging to an account as per the specified criteria. This API is paginated and returns 20 instructions by default. An instruction is uniquely identified by an 'instruction_key'. This key should be used in all the other API referencing a particular instruction.

Params

Param name Description
page
optional

Page number of results to be fetched, Default 1


Value: Must be Integer.
per
optional

Number of things records to be returned in one page, Default 20


Value: Must be Integer.
order_by
optional

Field on which resultant things should be sorted


Value: Must be a String
order
optional

Order, asc or desc, in which results should be sorted


Value: Must be a String
timestamp_format
optional

Format, “str” or “int”, in which timestamps should be returned, Default “int”


Value: Must be a String
search
optional

Keywords based on which things should be searched. Currently you can search things on - thing_key, name or tag


Value: Must be a String
scope
optional

Matching condition if multiple keywords are specified for search. Valid values are “all” or “any”. Default is “all”


Value: Must be a String
pretty
optional

Return a pretty formatted response if true, Default is false


Value: Must be a Boolean
field_list
optional

List of fields required in the result.


Value: Must be an array of any type
fields
optional

[Deprecated]Comma separated list of fields required in the result.


Value: Must be a String
is_oem
optional

Return instructions of child accounts along with instructions of oem account if is_oem flag is true.


Value: Must be one of: <code>true</code>, <code>false</code>, <code>true</code>, <code>false</code>.

Examples

Request - listing all instructions without any criteria
  curl -X GET -H "Content-Type:application/json" -H "X-Auth-Token:olezAZXGQn9MutnfNerKDQ" https://api.datonis.io/api/v3/instructions

Response (returns first 20 records)
{
  "total_count": 9,
  "page": 1,
  "instructions": [
    {
      "definition": {
        "val": "off"
      },
      "description": "Turn the sensor off",
      "instruction_key": "t9t2a63b4f",
      "max_retries": 0,
      "name": "TURNOFF",
      "timeout": 30,
      "created_at": 1425912572,
      "updated_at": 1425912572
    },
    {
      "definition": {
        "value": "on"
      },
      "description": "Turn the machine on",
      "instruction_key": "e23t78333c",
      "max_retries": 0,
      "name": "TURNON",
      "timeout": 30,
      "created_at": 1425984214,
      "updated_at": 1427986515
    },
    {
      "definition": {
        "temp": 50,
        "humidity": 65
      },
      "description": "Turn up the thermostat",
      "instruction_key": "e661ctd8fa",
      "max_retries": 0,
      "name": "TURNUP",
      "timeout": 30,
      "created_at": 1426142755,
      "updated_at": 1426142755
    },
    {
      "definition": {
        "address": "gfff",
        "value": "foo"
      },
      "description": "",
      "instruction_key": "11aae44468",
      "max_retries": 0,
      "name": "MODBUSOFF",
      "timeout": 30,
      "created_at": 1434350522,
      "updated_at": 1434350522
    },
    {
      "definition": {
        "status": "on"
      },
      "description": "start machine",
      "instruction_key": "ea96tc6c57",
      "max_retries": 0,
      "name": "Start Machine",
      "timeout": 30,
      "created_at": 1448429915,
      "updated_at": 1448429915
    },
    {
      "definition": {
        "status": "off"
      },
      "description": "stop machine",
 ...
Request - listing instructions by specifying number of instructions to be returned at a time (page size) and specific set to be returned (page)
  curl -X GET -H "Content-Type:application/json" -H "X-Auth-Token:olezAZXGQn9MutnfNerKDQ" -d '{"per":"2","page":"2"}' https://api.datonis.io/api/v3/instructions

Response (returns page 2 with 2 instructions per page)
{
  "total_count": 9,
  "page": "2",
  "instructions": [
    {
      "definition": {
        "temp": 50,
        "humidity": 65
      },
      "description": "Turn up the thermostat",
      "instruction_key": "e661ctd8fa",
      "max_retries": 0,
      "name": "TURNUP",
      "timeout": 30,
      "created_at": 1426142755,
      "updated_at": 1426142755
    },
    {
      "definition": {
        "address": "gfff",
        "value": "foo"
      },
      "description": "",
      "instruction_key": "11aae44468",
      "max_retries": 0,
      "name": "MODBUSOFF",
      "timeout": 30,
      "created_at": 1434350522,
      "updated_at": 1434350522
    }
  ]
}
Request - listing instructions ordered by a field
  curl -X GET -H "Content-Type:application/json" -H "X-Auth-Token:olezAZXGQn9MutnfNerKDQ" -d '{"order_by":"name","order":"desc"}' https://api.datonis.io/api/v3/instructions

Response (returns instructions in the reverse order of their name)
{
  "total_count": 9,
  "page": 1,
  "instructions": [
    {
      "definition": {
        "temp": 50,
        "humidity": 65
      },
      "description": "Turn up the thermostat",
      "instruction_key": "e661ctd8fa",
      "max_retries": 0,
      "name": "TURNUP",
      "timeout": 30,
      "created_at": 1426142755,
      "updated_at": 1426142755
    },
    {
      "definition": {
        "value": "on"
      },
      "description": "Turn the machine on",
      "instruction_key": "e23t78333c",
      "max_retries": 0,
      "name": "TURNON",
      "timeout": 30,
      "created_at": 1425984214,
      "updated_at": 1427986515
    },
    {
      "definition": {
        "val": "off"
      },
      "description": "Turn the sensor off",
      "instruction_key": "t9t2a63b4f",
      "max_retries": 0,
      "name": "TURNOFF",
      "timeout": 30,
      "created_at": 1425912572,
      "updated_at": 1425912572
    },
    {
      "definition": {
        "status": "off"
      },
      "description": "stop machine",
      "instruction_key": "767dte9eeb",
      "max_retries": 0,
      "name": "Stop Machine",
      "timeout": 30,
      "created_at": 1448429947,
      "updated_at": 1448429947
    },
    {
      "definition": {
        "status": "on"
      },
      "description": "start machine",
      "instruction_key": "ea96tc6c57",
      "max_retries": 0,
      "name": "Start Machine",
      "timeout": 30,
      "created_at": 1448429915,
      "updated_at": 1448429915
    },
    {
      "definition": {
        "reduce_pressure": 10
      },
      "description": "",
     ...
Request - listing instructions based on some search criteria with all keywords matching
  curl -X GET -H "Content-Type:application/json" -H "X-Auth-Token:olezAZXGQn9MutnfNerKDQ" -d '{"search":"start machine"}' https://api.datonis.io/api/v3/instructions

Response (returns instructions containing both keywords 'start' as well as 'machine')
{
  "total_count": 1,
  "page": 1,
  "instructions": [
    {
      "definition": {
        "status": "on"
      },
      "description": "start machine",
      "instruction_key": "ea96tc6c57",
      "max_retries": 0,
      "name": "Start Machine",
      "timeout": 30,
      "created_at": 1448429915,
      "updated_at": 1448429915
    }
  ]
}
Request - listing instructions based on some search criteria with any of the keywords matching
  curl -X GET -H "Content-Type:application/json" -H "X-Auth-Token:olezAZXGQn9MutnfNerKDQ" -d '{"search":"start machine", "scope":"any"}' https://api.datonis.io/api/v3/instructions

Response (returns instructions containing either of the keywords 'start' or 'machine')
{
  "total_count": 2,
  "page": 1,
  "instructions": [
    {
      "definition": {
        "status": "off"
      },
      "description": "stop machine",
      "instruction_key": "767dte9eeb",
      "max_retries": 0,
      "name": "Stop Machine",
      "timeout": 30,
      "created_at": 1448429947,
      "updated_at": 1448429947
    },
    {
      "definition": {
        "status": "on"
      },
      "description": "start machine",
      "instruction_key": "ea96tc6c57",
      "max_retries": 0,
      "name": "Start Machine",
      "timeout": 30,
      "created_at": 1448429915,
      "updated_at": 1448429915
    }
  ]
}