Skip to content

Commit fa92db2

Browse files
Merge pull request #238486 from dominicbetts/central-property-queries
IoT Central: remove property-based REST API queries
2 parents 36c710b + 297e035 commit fa92db2

File tree

1 file changed

+13
-32
lines changed

1 file changed

+13
-32
lines changed

articles/iot-central/core/howto-query-with-rest-api.md

Lines changed: 13 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
---
22
title: Use the REST API to query devices in Azure IoT Central
3-
description: How to use the IoT Central REST API to query devices in an application
3+
description: How to use the IoT Central REST API to query devices in an application, including filters, aggregation, and sorting.
4+
titleSuffix: Azure IoT Central
45
author: dominicbetts
56
ms.author: dobett
6-
ms.date: 06/14/2022
7+
ms.date: 05/19/2023
78
ms.topic: how-to
89
ms.service: iot-central
910
services: iot-central
@@ -15,7 +16,6 @@ services: iot-central
1516
The IoT Central REST API lets you develop client applications that integrate with IoT Central applications. You can use the REST API to query devices in your IoT Central application. The following are examples of how you can use the query REST API:
1617

1718
- Get the last 10 telemetry values reported by a device.
18-
- Get the last 24 hours of data from devices that are in the same room. Room is a device or cloud property.
1919
- Find all devices that are in an error state and have outdated firmware.
2020
- Telemetry trends from devices, averaged in 10-minute windows.
2121
- Get the current firmware version of all your thermostat devices.
@@ -28,9 +28,6 @@ Every IoT Central REST API call requires an authorization header. To learn more,
2828

2929
For the reference documentation for the IoT Central REST API, see [Azure IoT Central REST API reference](/rest/api/iotcentral/).
3030

31-
> [!IMPORTANT]
32-
> Support for property queries is now deprecated in the IoT Central REST API and will be removed from the existing API releases.
33-
3431
[!INCLUDE [iot-central-postman-collection](../../../includes/iot-central-postman-collection.md)]
3532

3633
To learn how to query devices by using the IoT Central UI, see [How to use data explorer to analyze device data.](../core/howto-create-analytics.md)
@@ -102,24 +99,19 @@ The following sections describe these clauses in more detail.
10299

103100
## SELECT clause
104101

105-
> [!IMPORTANT]
106-
> Support for property queries is now deprecated in the IoT Central REST API and will be removed from the existing API releases.
107-
108102
The `SELECT` clause lists the data values to include in the query output and can include the following items:
109103

110104
- Telemetry. Use the telemetry names from the device template.
111-
- Reported properties. Use the property names from the device template.
112-
- Cloud properties. Use the cloud property names from the device template.
113105
- `$id`. The device ID.
114106
- `$provisioned`. A boolean value that shows if the device is provisioned yet.
115107
- `$simulated`. A boolean value that shows if the device is a simulated device.
116108
- `$ts`. The timestamp associated with a telemetry value.
117109

118-
If your device template uses components such as the **Device information** component, then you reference telemetry or properties defined in the component as follows:
110+
If your device template uses components, then you reference telemetry defined in the component as follows:
119111

120112
```json
121113
{
122-
"query": "SELECT deviceInformation.model, deviceInformation.swVersion FROM dtmi:azurertos:devkit:hlby5jgib2o"
114+
"query": "SELECT ComponentName.TelemetryName FROM dtmi:azurertos:devkit:hlby5jgib2o"
123115
}
124116
```
125117

@@ -131,9 +123,7 @@ The following limits apply in the `SELECT` clause:
131123

132124
- There's no wildcard operator.
133125
- You can't have more than 15 items in the select list.
134-
- In a single query, you either select telemetry or properties but not both. A property query can include both reported properties and cloud properties.
135-
- A property-based query returns a maximum of 1,000 records.
136-
- A telemetry-based query returns a maximum of 10,000 records.
126+
- A query returns a maximum of 10,000 records.
137127

138128
### Aliases
139129

@@ -179,7 +169,7 @@ Use the `TOP` to limit the number of results the query returns. For example, the
179169
}
180170
```
181171

182-
If you don't use `TOP`, the query returns a maximum of 10,000 results for a telemetry-based query and a maximum of 1,000 results for a property-based query.
172+
If you don't use `TOP`, the query returns a maximum of 10,000 results.
183173

184174
To sort the results before `TOP` limits the number of results, use [ORDER BY](#order-by-clause).
185175

@@ -211,22 +201,16 @@ The time window value uses the [ISO 8601 durations format](https://en.wikipedia.
211201

212202
| Example | Description |
213203
| ------- | -------------------------- |
214-
| PT10M | Past 10 minutes |
204+
| PT10M | Past 10 minutes |
215205
| P1D | Past day |
216-
| P2DT12H | Past 2 days and 12 hours |
206+
| P2DT12H | Past 2 days and 12 hours |
217207
| P1W | Past week |
218208
| PT5H | Past five hours |
219209
| '2021-06-13T13:00:00Z/2021-06-13T15:30:00Z' | Specific time range |
220210

221-
> [!NOTE]
222-
> You can only use time windows when you're querying for telemetry.
223-
224211
### Value comparisons
225212

226-
> [!IMPORTANT]
227-
> Support for property queries is now deprecated in the IoT Central REST API and will be removed from the existing API releases.
228-
229-
You can get telemetry or property values based on specific values. For example, the following query returns all messages where the temperature is greater than zero, the pressure is greater than 50, and the device ID is one of **sample-002** and **sample-003**:
213+
You can get telemetry based on specific values. For example, the following query returns all messages where the temperature is greater than zero, the pressure is greater than 50, and the device ID is one of **sample-002** and **sample-003**:
230214

231215
```json
232216
{
@@ -245,10 +229,8 @@ The following operators are supported:
245229
The following limits apply in the `WHERE` clause:
246230

247231
- You can use a maximum of 10 operators in a single query.
248-
- In a telemetry query, the `WHERE` clause can only contain telemetry and device metadata filters.
249-
- In a property query, the `WHERE` clause can only contain reported properties, cloud properties, and device metadata filters.
250-
- In a telemetry query, you can retrieve up to 10,000 records.
251-
- In property query, you can retrieve up to 1,000 records.
232+
- In a query, the `WHERE` clause can only contain telemetry and device metadata filters.
233+
- In a query, you can retrieve up to 10,000 records.
252234

253235
## Aggregations and GROUP BY clause
254236

@@ -312,8 +294,7 @@ The current limits for queries are:
312294
- No more than 10 logical operations in the `WHERE` clause.
313295
- The maximum length of a query string is 350 characters.
314296
- You can't use the wildcard (`*`) in the `SELECT` clause list.
315-
- Telemetry-based queries can retrieve up to 10,000 records.
316-
- Property-based queries can retrieve up to 1,000 records.
297+
- Queries can retrieve up to 10,000 records.
317298

318299
## Next steps
319300

0 commit comments

Comments
 (0)