Hmm,
I cant see that any animal would bite without reason; there must be some reason that your hamster nipped at you. Youll have to explain in detail what you were doing just before he nipped you.
Was he busy cleaning himself? Was he sleeping? Did you try and pick him us as he was walking away from you?
The best way to stop a hamster from nipping is to treat it with respect. Im not trying to say you werent but you must be more in tune to what they are feeling, and how much you can press your luck with them before they become stressed out.
Another things you can do is make sure you wash your hand before trying to handle your ham. This will remove any food smells or pet smells from other animals in the house.
Is it possible that another animal in your house may have disturbed and upset him while you werent around and caused him to become agitated?