A court has ruled that Kim Dotcom can sue New Zealand's foreign intelligence agency for illegally spying on him for a US online piracy probe.

The New Zealand Court of Appeal refused a government request on Thursday to overturn a High Court decision that said the German Megaupload founder could seek damages from the Government Communications Security Bureau (GCSB) over his treatment.

The ruling means the GCSB will have to disclose to Dotcom's defence some details of information-sharing arrangements it had with foreign agencies, including US authorities, before the German internet tycoon's arrest in January 2012.

"This will strengthen our case in so far as GCSB remains a party to the proceedings," said William Akel, one of Dotcom's lawyers.

It emerged last September that the GCSB spied on Dotcom before armed police raided his Auckland mansion at the request of US authorities in January 2012.

Dotcom, who changed his name from Kim Schmidt, is a New Zealand resident and should have been off-limits to the agency.

New Zealand's Prime Minister John Key apologised after an official report revealed that GCSB illegally carried out surveillance on Dotcom.

The US Federal Bureau of Investigation accuses Dotcom of leading a group that netted $175 million since 2005 by copying and distributing copyrighted content without authorisation.

Compensation suit

Lawyers had argued that the government should not be required to be named twice as a defendant in the compensation suit, given that it is already listed as representing New Zealand police.

"It is preferable to require the addition of the Attorney-General as a separate party in respect of each Government entity in respect of which he or she is sued," the Appeals Court said in a written statement.

But the court limited the amount of GCSB evidence that Dotcom and his associates could access. It said that only evidence relevant to the case that was given to police would be passed on to his legal team.

Dotcom and his colleagues are fighting extradition to the US to where they are wanted on charges of online piracy, fraud and money laundering in relation to their website Megaupload. It was one of the world's most popular file-sharing sites before it was shut down last year.

The flamboyant entrepreneur maintains that Megaupload simply provided online storage services and should not be held

responsible for stored content.

Dotcom's case suffered a setback last week when a New Zealand court ruled that the US did not have to hand over all of its evidence against him.

He is due to appear at an extradition hearing in August.