How do I update an item property via code?

I want to set a value for certain items programmatically. Given that the item has a Resource Template that defines that value.

I know I can use somehow the api->update method, but I have no clue how to set the $data correctly and it is not documented either (or I couldn’t find it)

Any pointers would be nice. A workings example even better.