This may be a stupid question - sorry if so. I am writing an API function to create a new case, and I want it to pre-fill the New Case form with field contents based the case source contact and two or three parameters obtained from the user. Of course I could create a new form in order to collect the user input before displaying the New Case form, but I wondered if there is a way that the API function can interrogate the user in real time to obtain the input parameters? Thanks.
API functions can be called in different contexts (eg via API Explorer, command line, in extension code etc) so prompting for user input is not practical but they can require specific parameters. You could write your API function to require parameters and then figure out how you're going to get the parameters from the user.
That said, I'm not sure an API function is really what you need here.
hook_civicrm_buildForm to add extra bits to the new case form, and
hook_civicrm_postProcess for processing the form when it is submitted may be enough.