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

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:[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?




Thank you! Worked exactly as expected!

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 => console.log(res));
filter: {$or: [{category:4}, {category:5}]}

Awesome, thanks!

One more quick question:
What to these do:

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

in the request body?

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.

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

You can try

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