Data Lake
Searching data with OpenGate API
The searching API lets you retrieve provisioned and collected information from the entities registered on the platform.
Using search API, you can manage many situations in which you need to get information, collected by OpenGate, about your remote devices.
Some examples of questions you can answer using the searching API are:
- Where is my lost truck?
- Is my vending machine connected to Internet?
- What is the software version of this smart meter which is rebooting all the time?
- How is the signal strength of this weather station which is off-line most of the time?
- What are the latest operations launched over different devices and their current status?
- What are the latest raised alarms associated with my in-field resources?
- What is the latest value and history of different sensors and machine parameters?
Searching Features
Where are the FROM and WHERE?
Well, if you’re still thinking in SQL, then you’ll expect to find the word FROM anywhere. Remember, OpenGate exposes its API through a REST interface, so in this case the word FROM is in the URL suffix.
That suffix is the resource you are querying, and every available one is listed in
What you can query. The WHERE — and the ORDER BY, the SELECT and the
GROUP BY — is the JSON body described below.
In all response cases, you must POST a valid JSON query and you’ll get an array with the matched specific resources. The query could have next main objects:
filter: Allows to select the resources that meets with desired information, see Filteringlimit: Allows paginating the response, see Paginationsort: Allows sorting the results, see Sortingselect: Allows selecting only the parameters you need, see Selectinggroup: Allows grouping the results, see Grouping
Procedure
Searching in OpenGate platform is pretty easy. You have to send a HTTP request to the API using the POST method, the prefix always is /north/v80/search. Optionally you can attach a JSON file (in the HTTP body) if you need to use paging, sorting, selecting, grouping or filtering features.
You can use the URL above for searching information. So for the impatient, let’s suppose you’re trying to search over your previously provisioned device list, and you’re thinking in a SQL WHERE clause like that:
in this case you must use https://api.opengate.es/north/v80/search/devices URL and POST a JSON payload like that:
Requesting with curl:
Then you’ll receive the device list matching with your query, the response body should be something like that.
Where to go next
The clauses above are documented one page each, below. Two things live outside this section:
- Which URL to POST to: What you can query indexes every search endpoint.
- Where the clauses behave differently: time series and data sets accept the same syntax with stricter rules and a different response shape. The differences are collected in Query dialects.