How to fetch activity including custom fields using API
Let's say $params is enough to find the single activity, e.g. $params = ['activity_id' =&gt; 123] where 123 is the known Id. But it could be any other API acceptable params.

$result = civicrm_api3('activity', 'getsingle', $params)
        + civicrm_api3('activity', 'getsingle',
                       [return:'custom_%,activity_type_id'] + $params);


The custom_% results in all custom fields being added. But this won't work without activity_type_id also being requested.

(You probably know, but the $array1 + $array2 stuff in PHP means extend array 1 with key/value pairs from array 2 when the key from array 2 does not exist in array 1.)

Alternative method

You can, list every field in the activity table as well as the custom stuff and in the return parameter to one API call.

However, this assumes that you know all the fields and that they won't change over time/upgrades. So the 2-call method above ensures that you're getting all CiviCRM has to offer on your activities. (Although you have to do extra calls to get the related contacts like targets and assignees etc. of course). It could be argued that you should only request what you want anyway.