The role of a species in its ecosystem, which includes the way that the species interacts with the abiotic and biotic factors of the environment.