It's possible, but pay attention to nutritional balance.
It is possible for hamsters to only eat hamster food, but the prerequisite is that the nutritional components of the hamster food are comprehensive and balanced enough. Here is a specific analysis:

1. The Feasibility of Hamster Food as the Main Diet
If the selected hamster food is of qualified quality, with rich ingredients and a balanced nutrition profile, hamsters can take hamster food as their main diet without the need to supplement other foods additionally.
Hamster food usually contains grains, seeds, etc., which can provide the energy and crude fiber that hamsters need and meet their basic nutritional requirements.
2. Nutritional Supplements in Special Situations
Mother Hamsters during Lactation and Baby Hamsters: Hamsters in these stages need additional nutritional supplements, such as goat milk powder, cooked egg whites, etc. Relying solely on hamster food may not be able to meet their needs.
Special Health Conditions: If hamsters have problems such as constipation or diarrhea, they can be appropriately supplemented with sugar-free yogurt or fresh vegetables and fruits to regulate their intestinal function.
3. The Benefits of a Diverse Diet
Although hamster food can serve as the main diet, appropriately adding foods such as vegetables, fruits, and meats can further supplement vitamins, proteins, and trace elements, which is conducive to the healthy growth of hamsters.
For example, fresh vegetables (such as carrots, cucumbers) and fruits (such as apples, strawberries) can provide vitamins, while mealworms, cooked chicken, etc. can supplement proteins.
4. Precautions
Avoid Excessive Snacks: Although snacks (such as dried small fish, molar sticks) can be fed occasionally, excessive consumption will cause hamsters to be picky eaters and affect their nutrient intake.
Avoid Foods with High Water Content: Fruits with excessive water content, such as watermelons, may cause diarrhea in hamsters and should be avoided as much as possible.
Choose High-quality Hamster Food: Inferior hamster food may contain too many snack ingredients and lack sufficient nutrition. Long-term consumption will affect the health of hamsters.
Conclusion
It is possible for hamsters to only eat hamster food, but it is necessary to ensure that the hamster food is nutritionally comprehensive and appropriately supplement other foods in special situations. For the health of hamsters, it is recommended to occasionally add vegetables, fruits, and protein-rich foods on the basis of hamster food to maintain a balanced nutrition.