Edit

GraphQL API


We are offering a Graph QL which makes it easier to perform tasks like creating/searching/resolving things. See our Tutorial in case you need a proper introduction in using our GraphQL API. We highly recommend using a GraphQL Editor (e.g. integrated in Postman) when playing around with our API.

Querying

All queries have to be sent against the following endpoint:

Request
POST https://api.connctd.io/api/v1/query
Headers:
 Content-Type:application/json
 Authorization:YOUR TOKEN
 X-External-Subject-Id:SUBJECT_ID
Body: {"query":"a valid gql query see examples below"}

Example 1: Query things and components

query {
	things {
		name,
		components {
			id,
			name
		}
	}
}

same as

{"query":"query {things {name,components{id,name}}}"}

Example 2: Query things with certain properties

query{
	things(thingConstraint: {name: "ExampleOven"}, thingComponentConstraint: {name: "Door"}){
		name
	}
}

same as

{"query":"query{things(thingConstraint: {name:\"ExampleOven\"}, thingComponentConstraint: {name: \"Door\"}){name}}"}

Example 3: Query units

query {
	units {
		name
	}
}

Example 4: Query units with certain properties

query{
	units(unitConstraint: {name:"ExampleKitchen", type:"room"}) {
		name
	}
}

Example 5: Query historic thing values with criteria

query {
    things(thingConstraint: {id: "1e999269-a90c-41a3-b388-0eef1d810317"}) {
        id
        name
        components {
            name
            properties {
                name
                history(from: "2020-04-01T22:00:00Z", to: "2020-04-30T22:00:00Z", first: 5, after: "eyJ0aW1lIjoiMjAyMC0wNC0xM1QxNToyOTo1MC44OTA0MTVaIn0=") {
                    totalCount
                    pageInfo {
                        hasNextPage
                        endCursor
                    }
                    edges {
                        node {
                            timestamp
                            value
                        }
                        cursor
                    }
                }
            }
        }
    }
}

Mutation

All queries have to be sent against the following endpoint:

Request
POST https://api.connctd.io/api/v1/query
Headers:
 Content-Type:application/json
 Authorization:YOUR TOKEN
 X-External-Subject-Id:SUBJECT_ID
Body: see examples below

Example 1: Create thing and return its id

mutation{
	createThing(thing: {
			name: "My Example Thing",
			manufacturer: "connctd",
			displayType: "core.SIREN",
			mainComponentId: "siren",
			status: AVAILABLE,
			components: [{
				id: "siren",
				name: "Siren",
				componentType: "core.SIREN",
				capabilities: ["core.SWITCH"],
				properties: [{
					id: "on",
					name: "on",
					value: "false",
					unit: "",
					type: BOOLEAN,
					propertyType: "core.ONOFF"
				}],
				actions: [{
					id: "setOn", name: "setOn", parameters: [{
						name: "on",
						type: BOOLEAN
					}]
				}]
			}]
		}
	) {
		id
	}
}

Example 2: Create a unit and return its id

mutation{
	createUnit(unit: {name: "ExampleUnit", type: "GROUP"}) {
		id
	}
}