# Any way to apply a filter with multiple values via a URL API call?

**URL:** https://discourse.getcockpit.com/t/any-way-to-apply-a-filter-with-multiple-values-via-a-url-api-call/1051
**Category:** Support
**Created:** [October 8, 2019, 9:11pm UTC](https://discourse.getcockpit.com/t/any-way-to-apply-a-filter-with-multiple-values-via-a-url-api-call/1051 "2019-10-08T21:11:03Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![EAllison](https://avatars.discourse-cdn.com/v4/letter/e/b9e5f3/32.png) [@EAllison](https://discourse.getcockpit.com/u/EAllison)
#### Post date: [October 8, 2019, 9:11pm UTC](https://discourse.getcockpit.com/t/any-way-to-apply-a-filter-with-multiple-values-via-a-url-api-call/1051/1 "2019-10-08T21:11:03Z")

</div>

I’m consuming data via PHP’s file\_get\_contents, and so far all is good. As an example, this works great if want to get an entry with a field (category) that has a specific value:

`https://domain.com/cockpit/api/collections/get/MyCollection?token=myToken&filter[category]=3`

What I’m trying to accomplish is attempting to construct an API call that returns entries if they match an array of values (3, 4, 5, etc.), adding these values as additional filter parameters doesn’t work. `&filter[category]=3&filter[category]=4&filter[category]=5`

Is there a way to do this via URL API calls so it returns any entries that match an array of values?

---

<div class="post-metadata">

### Author: ![artur](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.getcockpit.com/artur/32/4_2.png) [@artur](https://discourse.getcockpit.com/u/artur)
#### Post date: [October 8, 2019, 11:06pm UTC](https://discourse.getcockpit.com/t/any-way-to-apply-a-filter-with-multiple-values-via-a-url-api-call/1051/2 "2019-10-08T23:06:03Z")

</div>

> [@EAllison](#):
>
> filter[category]=3&filter[category]=4&filter[category]=5

try

```auto
filter[$or][][category]=3&filter[$or][][category]=4&filter[$or][][category]=5

```

---

<div class="post-metadata">

### Author: ![EAllison](https://avatars.discourse-cdn.com/v4/letter/e/b9e5f3/32.png) [@EAllison](https://discourse.getcockpit.com/u/EAllison)
#### Post date: [October 9, 2019, 12:13pm UTC](https://discourse.getcockpit.com/t/any-way-to-apply-a-filter-with-multiple-values-via-a-url-api-call/1051/3 "2019-10-09T12:13:43Z")

</div>

Thank you! Worked exactly as expected!

---

<div class="post-metadata">

### Author: ![reddo](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.getcockpit.com/reddo/32/489_2.png) [@reddo](https://discourse.getcockpit.com/u/reddo)
#### Post date: [February 14, 2020, 9:54am UTC](https://discourse.getcockpit.com/t/any-way-to-apply-a-filter-with-multiple-values-via-a-url-api-call/1051/4 "2020-02-14T09:54:12Z")

</div>

is there a way to do this in post body like in the docs?

```
fetch('/api/collections/get/posts?token=xxtokenxx', {
method: 'post',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
    filter: {published:true}, // <--- here
    fields: {fieldA: 1, fieldB: 1}, // <-- also, what do these do?
    limit: 10,
    skip: 5,
    sort: {_created:-1},
    populate: 1, // resolve linked collection items

    lang: 'de' // return normalized language fields (fieldA_de => fieldA)
}))
.then(res=>res.json())
.then(res => console.log(res));
```

---

<div class="post-metadata">

### Author: ![artur](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.getcockpit.com/artur/32/4_2.png) [@artur](https://discourse.getcockpit.com/u/artur)
#### Post date: [February 14, 2020, 10:06am UTC](https://discourse.getcockpit.com/t/any-way-to-apply-a-filter-with-multiple-values-via-a-url-api-call/1051/5 "2020-02-14T10:06:53Z")

</div>

```auto
filter: {$or: [{category:4}, {category:5}]}

```

---

<div class="post-metadata">

### Author: ![reddo](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.getcockpit.com/reddo/32/489_2.png) [@reddo](https://discourse.getcockpit.com/u/reddo)
#### Post date: [February 14, 2020, 10:13am UTC](https://discourse.getcockpit.com/t/any-way-to-apply-a-filter-with-multiple-values-via-a-url-api-call/1051/6 "2020-02-14T10:13:47Z")

</div>

Awesome, thanks!

One more quick question:  
What to these do:

```
fields: {fieldA: 1, fieldB: 1},

```

in the request body?

---

<div class="post-metadata">

### Author: ![raffaelj](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.getcockpit.com/raffaelj/32/331_2.png) [@raffaelj](https://discourse.getcockpit.com/u/raffaelj)
#### Post date: [February 15, 2020, 6:22pm UTC](https://discourse.getcockpit.com/t/any-way-to-apply-a-filter-with-multiple-values-via-a-url-api-call/1051/7 "2020-02-15T18:22:07Z")

</div>

> [@reddo](#):
>
> What to these do:
> 
> ```auto
> fields: {fieldA: 1, fieldB: 1},
> 
> ```

Your response will only have “fieldA” and “fieldB” (and “\_id”), “fieldC” etc. will be skipped. The `1` means `true`. In the post body, you can write it in boolen, the get request needs 1 or 0.

---

<div class="post-metadata">

### Author: ![reddo](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.getcockpit.com/reddo/32/489_2.png) [@reddo](https://discourse.getcockpit.com/u/reddo)
#### Post date: [February 15, 2020, 6:51pm UTC](https://discourse.getcockpit.com/t/any-way-to-apply-a-filter-with-multiple-values-via-a-url-api-call/1051/8 "2020-02-15T18:51:08Z")

</div>

Cool, thanks for the reply. I’ve also figured it out in the meantime. The docs could definitely use some love 🙂

---

<div class="post-metadata">

### Author: ![sharmasunil.07ss](https://avatars.discourse-cdn.com/v4/letter/s/e19b73/32.png) [@sharmasunil.07ss](https://discourse.getcockpit.com/u/sharmasunil.07ss)
#### Post date: [June 26, 2021, 3:59am UTC](https://discourse.getcockpit.com/t/any-way-to-apply-a-filter-with-multiple-values-via-a-url-api-call/1051/9 "2021-06-26T03:59:47Z")

</div>

You can try

let filter = {  
pageType : ‘Cart’,  
$or : [{emailSendCounter:“0”}, {emailSendCounter:“1”}],  
isOrderPlaced: ‘No’,  
isActive : ‘1’  
};
