Economic theory rarely provides a parametric specification for a model, but it often provides shape restrictions. We consider nonparametric estimation of the heterogeneous demand for gasoline in the U.S. subject to the Slutsky inequality restriction of consumer choice theory. We derive conditions under which the demand function can be estimated consistently by nonparametric quantile regression subject to the Slutsky restriction. The estimated function reveals systematic variation in price responsiveness across the income distribution. A new method for estimating quantile instrumental variables models is also developed to allow for the endogeneity of prices. In our application, shape-constrained quantile IV estimates show similar patterns of demand as shape-constrained estimates under exogeneity. The results illustrate the improvements in the finite-sample performance of a nonparametric estimator that can be achieved by imposing shape restrictions based on economic theory.