xAPI is H5P's standard for communitcation about what the users does between libraries and externally. To user the xAPI features within your library you need to add H5P's event system to your library. After that you may have your library trigger xAPI events like this:
Or use the short hand version like this:
If your library has child libraries you might want to listen for xAPI events triggered by your children. For instance if you want to act when the user does an attempt you do it like this:
All features of the xAPI Event are documented in the xAPIEvent reference.