An earthworm is a tube-shaped, segmented worm, that is commonly found living in soil.
They enjoy feeding on live and dead organic matter.
An earthworm’s digestive system runs through the length of its body and it conducts respiration through its skin.
It has a double transport system composed of coelomic fluid that moves within the fluid-filled coelom and a simple, closed blood circulatory system.
Earthworms are far less abundant in disturbed environments and are typically active only if water is present. (source)
So can hamsters eat earthworms?
Unfortunately they cant as they may be carrying parasites that could harm a hamster.