The function "client_get_by _username" is deprecated and will be removed, so dont use it for new projects. Use the client_get function instead. If you want to get a client by username, the correct syntax is:
$client_record = $client->client_get($session_id, array('username' => 'myuser'));
There is a lot of ID's. What is difference between "userid", "client_id", "sys_userid" and "sys_groupid"?
The only relevant ID when using the API is the client_id. The other id's are internal ID's from ispconfig to manage the permissions of the records.