Based on the Green's-function formalism, we present an approach to the linear and nonlinear optical properties of semiconductors and their heterostructures. Starting from the Bethe-Salpeter equation ͓as provided in Schmitt-Rink, Ell, and Haug, Phys. Rev. B 33, 1183 ͑1986͔͒, we obtain closed-form expressions for the interband density of states in the presence of a carrier plasma of arbitrary density and in quasiequilibrium. Focusing on two-dimensional heterostructures, we discuss both the exciton resonances and the exciton ionization continuum. Our approach brings out, in a most natural way, phenomena whose description was previously known phenomenologically or numerically.