curl --request POST \
--url https://{cluster}.cognitedata.com/api/v1/projects/{project}/streams/{streamId}/records/filter \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"lastUpdatedTime": {
"gt": 1705341600000,
"lt": "2030-05-15T18:00:00.00Z"
},
"filter": {
"and": [
{
"containsAll": {
"property": [
"mySpace",
"myContainer",
"myProperty"
],
"values": [
10011,
10012
]
}
},
{
"range": {
"property": [
"my_space",
"my_container",
"my_weight"
],
"gte": 0
}
}
]
},
"sources": [
{
"source": {
"type": "container,",
"space": "mySpace,",
"externalId": "myContainer"
},
"properties": [
"someProperty"
]
}
],
"targetUnits": {
"unitSystemName": "<string>"
},
"includeTyping": true,
"limit": 42,
"sort": [
{
"property": [
"space"
],
"direction": "descending"
}
]
}
'{
"items": [
{
"space": "mySpace",
"externalId": "some_id",
"createdTime": 1720616232,
"lastUpdatedTime": 1720616232,
"properties": {}
}
],
"typing": {}
}Required capabilities:
StreamRecordsAcl:READDataModelsAcl:READ
Filter the records from the stream.
curl --request POST \
--url https://{cluster}.cognitedata.com/api/v1/projects/{project}/streams/{streamId}/records/filter \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"lastUpdatedTime": {
"gt": 1705341600000,
"lt": "2030-05-15T18:00:00.00Z"
},
"filter": {
"and": [
{
"containsAll": {
"property": [
"mySpace",
"myContainer",
"myProperty"
],
"values": [
10011,
10012
]
}
},
{
"range": {
"property": [
"my_space",
"my_container",
"my_weight"
],
"gte": 0
}
}
]
},
"sources": [
{
"source": {
"type": "container,",
"space": "mySpace,",
"externalId": "myContainer"
},
"properties": [
"someProperty"
]
}
],
"targetUnits": {
"unitSystemName": "<string>"
},
"includeTyping": true,
"limit": 42,
"sort": [
{
"property": [
"space"
],
"direction": "descending"
}
]
}
'{
"items": [
{
"space": "mySpace",
"externalId": "some_id",
"createdTime": 1720616232,
"lastUpdatedTime": 1720616232,
"properties": {}
}
],
"typing": {}
}Access token issued by the CDF project's configured identity provider. Access token must be an OpenID Connect token, and the project must be configured to accept OpenID Connect tokens. Use a header key of 'Authorization' with a value of 'Bearer $accesstoken'. The token can be obtained through any flow supported by the identity provider.
An identifier of the stream where the records are stored.
1 - 100^[a-z]([a-z0-9_-]{0,98}[a-z0-9])?$"test1"
Filter records based on the last updated time, on the space and on container(s) properties. The response supports custom sorting. Otherwise, the records in the response are sorted by last updated time.
Defines a filter request. This will let you fetch records with some necessary properties filtered by different criteria.
Matches records with the last updated time within the provided range. This attribute is mandatory for immutable streams but it's optional for mutable streams. The maximum time interval that can be defined by the attribute is limited by the stream settings. If more data needs to be queried than allowed by the stream settings, it should be done with multiple requests. For example, if stream allows querying up to 1 month of data, but a quarterly report is needed, the solution is to make 3 requests, one for each month, and then aggregate the responses.
The range must include at least a left (gt or gte) bound.
It is not allowed to specify two upper or lower bounds, e.g. gte and gt, in the same filter.
gte: Greater than or equal to.
gt: Greater than.
lte: Less than or equal to.
lt: Less than.
Note: lastUpdatedTime is a CDF generated timestamp that marks the moment a record is stored in the API
The range bounds can be specified in two formats:
2030-05-15T18:00:00.00Z).1705341600000).Show child attributes
{
"gt": 1705341600000,
"lt": "2030-05-15T18:00:00.00Z"
}Build a new query by combining other queries, using boolean operators. We support the and, or, and
not boolean operators.
Show child attributes
{
"and": [
{
"containsAll": {
"property": ["mySpace", "myContainer", "myProperty"],
"values": [10011, 10012]
}
},
{
"range": {
"property": ["my_space", "my_container", "my_weight"],
"gte": 0
}
}
]
}List of containers and their properties which values should be selected for the response.
1 - 10 elementsShow child attributes
NB! This parameter requires an alpha header to use.
Properties to convert to another unit. The API can only convert to another unit, if a unit has been defined as part of the type on the underlying container being queried.
Use unitSystemName to convert all properties to the target unit system without
specifying each property individually.
NB! Unit conversion is applied to both the response and the request. For example, let's assume
there is a temperature property with its unit defined as temperature:deg_c. If
one requests conversion of this property to temperature:k unit,
then all values of this property in response will be converted to Kelvin.
But also all values of this property in request (e.g. in a filter)
are expected to be provided in Kelvin.
Show child attributes
NB! This parameter requires an alpha header to use.
If set to true, property type information will be included into response.
Only following properties are included:
items response parameter (for /filter and /sync responses)filter request parametertargetUnits request parameteraggregates request parameter (for /aggregate request )true
Limits the number of results to return.
1 <= x <= 100042
Ordered list of sorting specifications (property, direction, etc) to sort on.
1 - 5 elementsShow child attributes
Was this page helpful?