The story centres on a witty, sly, illiterate and lazy protagonist, Wei Xiaobao, who was born to a prostitute from a brothel in Yangzhou in the early Qing dynasty. The teenage scamp makes his way from Yangzhou to the capital, Beijing, through a series of adventures. In Beijing, he is kidnapped and taken to the imperial palace, where he impersonates a eunuch. While in the palace, Wei Xiaobao bumbles his way into a fateful encounter with the young Kangxi Emperor, the ruler of the Qing Empire, and develops an unlikely friendship with him.