Add/Remove Favorite

Is there an API to add/remove favorites in Kodi?

I’m trying to programatically add favorites to PlayMedia but I don’t want to do it by writing directly to the favoruites.xml. Is there a method to do this?

Thanks.