You need to first run "find" to get all IDs (in the "ret" property of the reply), and then pass this list of IDs in the "numbers" argument of "remove"... That's actually what happens in CLI too, but the CLI hides it, whereas the API requires you to be explicit about it.
e.g. in protocol flow:
Notice that the API's "find" command (in recent versions) returns the list separated with ";", while other commands expect the IDs to be separated with ",". You need to search and replace that on the client side.
If after doing this successfully, you decide you want to remove only items matching criteria, you'll need to stop using "find" and use "print" with a query instead, as "find" (last I checked) doesn't support queries. e.g. to remove only items that are in "list1":