Conjure up the private detective. For those familiar with the novels of Dashiell Hammett and Raymond Chandler as well as the noir films of the 1940s and ’50s, this is easy magic. Tucked underneath a fedora, the archetypal P. I. chain-smokes cigarettes, goes nowhere without his trenchcoat, and prefers to walk the dark streets as a lonely man—described frequently as a sort of knight errant. His goals are easy: truth, justice, and a shot of whiskey. Sure, plenty of girls ("dames" in trade vernacular) come along, but they never stay. The American P. I. is just the Western cowboy in the big city, and we all know that cowboys are better off riding alone.

Given the private eye's place in American mythology, it's hard to believe that the whole thing is an invention. That's John Walton's assertion in this deconstruction of the private detective myth. Rather than dashing outsiders with strict moral codes, Walton shows that America's private eyes were mostly "men, all white, in their 30s and 40s, mostly married, often with children." A large majority had prior law enforcement experience, with some even being veterans or other experienced hands in the rougher socially acceptable trades. In Walton's words, private eye operatives in America were "from the righteous working class."

This did not stop the anti-P. I. crowd from calling them disreputable. After all, small-time and big-time private companies made money breaking up strikes and hiring out criminals for replacement labor. The Legendary Detective cites innumerable investigations that proved many detective agencies were given to less-than-legal practices during the labor wars that plagued America before and after World War I.

Walton's research takes these findings one step further. He argues that labor espionage—everything from anti-union agitation to company-versus-company spying—was the real meat and potatoes of the trade until the 1930s wave of federal reforms forever altered industrial relations. Investigating crimes and apprehending criminals were far down on the private detective's to-do list. Private eyes never slept because, in Walton's rendering, they were up to no good.

Readers might have reason to suspect the author's bias and motivations here, yet it would be unwise to discard The Legendary Detective as mere agitprop. Walton shows that private detectives of yesteryear were capable of ugly tactics, from political subterfuge to warrantless surveillance on citizens. And although they occasionally produced operatives like Frank Geyer, the Pinkerton man who helped capture a serial killer named H. H. Holmes, or Charles Siringo, the cowboy-cum-lawman who ended his life as a reformer speaking out against P. I. excesses, the Pinkertons, the Burns detective agency, and other independent enterprises mostly produced hard-bitten workers who provided dubious services to corporations that wanted to get organized labor out of their hair.

How this reality became romanticized fiction is another matter. In order to break away from the genteel fantasies of Arthur Conan Doyle and Agatha Christie, American pulp magazine writers of the midcentury sought to appeal to working and middle-class male readers by hammering out tough-talking crime stories about equally tough-talking private detectives. The first to do this was Carroll John Daly, who created Race Williams, a private eye who consciously walked the middle path between cop and criminal. Daly was followed by Dashiell Hammett, a former Pinkerton operative.

Yet as much as these stories merely represented working for a payday, Walton sees them as products of an intentional synthesis. Digesting the complex American world of the early 20th century, hardboiled writers created a private detective figure who was "an amalgam [of] the criminal associate, labor spy, strikebreaker, leg breaker, jury tamperer, frame-up artist, braggart, entrepreneur, advocate, and reformer." The American private investigator of fiction is still two-faced, with conflicting instincts that oscillate between lightness and darkness. But that's how it usually is with creatures tasked with doing society's dirty work.

Benjamin Welton is a writer in Boston.