Here you can find how to get it: http://suitelife.com/blog/barcelona-real-estate/how-to-get-a-spanish-nie-number-its-kind-of-a-big-deal
If you are citizen from a European Union country, don't need anything special, you'll get it for sure. It's something formal and need it to open a bank account for example.
If not, you'll need a company that makes you an offer and they should help you.
If you have more doubts, better ask to the spanish consulate in you country.