Haystack REST APIs
The Haystack REST API documentation along with Ops and Authentication can be found here:
https://finproducts.atlassian.net/wiki/spaces/JIDD3/pages/34268873225/docHaystack#HTTP-API
https://finproducts.atlassian.net/wiki/spaces/JIDD3/pages/34268873225/docHaystack#Authentication
https://finproducts.atlassian.net/wiki/spaces/JIDD3/pages/34268873225/docHaystack#Ops
Note: In order to use the eval op, you must enable the “Allow get with side effects” setting in your Host → Settings under the API section, or apply the noSideEffects tag if using functions or operations.
You can try end point: http://host/api/<projName>/read?filter=<axon filter>
Example to read about: http://host/api/<projName>/about
Example to read all operations allowed: http://host/api/<projName>/ops
Example to read all points in the database: http://host/api/<projName>/read?filter=point
Example to read all alarms in the database: http://host/api/<projName>/eval?expr=readAll(equip or point).alarms(today)
Example to read a single point history in the database: http://host/api/<projName>/hisRead?id=@p:demo:r:1eeaff9e-a14e5d23&range=today
Example to batch read history of multiple points. This requires POST request with a Zinc or JSON body, like this:
Zinc example:
ver:"3.0"
range:"today"
id @p:demo:r:1eeaff9e-a14e5d23 @p:demo:r:2bbaff9e-b24e5d34JSON example:
{
"meta": { "ver": "3.0", "range": "today" },
"cols": [{ "name": "id" }],
"rows": [
["@p:demo:r:1eeaff9e-a14e5d23"],
["@p:demo:r:2bbaff9e-b24e5d34"]
]
} Example to create a schedule. This requires POST request with a Zinc body like this:
ver:"3.0"
expr
"diff(null, { dis:\"Simple Schedule\", point, sp, schedule, kind:\"Bool\", tz:\"Los_Angeles\",
scheduleGrid:[
{ dis:\"TUE 08:00 am to 05:00 pm\", end:parseTime(\"17:00:00\"), start:parseTime(\"08:00:00\"), val:true, weekdays:\"tue\", weekly },
{ dis:\"WED 08:00 am to 05:00 pm\", end:parseTime(\"17:00:00\"), start:parseTime(\"08:00:00\"), val:true, weekdays:\"wed\", weekly },
{ dis:\"THU 08:00 am to 05:00 pm\", end:parseTime(\"17:00:00\"), start:parseTime(\"08:00:00\"), val:true, weekdays:\"thu\", weekly },
{ dis:\"FRI 08:00 am to 05:00 pm\", end:parseTime(\"17:00:00\"), start:parseTime(\"08:00:00\"), val:true, weekdays:\"fri\", weekly },
{ dis:\"MON 08:00 am to 05:00 pm\", end:parseTime(\"17:00:00\"), start:parseTime(\"08:00:00\"), val:true, weekdays:\"mon\", weekly },
{ defaultEvent, end:parseTime(\"12:00:00\"), start:parseTime(\"12:00:00\"), val:false, weekdays:\"sun,mon,tue,wed,thu,fri,sat\" }
].toGrid
}, { add }).commit"Example to add a schedule event. This requires POST request with a Zinc body like this:
ver:"3.0"
expr
"readById(@p:test:r:3144a651-795232a5)
.diff({scheduleGrid:
readById(@p:test:r:3144a651-795232a5)->scheduleGrid.addRow(
{
dis:\"TUE 08:00 am to 05:00 pm\",
end:parseTime(\"17:00:00\"),
start:parseTime(\"08:00:00\"),
val:true,
weekdays:\"tue\",
weekly
}
)
}).commit"