You should be able to get your deposit back--and possibly additional damages, such as retroactive rent abatement for the time you lived there, and/or the costs of making an additional move--under three possible theories:1) If the building code is violated so that the premises was not a legal rental, then the landlord could not lawfully rent it; an illegal contract is void ab initio, or from the beginning (day 1).2) If you were forced out because you could not longer live there--the premises was not fit for residence--then that is contructive eviction; it is like the landlord illegally evicted you.3) If you were renting an apartment with working plumbing--e.g. that's what you intended to rent and that's what the lease could be reasonably construed as providing for, it may have been a lease violation by the landord to rent you the space in the condition it was in.If the landlord won't voluntarily return the money you are owed, you may have to sue. You should speak with an attorney in detail, to discuss bringing a lawsuit and also what other damages you may be entitled to.