If it is just muscle spasms, stretching should ease the pain. If it is constant, you should see a doctor. There are many people who would say you should go to the doctor first. If you want to research cramps and hip pain, I would suggest you start at the National Institutes of Health, nih.gov
Factors might be age (especially to women, in some studies they are prone to hip problems), temperature, over fatigue, health conditions (especially if you have recently diagnosed of something serious), and any history of hip problems, osteoarthritis in your family.
Other people asked questions on similar topics, check out the answers they received:
Other people asked questions on various topics, and are still waiting for answer. Would be great if you can take a sec and answer them