How to enumerate user permissions from API

We are building a system that would like to get an idea of what permissions a certain user has. Of special interest is granular or custom permissions added to a specific user regardless their role. However, I am getting lost in the labyrinth of oddly named tables sppermission, spprincipal etc. What kind of API call would suffice in getting a list of a particular user’s permissions?