AFAIK, the only way is to parse it from the Advancement channel chat message when you gain xp. You would simply have to have a chat handler installed that looks for messages like "You've earned 24 XP for a total of 8,866 XP." in the Advancement channel and capture the total. I would recommend using the string.match function and learning about Lua patterns (similar to regex but not exactly the same) and captures. There are quite a few examples of chat handlers in existing plugins. Then whenever the player earns any xp you can start tracking the total - of course this only works if the user keeps your plugin loaded at all times.
Actually, this makes a lot of sense. If I can get access to the text saying "You gained X xp for a total of Y xp" then I only need to extract the total XP.
I should know how much XP you need for each level, because it's available on the wiki and I can just hardcode it.
And I already know your current level.
With all of this, you only need to gain xp once from any source for the plugin to get back to date!