Can I work with hook_user_login() directly within user.api.php?
The .api.php files are documentation only, they're never included in a request.

hook_user_login() can only be implemented in a module, so you'll need to write one for this.

It's pretty straightforward, the Module developer's guide will get you started quickly.