The absolutely proper way is to act on selection/subselection^{1}, not on SPItem, and use sp_desktop_set_color for that, which will take care of everything. But if you absolutely must apply color to an item regardless of selection, then you'll have to construct a cssattr with that color in fill or stroke (see how sp_desktop_set_color does that) and then call the low-level function sp_desktop_apply_css_recursive on the item.
[1] The subselection is some part or aspect of a selected object, further selected by some specific tool. Two types of subselection currently supported are text selection (a text span selected by text tool) and gradient handle selection (one of gradient handles selected by gradient tool). If there's a subselection active, any style-setting commands will apply to that subselection instead of the entire selection.
-- bulia byak Inkscape. Draw Freely. http://www.inkscape.org