GraphQL API

How to use and access the Datacake GraphQL API.

Introduction

Datacake is fully powered by a GraphQL API, accessible at https://api.datacake.co/graphql/.

Generate Access Token

To read or write any data, you need to authenticate with an access token. You can generate access tokens in your user settings.

See this guide on how to create access tokens:

Note that access tokens give access to your account! Store them securely and do not share them with anyone.

You then have to pass this personal access token in the Authorization header as a token:

Authorization: Token <YOUR_TOKEN_HERE>

If you do not authorize correctly, your request will be treated as unauthenticated.

Browse Documentation

For now, the only documentation for the API is exploring the schema with the GraphiQL at https://api.datacake.co/graphql/ (click the "Docs" button on the upper right edge).

Authenticate

To authenticate in GraphiQL, paste your API token in the corresponding field at the top of the page:

If you do not authorize correctly, your request will be treated as unauthenticated. The easiest way to check if you are authorized is to query for the authenticated user data:

query {
user {
id
}
}

If the returned user object is null, the request is not authenticated.

If you have any specific questions on how to achieve certain tasks, feel free to ping us directly at support@datacake.de, we would be happy to help!

Examples

Here are some examples of common queries.

Get all fields of a device

Query

query {
device(deviceId:"05ef17fa-8497-4f21-7c84-9f12ae049af0") {
product {
id
measurementFields {
id
fieldName
verboseFieldName
}
}
}
}

Example Response

Get all current measurements

Query

query {
device(deviceId:"05ef17fa-8497-4f21-8c84-9f12ae049af0") {
id
currentMeasurements {
id
field {
id
fieldName
verboseFieldName
}
value
}
}
}

Example Response

Get single current measurement

Query

query {
device(deviceId:"05ef17fa-8497-4f21-8c84-9f12ae049af0") {
id
currentMeasurement(fieldName:"POOLTEMP") {
value
field {
fieldName
unit
}
}
}
}