We present a way of measuring with high precision the anharmonicity of a quantum oscillator coupled to an optical field via radiation pressure. Our protocol uses a sequence of pulsed interactions to perform a loop in the phase space of the mechanical oscillator, which is prepared in a thermal state. We show how the optical field acquires a phase depending on the anharmonicity. Remarkably, one only needs small initial cooling of the mechanical motion to probe even small anharmonicities. Finally, by applying tools from quantum estimation theory, we calculate the ultimate bound on the estimation precision posed by quantum mechanics and compare it with the precision obtainable with feasible measurements such as homodyne and heterodyne detection on the cavity field. In particular we demonstrate that homodyne detection is nearly optimal in the limit of a large number of photons of the field and we discuss the estimation precision of small anharmonicities in terms of its signal-to-noise ratio.