Unfortunately, we do not have any API to enable the rating settings on list / library in SP2013. But, the same old friend – Reflection will help us.
In SP2013, Ratings are handled by ReputationHelper (obviously internal class in Microsoft.SharePoint.Portal namespace).
To enable the rating settings:
Assembly assembly = Assembly.Load("Microsoft.SharePoint.Portal, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c");
Type reputationHelper = assembly.GetType("Microsoft.SharePoint.Portal.ReputationHelper");
MethodInfo method = reputationHelper.GetMethod("EnableReputation", BindingFlags.Static | BindingFlags.NonPublic);
// "Likes" or "Ratings" as per your requirement.
method.Invoke(null, new Object[] { list, "Likes", false });To disable the rating settings:MethodInfo method = reputationHelper.GetMethod("DisableReputation", BindingFlags.Static | BindingFlags.NonPublic);
method.Invoke(null, new Object[] { list });