If you can create a view in your list that gives you the items you want, you can get the CAML query using this snippet of code. Just hit F12 to bring up the developer tools, select the Console and paste the below snippet (you might have to type in the text “allow pasting” if you cannot paste the text):
const payload = {
method: 'GET',
headers: { "Accept": "application/json; odata=verbose" },
credentials: 'same-origin'
}
fetch(_spPageContextInfo.webServerRelativeUrl + "/_api/web/lists/getById('"+_spPageContextInfo.pageListId+"')/views/getById('"+_spPageContextInfo.viewId+"')", payload ).then(data => {
return data.json()
}).then(json => {
console.log(json);
console.log(json.d.ViewQuery);
});
Alexander