New York's attorney general and the website Airbnb have reached agreement on information disclosures about short-term New York City apartment rentals by Airbnb members.

Attorney General Eric Schneiderman had demanded the information in an probe aimed at cracking down on illegal hotels.

Attorneys for both sides confirmed the agreement Wednesday, saying it balances concern about  illegal hotels with the Airbnb's worry about violating the privacy of thousands of people who use the website to rent their apartments to visitors.

It requires the company to provide investigators with information about city apartment listings within 51 days, with renters and properties identified only by assigned numbers.

'We wanted to do everything we could to avoid turning over data on thousands of regular New Yorkers, so we continued to work with the attorney general's office' - Airbnb's David Hantman

After the attorney general's investigators review that information, Airbnb will provide user names, apartment numbers and tax identification numbers only about those suspected of breaking the law.

"We are going to pursue anyone who's running illegal hotels," Schneiderman told The Associated Press.

The agreement also protects the privacy of people who are just renting out a room in their apartment and not violating the law, he said.

"We view this as a template for other places in the country where the issue has been raised," Schneiderman said.

A subpoena filed last year sought information about Airbnb's hosts going back three years, noting many listings appeared to offer unoccupied apartments for very short periods, violating rules against unregulated hotels.

A judge last week rejected Schneiderman's request to subpoena information about hosts, saying it was overly broad. However, Judge Gerald Connolly wrote there was evidence that "a substantial number of hosts" may be violating New York law and tax provisions. The subpoena request was narrowed and refiled.

The state law prohibits owners or renters of apartments in multi-unit buildings from renting them for less than 30 days unless they remain present. The law permits having boarders or renting rooms.

"We wanted to do everything we could to avoid turning over data on thousands of regular New Yorkers, so we continued to work with the attorney general's office and we now believe we have reached an agreement that will protect the privacy of thousands of Airbnb hosts, while allowing the attorney general to investigate bad actors and move us forward," Airbnb's David Hantman said in a web posting Wednesday.

Run afoul of Canadian law

Hantman said the company is committed to working with authorities around the world to ensure they know more about home sharing and how it makes neighbourhoods better places to live. He noted New York's law that made the investigation possible is still on the books, "and we need to change that law to allow anyone in New York who wants to rent out their own home to do so."

The Airbnb rental service has also run afoul of licensing and rental laws in Canada, with Quebec cracking down on some operators last year

San Francisco has also attempted to introduce laws to limit the amount of time people can rent out their homes and create a registry of renters. Airbnb has agreed to a plan that will collect taxes directly from guests as an extra charge on their bill in San Francisco and Portland, Ore.