Historically, mystery fans generally consider the first two sleuths in modern detective fiction to be Edgar Allan Poe's C. Auguste Dupin in the 1840s and Sir Arthur Conan Doyle's Sherlock Holmes in the 1880s. However, during the 40 years in between, at least one author was also writing mystery fiction: Westholme Publishing has unearthed the never-reprinted 1864 collection Leaves from the Note-Book of a New York Detective: The Private Record of J.B., by author John Babbington Williams.
"Twenty years before Sherlock Holmes, a fictional New York private investigator was being celebrated for his ability to solve crimes based on observation and deductive reasoning -- the principles that would later become Holmes' hallmark. Originally published in 1864 and never before reprinted, "Leaves from the Note-Book of a New York Detective" features 29 cases from the first American detective hero to appear in fiction, James Brampton."
Check out Sarah Weinman's review, Dark Passages: Early American Detective Fiction.