Algae obtain energy through photosynthesis, using sunlight to convert carbon dioxide and water into glucose and oxygen.