GraphQL API
Endpoint / Playground
Use any api client, or use your browser to access our graphql playground. https://iot.dimensionfour.io/graph
Headers
To follow the steps below you need to include either a valid session cookie (e.g. from running the login mution in the playground), or use a token. Make sure you have followed the steps in the auth section
Using session cookie or playground with login mutation
// Headers:
{ "x-tenant-id": "tenant-id" }
Using token
// Headers:
{ "x-tenant-id": "tenant-id", "x-tenant-key": "<token>"}
Space
Create
mutation CREATE_SPACE {
space {
create(input: { name: "All devices" }) {
id
name
}
}
}
Response
{
"data": {
"space": {
"create": {
"id": "6195f5469a14ca90eb220e5f",
"name": "All devices"
}
}
}
}
Query
query LIST_SPACES_WITH_POINTS {
spaces {
edges {
node {
id
name
points {
edges {
node {
id
name
}
}
}
}
}
}
}
Response
{
"data": {
"spaces": {
"edges" : [
{
"id": "6195f5469a14ca90eb220e5f",
"name": "All devices",
"points": {
"edges": []
}
}
]
}
}
}
Update
mutation UPDATE_SPACE {
space {
update(input: {
id: "6195f5469a14ca90eb220e5f"
data: {
metadata: {
myCustomKey: "my custom information"
}
}
}) {
id
name
metadata
}
}
}
Response
{
"data": {
"space": {
"update": {
"id": "6195f5469a14ca90eb220e5f",
"name": "All devices",
"metadata": {
"myCustomKey": "my custom information"
}
}
}
}
}
Delete
mutation DELETE_SPACE {
space {
delete(input: {
id: "6195f5469a14ca90eb220e5f"
}) {
id
}
}
}
Response
{
"data": {
"space": {
"delete": {
"id": "6195f5469a14ca90eb220e5f"
}
}
}
}
Point
Create
mutation CREATE_POINT {
point {
create(input: {
spaceId: "<insert_spaceId>"
name: "Our device with sensors"
}){
id
}
}
}
Response
{
"data": {
"point": {
"create": {
"id": "6195f58364d3a66041c9548b",
"name": "Our device with sensors"
}
}
}
}
Query
query LIST_POINTS_WITH_SPACE {
points {
edges {
node {
id
name
space {
id
name
}
}
}
}
}
Response
{
"data": {
"points": {
"edges": [
{
"id": "6195f58364d3a66041c9548b",
"name": "Our device with sensors",
"space": {
"id": "6195f5469a14ca90eb220e5f",
"name": "All devices"
}
}
]
}
}
}
Update
mutation UPDATE_POINT {
point {
update(input: {
id: "6195f58364d3a66041c9548b"
point: {
name: "newName"
}
}) {
id
name
}
}
}
Response
{
"data": {
"point": {
"update": {
"id": "6195f58364d3a66041c9548b",
"name": "newName"
}
}
}
}
Delete
mutation DELETE_POINT {
point {
delete(input: {
id: "6195f58364d3a66041c9548b"
}) {
id
}
}
}
Response
{
"data": {
"point": {
"delete": {
"id": "6195f58364d3a66041c9548b"
}
}
}
}
Signal
Create
mutation CREATE_SIGNAL {
signal {
create(input: {
pointId: "<insert_pointId>"
signals: [
{
unit: CELSIUS_DEGREES
value: "22.2"
type: "air temperature"
timestamp: "2021-11-17T14:30:21.000+00:00"
}
]
}) {
id
pointId
unit
type
data {
numericValue
rawValue
}
}
}
}
Response
{
"data": {
"signal": {
"create": [
{
"id": "6195f5fdc1bbb47401b07fa2",
"pointId": "6195f58364d3a66041c9548b",
"unit": "CELSIUS_DEGREES",
"type": "air temperature",
"data": {
"numericValue": 22.200000762939453,
"rawValue": "22.2"
}
}
]
}
}
}
Query
note
Note how value
is converted to numericValue
and rawValue
wrapped inside the data
field. rawValue
will always be what was inserted, but if the value is numeric it will be available as a numeric in the numericValue
field. Otherwise that field will be null
.
Latest signals
query LATEST_SIGNALS {
signals(
paginate: { last:10 }
){
edges {
node {
id
timestamp
createdAt
type
unit
pointId
data {
numericValue
rawValue
}
}
}
}
}
Response
{
"data": {
"signals": {
"edges": [
{
"node": {
"id": "6195f5fdc1bbb47401b07fa2",
"timestamp": "2021-11-17T14:30:21.000000000+0000",
"createdAt": "2021-11-18T06:43:09.854000000+0000",
"type": "air temperature",
"unit": "CELSIUS_DEGREES",
"pointId": "6195f58364d3a66041c9548b",
"data": {
"numericValue": 22.200000762939453,
"rawValue": "22.2"
}
}
}
]
}
}
}
Latest signal from one point
query LATEST_SIGNAL_FROM_MY_DEVICE {
points(where: { name: { _EQ: "Our device with sensors" } }) {
edges {
node {
temperature: signals(
where: { type: { _EQ: "air temperature" }}
paginate: { last:1 }
){
edges {
node {
id
timestamp
createdAt
type
unit
pointId
data {
numericValue
rawValue
}
}
}
}
}
}
}
}
Response
{
"data": {
"points": {
"edges": [
{
"node": {
"temperature": {
"edges": [
{
"node": {
"id": "622b2873286affefc10e2705",
"timestamp": "2022-03-11T11:30:00.000000000+0000",
"createdAt": "2022-03-11T10:46:11.789000000+0000",
"type": "air temperature",
"unit": "CELSIUS_DEGREES",
"pointId": "622b25fc4a7daf164a449f86",
"data": {
"numericValue": 22.200000762939453,
"rawValue": "22.2"
}
}
}
]
}
}
}
]
}
}
}