Airbnb Inc. is suing New York City over a recently passed law that allows the collection of Airbnb hosts’ data, claiming the ordinance violates users’ constitutional rights.

The company is hoping to avoid millions in losses when the law, designed to police short-term home rentals, takes effect this winter. The New York City legislation, which passed with a 45-0 vote, would require Airbnb to share the names and addresses of its hosts with the city’s Office of Special Enforcement.

“The ordinance is an unlawful end-run around established restraints on governmental action and violates core constitutional rights,” the company said in a claim filed in New York court on Friday.

New York, which faces an affordable housing shortage, has struggled with how to enforce regulation to control Airbnb and other home-sharing services like Expedia Inc.’s HomeAway. Regulators argue that short-term rentals, which can be more profitable than long-term leases, disrupt neighborhoods and drive up rents. The new legislation is designed to give officials enough information to catch Airbnb hosts who operate outside of strict home-sharing laws.

Some people close to Airbnb said the new bill is a devastating blow for the company. New York is one of Airbnb’s most popular markets and the legislation could inspire other cities to take a harder line on short-term home-rentals. However, Airbnb says it won’t hurt the company and other cities don’t have the same incentive to act so probably won’t pass similar rules.

“The New York City Council is a wholly owned subsidiary of the hotel industry, and they aren’t interested in working together,” said Chris Lehane, Airbnb’s head of global policy. Airbnb says it’s successfully partnering with officials in France, Australia, China and India.

In New York, Airbnb has tussled with regulators for almost a decade. In July, the company funded a civil rights lawsuit against the city. A few days later, the city sued Airbnb to force compliance with a subpoena related to an investigation into an illegal hotel.