Search for users with service desk users excluded?

Is there any way to search for jira users using the REST api and excluding service desk users from the search results? Have not succeeded to find the right endpoint for it on here

Do you mean that you want to exclude portal-only customers? If so, then consider the Find users end-point, or the experimental Search users end-point. You could examine the applicationRoles in the returned JSON values.

The trick is to recognise that portal-only customers are Jira users that do not have access to any Jira applications.

Is there any documentation about the query language that is described in the search users end-point, because i cannot seem to figure it out

Apart from the very few examples provided in the API documentation, no.