API: Best way to find related media entries?

I’m trying to write a widget that finds and displays a list of entries related to a particular media entry, similar to the way the related media gallery works in the KDP. Is there any sort of built-in API method for this, or a best way to go about it? I’m able to get decent results by calling listAction with a tagsMultiLikeOr filter to match entries that share one or more tags with the original entry. However, it would be nice to have weighting of some sort based on the number of tags in common, shared categories, etc. Is there a simple way to accomplish this? Thanks.