Quantum API Documentation
The Quantum API is built on GraphQL, a query language that allows clients to interact with Quantum datasets and query for exactly what they need.
HTTP API Overview
An HTTP API is provided that supports authentication, user management, and GraphQL access.
The root of this API is https://passivelogic.com/api/. Detailed interactive documentation for all operations is available at https://passivelogic.com/app/swagger/.
Registering a New User
Create the account as you would for any new PassiveLogic user. Click the Sign in button on passivelogic.com, click Sign up, and provide your information. Using the link you receive in an email message, verify your email address to complete the sign up. For getting data, best practice would be to make a user just for queries, with Viewer permissions only. Note: Making accidental changes to the database with the API can cause problems that might not be reversible, or fixable only with PassiveLogic support.
Generating API Key
If you want to run queries from the command line, use Swagger to generate the API key. Sign in to passivelogic.com first through the browser, and then go to https://passivelogic.com/app/swagger/#/Authentication/getApiV0.20AuthApi-keyGenerate. From there you can generate the API key along with defining how long until it expires. The Swagger tool will display the response body containing the key.
API Keys act with the same permissions as a JWT, but provide a longer-lived and more convenient use pattern for command-line and scripting purposes.
Querying with GraphQL
Once an API key has been generated, GraphQL queries can be requested from https://passivelogic.com/api/graphql. This is a way that you could create automated queries.
For example, to query all the sites and their names using an API Key:
curl -X 'POST' \
https://passivelogic.com/api/graphql \
-H 'accept: application/json' \
-H 'Authorization: PL-API-KEY <KEY>' \
-H 'Content-Type: application/json' \
-d '{"query": "query { sites { name } }"}'The GraphQL API supports GET and POST request formats.
Support for GraphQL subscriptions is available through the https://passivelogic.com/api/graphqlSubscribe endpoint, which will open a WebSocket. See the Quantum API documentation for more details.
Interactive documentation of the Quantum GraphQL type system is available in the Insights app and the GraphiQL tool. Users can see what types are available in the API, their specific attributes, and their relationship with other types. This information may also be queried directly from the Quantum API using introspection queries.
Example GraphQL Query
Here's an example of querying time series data for a particular Sense Nano:
query {
equipments(where:
{name: {isEqualTo:"Inventory Sense Nano 1"}}) {
name
equipmentComponents {
name
equipmentComponentPropertyRouters {
property {
name
currentValue
history(from: "2024-07-09T00:00:00Z",
to: "2024-07-10T00:00:00Z") {
ts
val
}
}
}
}
}
}