He was born at Keir, Dumfriesshire, and first worked as a stone mason's apprentice. His father was a neighbour of Robert Burns at Ellisland, and Allan with his brother James visited James Hogg, the "Ettrick shepherd", who became a friend to both. Cunningham contributed some songs to Roche's Literary Recreations in 1807, and in 1809 he collected old ballads for Robert Hartley Cromek's Remains of Nithsdale and Galloway Song; he sent in, however, poems of his own, which the editor inserted, even though he may have suspected their real authorship.
In 1810 Cunningham went to London, where he worked as a journalist till 1814, when he became clerk of the works in the studio of the sculptor, Francis Chantrey, a post he kept until Chantrey's death in 1841. Cunningham meanwhile continued to write. His prose is often spoiled by its misplaced and too ambitious rhetoric; his verse also is ornate, and both are full of mannerisms, Some of his songs, however, hold a high place among British lyrics. "A Wet Sheet and a Flowing Sea" is one of the best British sea-songs, although written by a landsman; and many other of Cunningham's songs became popular.
He was married to Jean Walker, who had been servant in a house where he lived, and they had five sons and one daughter.