There is something, in 5e, that (sort of) does what you want
You stated in a comment:
'I want the meta information, but I'd need to obtain it via non-meta methods.'
Have you considered the seventh level ability of Battle Master Fighters?
Know Your Enemy
Starting at 7th level, if you spend at least 1 minute observing or interacting with another creature outside combat, you can learn certain information about its capabilities compared to your own. The DM tells you if the creature is your equal, superior, or inferior in regard to two of the following characteristics of your choice:
- Strength score
- Dexterity score
- Constitution score
- Armor Class
- Current hit points
- Total class levels (if any)
- Fighter class levels (if any)
Note: While this is related to what your asking for, it's a bit more limited than what you want. It only lets you find out how their total class levels compare to yours (not what class/classes those levels are in) and how their total Fighter class levels compare to yours. If the only NPCs your ever curious about are pure Fighters then this would go some way to solving your problem, otherwise, not so much.
That said, the other five categories of things that you can find out via the Know Your Enemy ability are much more widely, and consistently useful.
How does this Fighter class-feature help me? I'm a sorcerer.
Well, the fact that this feature even exists within the game does a couple of useful things:
- It tells us that giving you the meta information, that you want to know, for 'free' would almost certainly be imbalanced.
When you want to do something that renders an in-game class feature obselete that's a pretty strong red flag that you might be wanting to do something that could unbalance your game. In this case your 'free' question wouldn't just override the need for this ability - it'd actually be much stronger than this ability, providing you with more detailed (and less limited) information.
- However, if your DM is open to homebrew ideas, it sets a precedent for this kind of information being accessible to PCs, under the right conditions.
If your DM is open to homebrew, then you can point out Know Your Enemy as a precedent around which to shape a way for your character to gain a similar ability. I'd suggest creating either a magic item or a feat to be sensible way forward.
The feat, could be inspired by other mental feats like Keen Mind or Observant, and might look somethign like this:
Insightful
You have a mind that can, given enough time to observe an enemy, make accurate predictions about their abilities and possible courses of action. You gain the following benefits:
- Increase your Intelligence or Wisdom score by 1, to a maximum of 20.
- If you spend at least 1 minute observing or interacting with another creature outside combat, you can learn certain information about their capabilities. The DM tells you the what class levels, or spell casting levels the NPC has (if any).
If I was instead making an item (say, for instance The Ring of Knowledge, then it would require attunement, and I'd probably remove the ability stat increase. This is replacing a class-feature, so in order to keep it balanced there needs be a cost to taking it (whether that's taking a feat instead of an ASI, or using one of your attunement slots).
Caveats:
I'm aware that I've strengthened this ability 9as compared to Know Your Enemy), by suggesting that the DM provide the player with exact specific information, as opposed to just how the NPC's abilities compare to the player's own abilities. However, I don't think this would be overpowered as I've also removed the much more generically useful functions to learn about NPC's ability scores, armor class and hit points.
The risk with this feat is probably not that it would be too overpowered, but rather it might end up being quite useless. As has been pointed out by a number of the other answers, most NPCs don't have class levels at all.
You'd need to know, from your DM, whether this feat was likely to have any real use in your campaign, or not. If, as is common, he wasn't planning to give class levels to many NPCs, then you might want to forget this idea, or add back in some of the extra functionality from Know Your Enemy, such as AC and HP, for instance.