Trying to get a list of cards from a specific user on a specific board

Hi,

I’m trying to pull back all the cards on a board where a specific user is a member, and the only way I can see to do this is to use the search function which doesn’t seem to be working as I’d expect.

I’m just using a simple php curl request to get the data via the API with the following code

$query = "@$username board:$boardID";
$cardsLimit = 5;
$cardFields = "name,url";

$curl = curl_init();
                
curl_setopt_array($curl, array(
    // use a search query
    CURLOPT_URL => "https://api.trello.com/1/search?query=" . $query . "&cards_limit=" . $cardsLimit . "&card_fields=" . $cardFields . "&key=" . $apikey . "&token=" . $serverKey,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_ENCODING => "",
    CURLOPT_MAXREDIRS => 10,
    CURLOPT_TIMEOUT => 30,
    CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
    CURLOPT_CUSTOMREQUEST => "GET",
    CURLOPT_HTTPHEADER => array(
       "Accept: application/json",
    ),
));
                        
$response = curl_exec($curl);  

I know the username and the board id in advance, and when i use the same query (something like"@user_name board:1239876scsjkh198kjs") in Trello’s search it works fine and pulls back the expected results, but via the API I get no results.

If I modify the query above to the following it does return cards as expected so I know the API call works ok.

$query = "@$username";

but if I modify it to be just that board it returns nothing whereas the UI in trello returns cards fine (although I need a space, which I have tried in the code too, e.g. “board: 12387kh21498gh1322g”)

$query = "board:$boardID";

I feel like I’m either missing an easy way to filter cards on a board by user, or not quite getting the search functionality right? Can anyone point me in the right direction?