How can i alter attributes via the Api?

Yes this can work. Posting the code you are working on will help us help you. @dezmo posted some good links, search the forum there are lots of examples, this one might be a good starting point: