The way in which energy is transferred and used within an ecosystem, from primary producers to higher-level consumers.