Skip to content
EN

Filtering items with Integration API

Last updated

When retrieving items with Integration API, you can filter them by specifying conditions. There are two ways to filter.

Adding a keyword parameter to the GET /items endpoint lets you narrow down items by keyword. See Integration API Reference for the available parameters.

Terminal window
curl -X GET \
'https://api.cms.reearth.io/api/<workspace>/projects/<project>/models/<model>/items?keyword=Tokyo' \
--header 'Authorization: Bearer <your_integration_token>'

Method 2: Condition filters (fine-grained filtering)

Section titled “Method 2: Condition filters (fine-grained filtering)”

For more complex filtering, specify conditions as JSON in a request to the POST /items/filter endpoint.

Use a condition type as the key, and specify fieldId (a field selector), operator, and value.

{
"filter": {
"<condition-type>": {
"fieldId": {
"fieldId": "<field-id>",
"type": "field"
},
"operator": "<operator>",
"value": "<value>"
}
}
}

Using the contains operator with the string condition type lets you narrow down items whose specified field contains a given substring. Here’s an example that retrieves items where the field’s value contains “Tokyo”.

Terminal window
curl -X POST \
'https://api.cms.reearth.io/api/<workspace>/projects/<project>/models/<model>/items/filter' \
--header 'Authorization: Bearer <your_integration_token>' \
--header 'Content-Type: application/json' \
--data '{
"filter": {
"string": {
"fieldId": {
"fieldId": "<field-id>",
"type": "field"
},
"operator": "contains",
"value": "Tokyo"
}
}
}'

To combine multiple conditions, use and / or.

Terminal window
curl -X POST \
'https://api.cms.reearth.io/api/<workspace>/projects/<project>/models/<model>/items/filter' \
--header 'Authorization: Bearer <your_integration_token>' \
--header 'Content-Type: application/json' \
--data '{
"filter": {
"and": [
{
"basic": {
"fieldId": { "fieldId": "<field-id-1>", "type": "field" },
"operator": "equals",
"value": "high"
}
},
{
"string": {
"fieldId": { "fieldId": "<field-id-2>", "type": "field" },
"operator": "contains",
"value": "Tokyo"
}
}
]
}
}'

For details on the available condition types and operators, see Integration API Reference.