I once was told that you can use the API DB queries also in extensions. All I find in the docs are use cases for calling api.php via ajax.
Topic on Project:Support desk
See API:Calling internally. Does that give you enough guidance?
Ah, thanks! I will work me through this.