For the most part, there was no institution of slavery in China comparable to European (Roman or Slavic) or Arabic slavery. There was not a great need for agricultural slaves as taxes were extracted in the form of crops until the Tang Dynasty era and military slaves, such as the Ottoman janissaries, were not needed by most dynastic rulers who had a sizable population to conscript from.
There are some important exceptions though.
The Mongol military often used captives from one town as human shields to attack a following town and also used imprisoned Chinese siege engineers to create their own siege equipment. This could be construed as slavery, or at the least, a forced march with forced labor as they slowly moved from northern China to the south over a span of about fifty years.
The Qin Dynasty used forced labor for the construction of the Great Wall and the Terracotta Army memorial for Qin Shi Huang in which tens of thousands died. Another short-lived dynasty, the Sui, also utilized forced labor to construct the Grand Canal which linked Beijing to China's two rivers (and its grain supply) where tens of thousands of peasant laborers also died.
Military conquest, especially by the Tang, Song, and the Qing, saw a rise in captive slaves either from battle or conquest of lands. In all of these cases, a program of slow abolition took place usually over decades to phase out the institution. Whether or not this was for moral reasons, fear of a slave rebellion, a desire for tax revenue, or something else, is left to your judgement.
The abolition of slavery was decreed by several dynasties starting with the Han which suggests some form of slavery existed, even if it was unofficial, which required repeated royal attention. The emperor's ability to enforce abolition was also limited by attention and distance, so slavery was likely common along Silk Road trading posts and coastal ports as traders dealt with cultures where slavery was more accepted.
Eunuchs could be considered slaves as they were considered to be the "property" of the Emperor. While some did join willingly for the comfort and duties, many eunuchs were captured and forcibly castrated to serve as "unfettered" servants, harem guards, and messengers.
I've also avoided talking about the station of peasants themselves, as some have argued that feudalism itself was a form of slavery. Chinese peasants were definitely separated from the nobility but depending on the dynasty, there was room for upward mobility be it through trade, learning to read and write, learning a trade, owning land, marriage links to a family, joining the military, joining a religious movement, and of course, good old-fashioned armed rebellion. The peasants were given at least ceremonial respect in Confucianism and were not seen as the opposite of nobility, but as the "children" of the Emperor. In reality, they could often suffer at the hands of the nobility or landowners.
"slavery" as a trade practice existed in China during and before the Zhou dynasty.
However, Qin dynasty largely abolished the practice of slave trade and private ownership of slaves.
What some have characterized as "slaves" in China after Qin, is what was called "official slaves", which are technically not slaves as we would understand, but most comparable to convicts and prisoners of war.
That is, "official slaves" in China were prisoners who were captives of the Emperor's court. No other people were allowed to own "official slaves", and no trade of "official slaves" was allowed.
Some "official slaves" were subject to terms of services. After they served a number of years, they could be set free. Others were lifers, but they could earn their freedom by exceptional services.
The other comments have a lot of very good specific information on what slavery in China was like. I would like to contribute, though, a theoretical distinction that is necessary before a meaningful comparison between Chinese slavery and, say, European slavery can be had.
There is a distinction between "slave societies," where slavery is a primary, or THE primary mode of economic production and "slave using societies," where slaves may have a place in society but are not key to the economic success of that state.
Rome, Sparta, and the American South typify the first category. Arab slavery (using slaves for sex or military service), some (but not all) forms of indigenous African slavery (Malinke, for instance) and the limited use of slaves in China are examples of the second category.
Many characteristics of "slavery" as it is commonly thought of by modern people are more descriptive of the "slave societies" with which we are usually more familiar. It is important to remember, though, that many of these characteristics are not present in the institutions we label "slavery" in societies outside the familiar context. (For instance, I was surprised that a concept of ownership is not a key part of all the institutions we would label as "slavery." See Slavery and Social Death by Orlando Patterson.)
For a relatively short primer that explains this theoretical distinction better than I am able, have a look at this section by historian Martin A. Klein..