In the last five years, the market for legal highs has exploded. It's never been easier, or cheaper, to buy drugs online – but no one knows what's in them, or how dangerous they are

For most of the last decade, an average of four or five new legal drugs came on to the market each year. Trade was steady – government efforts were focused on fighting the spread of illegal substances. And then mephedrone appeared on the scene: cheap, legal and available online. By 2010, the drug, now dubbed meow meow by journalists, had become the fourth most popular drug on the market, after marijuana, cocaine and ecstasy. It was banned in April of that year, but not before a new market had emerged for online legal highs. In 2011, EU researchers found 49 new legal drugs for sale online. In 2012, 73 were identified; hundreds more were banned.

To find out how effective the laws banning these new drugs have been, and how easy it is to buy them, I phone a lab in north-eastern China that supplies websites specialising in legal highs, and ask for bulk prices on synthetic cannabis products. A well-spoken man apologises immediately on hearing my English accent: "Sorry, I totally forgot it. I'll send it tomorrow – UK, yes?" I've never spoken to him before. Business is clearly brisk.

He offers me 1kg of a legal, synthetic cannabinoid receptor agonist (ie, a marijuana substitute) for just over £1,000. It is active at 1mg, meaning I would have a million doses that I could sell, legally, for around £25,000. He will send it to me via international courier and there will be no danger with customs in the UK, he says breezily. In any case, he can put a false label on the package. If it's seized, he will resend the drugs for free. "UK, no problem."

But synthetic cannabis is just the beginning. Another Chinese lab offers to sell me 10g of 25I-NBOMe, a hallucinogenic compound that is part of the -NBOMe series. These new drugs don't work if taken orally, so users dilute and spray them using nasal sprays or inhalers; or they drip the liquid on to patterned and perforated blotter paper, passing it off as LSD. Each gram contains a minimum of 2,000 doses, making it very easy to take too much. By way of comparison, 1g of MDMA has eight to 10 doses. And whereas LSD will not kill, even when taken in excess, these drugs are disturbing many expert observers, not least because most tabs sold as LSD in the UK right now contain an -NBOMe substance.

On 11 June 2012, Christian Bjerk, an 18-year-old from Minnesota, died after taking 25I-NBOMe. In less than a year since, researchers in the US have confirmed five deaths from the drug. As it is currently being used by only a small number of dedicated drug experimentalists, that death rate is proportionally high.

Four days after Bjerk's death, 17-year-old Elijah Stai, also from Minnesota, died after he took 25I-NBOMe, believing it to be a magic mushroom extract. Last July, 25-year-old Stephanie Chappell Hobson died in North Carolina after taking the drug with her boyfriend, Jeremy Leutgens. At the Voodoo Fest in New Orleans in October 2012, 21-year-old Clayton Otwell was offered a single drop of 25I-NBOMe up his nose as a gift from a grateful stranger whose phone he had found. He started babbling and was taken to a medical tent. He had a seizure 30 minutes later and died in hospital. In February this year, 17-year-old Krystopher Sansone died in Orange County, Florida; the coroner identified the culprit as an –NBOMe series drug, but did not say which one.

In the same month, Surrey police said that 18-year-old Charlie Barker from Wrecclesham, Farnham, died after attending an illegal party in a tunnel under Chobham Common, where he took a drug – 2CI – through a nasal inhaler. 2CI is illegal in the UK, and is commonly eaten, not consumed via a nasal inhaler. Toxicology reports are currently unavailable, but it is possible that 25I-NBOMe was responsible for the death of Barker, a talented and popular graffiti artist, since that is a more usual way of taking it.

"Not all of the -NBOMe series are that harmful," one user says. "But 25I-NBOMe is another matter. I have reason to believe that high doses or prolonged abuse may cause catastrophic seizures, brain swelling or some other severe inflammation of nerve tissue."

Chris (not his real name), a 28-year-old chemist, considers himself an expert user: he has taken more than 40 different legal and illegal drugs in the past few years. But recently he ended up in hospital after trying 25I.

"This was not an overdose – I measured it correctly and I have a long-standing relationship with my supplier. It comes on very quickly and within five minutes I was tripping my balls off, trying to call friends [for help], but I couldn't use my phone. At the same time my heart rate was going up and then I started to panic. It all snowballed and there was a 10- to 15-minute blackout. I found myself in the street. The first thing I remember is being grabbed by a police officer and not knowing why. They had me by my T-shirt and I wriggled free; I managed to escape and was running around without a T-shirt on. The ambulance arrived and my heart rate was over 240bpm." He was taken to hospital and kept under observation for two days. He survived, but was badly shaken.

25I is far from the worst of these new drugs, however: in summer 2012, a drug called 5-IT – legal in most European countries and supposedly resembling MDMA – came on the market. Within just a few months of its appearance, Swedish health authorities had banned it, recording its presence in 14 autopsies. It is unclear whether the users knew what they were taking, or whether the drug was mislabelled and they overdosed. What is indisputable is that Sweden, with some of the toughest drug laws in Europe, has a disproportionately high death rate from legal drugs, which users buy online. There is no equivalent data available on the UK death rate, but here, too, the legal highs market appears to be thriving.

In a small room in Tooting, south London, John Ramsey looks after the biggest and most varied cache of drugs in the UK. A studious man in his 60s, Ramsey has spent decades collecting more than 27,000 samples of narcotics, which he has meticulously catalogued, labelled and hidden away in huge sliding drawers.

"There's about 400 quid's worth here," Ramsey says, pointing to some small butterfly-stamped tablets he picked up at a UK music festival. "I do wonder why they threw them away."

Toxicologist John Ramsey has spent decades collecting more than 27,000 samples of narcotics. Photograph: Daniel Stier for the Guardian

Ramsey is a toxicologist and drug scientist at St George's medical school. He buys all manner of legal highs from websites and collects them and other illegal drugs from amnesty bins outside clubs and festivals. He even analyses the urine collected in specially installed toilets in consenting nightclubs' car parks. His archives document the UK's ever-changing relationship with psychoactive substances over the past three decades. His organisation, TicTac, produces a database that is used by law enforcement and health professionals to identify mystery pills and powders. Like any other drug market, it's a growth industry.

Ramsey's samples from 2008 onwards show an initially baffling evolutionary leap, with dozens more species suddenly appearing. That was the year that mephedrone first went on sale in the UK and the EU. The drug was initially sold online under false pretences, as "plant food", to dodge food and medicine laws. It had no horticultural use, of course. It was a cathinone: a drug in the amphetamine family that occupied a sweet spot between the bonhomie of ecstasy and the brittle buzz of cocaine.

Most of all, it was legal. In recession-hit Britain in 2009, when cocaine purity had plummeted and ecstasy had virtually disappeared following a clampdown in Cambodia (where a key ingredient required for its manufacture was at that time sourced), users embraced mephedrone. The drug's legality – or, rather, its convenience and functionality – attracted hundreds of thousands of users in a matter of months. It was the first viral narcotic.

"Mephedrone was the perfect drug, wasn't it?" Ramsey says. "Water-soluble, not that toxic, and a very effective stimulant. Enormously enjoyable, users say, and very profitable for the dealers. People absolutely loved it. Well, they still do, actually – Britain is awash with the stuff."

Ramsey was among the first scientists to discover the chemical formula of mephedrone and is as conflicted as any rational observer over drug prohibition. "You can't just have shops and websites selling [legal highs] to kids. But it is the anti-drugs legislation, in many ways, that has prompted this innovation."

The first death attributed to mephedrone in the UK was that of Gabrielle Price, a 14-year-old from Worthing, West Sussex, who became ill at a house party where she had taken the drug together with ketamine. It was widely reported that she had died as a result. However, a pathologist's report showed the cause of death was broncho-pneumonia following a streptococcal A infection, and that the drugs had played no part.

There followed scenes that could have been lifted from Brass Eye: newspapers and police reported that mephedrone made one user tear off his own scrotum (untrue – this was a joke made on a vendor's site, mentioned in a Durham police report and then disseminated by a news agency). In March 2010, two young men from Winteringham and Scunthorpe, 18-year-old Louis Wainwright and 19-year-old Nicholas Smith, were found dead at their homes. Once again, the new killer drug was blamed, but toxicology reports found that the pair had actually taken methadone, the potent heroin substitute that can slow breathing dramatically in users with no tolerance to the drug, leading to death.

Though newspapers reported dozens of deaths due to mephedrone, in 2010 there were just six instances where the drug was mentioned on death certificates, and it is by no means certain that the drug killed even those users. What is known is that mephedrone has a number of unpleasant side-effects – users can become anxious and paranoid, and bingeing is common – and that it has given rise to an ever-growing market for online legal highs.

After mephedrone was banned, the dealers who had got rich quick cast around for new legal drugs that might capture the nation's imagination – and money. By 2010, the underground online drug culture had gone mainstream. None of the subsequent concoctions has gained the popularity of mephedrone, but the change it effected – of people looking online for legal drugs – is now permanent. Its significance is still playing out.

"The internet parachuted these new drugs into user groups, and that meant there was no way for people accurately to discuss correct and safe use," says Dr Adam Winstock, who runs the Global Drug Survey. Meaning they often took too much, too quickly. Winstock also runs drugsmeter.com, helping users compare their drug usage with others'. In November and December 2012, of the 7,360 people who responded online, one in eight of those surveyed had taken legal highs. Of those, 53% sourced them online, while 43% bought them in shops. More than one respondent in five had bought drugs of any kind online, and the first time they had done so was in 2011. "This is not a phenomenon that is going away," Winstock says.

John Ramsey and I are navigating the warren of St George's medical school. He is escorting me to his colleagues' laboratories, where they are about to feed animal tissue with legal drugs Ramsey bought online, and from that extrapolate what these novel compounds actually do to humans.

I'm expecting stainless steel and porcelain; instead, it looks like a 1980s hackers' den. The flickering monitors are decades old; clamps, vices and microscopes lie ramshackle on the worktops. There's a huge tank of CO 2 and a recipe pasted to the wall detailing how to make cerebro-spinal fluid. Slices of rat brain sit in a plastic sieve balanced in a lunchbox filled with the fluid.

Some of the drugs paraphernalia that John Ramsey has recovered from amnesty bins. Photograph: Daniel Stier for the Guardian

A tangle of tubing floods the brain with fluid and under a microscope we examine its dopamine and pleasure centre, before adding a drug to the mix – camfetamine, a legal stimulant sold on dozens of sites. After 20 minutes, a spike on the graph on the monitor shows that the drug has caused a release of dopamine, as cocaine does, though at a level not yet determined. Next door, the same drug is added to smooth stomach tissue, which contains serotonin receptors. The drug hits; the sliver of stomach muscle contracts, showing that the drug could cause narrowing of the arteries and possible heart problems.

This work yields valuable data that could help emergency wards treating those suffering the effects of the drugs – or produce health information campaigns to dissuade users from risky experimentation. "But how can we gather the data when there are so many new drugs?" Ramsey asks. "There simply aren't the resources to risk-assess everything, and I don't know if there's even the appetite to do it.

"Of the 73 new drugs in 2012, more than 50 were cannabinoid receptor agonists," Ramsey adds. "They come from such a wide range of chemical families, it's impossible pre-emptively to ban them all. We find them, test them and the government drafts laws guessing at all the possible generic variations that can be made. Then the manufacturers just change the formula again."

On 26 February this year, a raft of these cannabis-resembling compounds were banned, and within days there was a new range of products available containing different compounds. But the problem extends far beyond marijuana substitutes: 6-APB, known online as Benzo Fury, is an ecstasy alternative; camfetamine, methiopropamine and ethylphenidate are stimulants similar to amphetamines; 5-MeO-DALT and DALT are tryptamines with hallucinogenic effects. All are legal.

"Really, if you'd said even 10 years ago that you'd be able to buy tryptamines on the high street, who'd have believed you?" Ramsey asks wearily.

In comparison with regular drugs, there is hardly any data on the harm these new drugs do. That doesn't stop many unregulated manufacturers in the UK, China and eastern Europe taking any of these chemicals or dozens more, blending them with inert substances into uncontrolled, unstated doses, and selling them online. "The UK Border Agency has got great hangars full of little packets of white powder," Baroness Molly Meacher of the Parliamentary Drug Policy Group said recently. "They just simply haven't got the technology, they haven't got the money, they haven't got the resources. They don't know what's in all those packages."

Chris Raby, a masters student working with Ramsey, shows me a densely typed A4 page listing dozens of branded legal highs he's been testing, bought from one Essex headshop – the kind of establishment that sells novelty cannabis pipes and glow-in-the-dark Rizla cigarette papers. These products, with names such as Barry White and Dutchy, are the most concerning: customers are very often young people, some of whom find it hard to buy drugs anywhere else, or prefer to stay on the right side of the law. Manufacturers do not list their contents, or give any dosage instructions, since to do so would render them liable for prosecution.

"People never ask why I do them," one young user tells me. "They think it's risky, but some of these new drugs are pretty good – and I don't have to bother with some dodgy dealer."

For some, hedonism is not the aim. One user, a 33-year-old software engineer who suffers from occasional depression, says he self-medicated his way out of his illness using drugs that at the time were legal. "I discovered that regular, small… doses of methoxetamine [a ketamine derivative banned in 2012 after four deaths in a month] alleviated my lifelong depression and made me functional and productive again. I was able to live a normal life for a year until the government banned [it] in another reactionary response to media scaremongering." He fears, though, "for younger, more naive people who are exposed to these drugs without knowing how they really work – kids who are just looking for a good time".

The quickest way to ban new drugs in the UK is to place them under a temporary class drug order, where their import and sale are banned by law, but their possession is not. The Advisory Council on the Misuse of Drugs, a panel of chemists and medics that makes policy recommendations to government, then has 12 months to analyse the published literature for the drugs and decide whether to ban them. The system works in the sense that it takes drugs off the market – the first use of the new law in March 2012 saw off methoxetamine almost entirely. But it does nothing to prevent new drugs emerging.

Some experts believe a longer-term answer could be to give people controlled, licensed, taxed and regulated access to relatively safer compounds that have been studied for decades. David E Nichols, emeritus professor in pharmacology at Purdue University in Indiana, US, who invented the NBOMe-series of drugs as part of legitimate research into antidepressants, suggests that the government "legalise the safe ones. Mushrooms, mescaline, peyote: all have been used for thousands of years and have been shown to be safe." James Moffatt, a senior lecturer in physiology at St George's, agrees: "LSD is relatively far safer than any of these new compounds, and we have decades of data on it."

For Adam Winstock, the current situation comes down to a shortage of quality drugs on the market: a theory supported by the results of the Global Drug Survey 2013, which found that 14% of respondents had taken what it called "mystery white powders" in the past 12 months. Winstock adds: "And nearly 80% of them say they were already off their head when they did. There is a market for these drugs when other drugs aren't very good. If there were good-quality coke, weed and pills, I don't know how much of a look-in these drugs would get."

• Some names have been changed.

Drugs 2.0: The Web Revolution That's Changing How The World Gets High, by Mike Power, is published next week by Portobello Books at £14.99.