I'm not 100% certain about the legal side, but surveillance cameras are generally legal to use in your home or business or any public place, though you'll probably need to get permission from your apartment manager to record in the lobby or basement areas. As for the technical side, there are few things to keep in mind:
* Megapixels are meaningless for spy cameras. Actually, megapixels are meaningless for most cameras, but doubly so for spy cameras, since the small aperture size combined with the fact that you'll probably be using it in low-light conditions means there will be very few photons hitting the sensor, resulting in a blurry, grainy image regardless of the resolution. Greater resolution doesn't mean a clearer picture.
* The lux rating is most important if you're going to be using the camera in low-light conditions. The lower the rating, the less light is needed to get a clear image.
* Most colour cameras do not pick up IR light (and the ones that do get unnatural colours when used with an IR illuminator, which defeats the whole purpose of using a colour camera), so if you intend to use an IR illuminator for night vision, you'll need to stick with black and white.
* IR illuminators tend to be hideously expensive, but you can improvise one using an incandescent light source and an IR filter. Mag Instrument sells IR lens kits for their flashlights for under $50.