Power output only when mains power cut and only bu ups
I have a ups in my home.I want to install a fan in my room which run only when the mains power supply is cut and ups is supplying the power.How can I do this.

As you likely already found out a normally closed relay or contactor is hard to source.  When they can be found they tend to be expensive, like this one:  https://www.kele.com/product/sku?kid=LS7K-04-G
You can get this expensive contactor, get a proper enclosure, then wire it up.  You can get the 24 VAC power supply for the coil from a number of sources, these are relatively common for things like HVAC controls and doorbells.  Plug the power supply into the mains power and have the power for the fan come off the UPS.
One other way to trigger this, and perhaps avoid the use of an expensive normally closed contactor, is see if your UPS has an output to trigger a generator.  I've seen UPSes with what is called a generator trigger to indicate a loss of mains power.  Attach this somehow to the coil of a normally open contactor so that when power is lost the contactor is closed.  Such output to trigger a generator will have a built in delay since short power glitches should not trigger a generator start.  If such a delay is acceptable in turning on your fan then this could save a lot of trouble and expense.
Either way I'm seeing this as needing a contactor of some sort to close the circuit from the UPS to the fan.  The coil will take power from mains supply or some output from the UPS.  Whether you need a cheaper and more common normally open contactor or a harder to find and more expensive normally closed depends on how and where you get that control signal.
Here's an example of a far cheaper contactor: https://www.amazon.com/Packard-C140A-Pole-Contactor-Coil/dp/B003U81D2I/
With a proper selection of parts this likely could be constructed for less than $30.  Adding other features like having the fan run based on temperature and/or humidity would add a few bucks more by using a pretty common household HVAC control.  This makes me ask if there is a need to have the fan run on a power outage.  It's likely easier and cheaper to have the fan run based on temperature.