Nanotechnology continues to develop novel materials and devices that can potentially improve our daily life. Atomic force microscopy (AFM) has proven to be one of the most powerful characterization tools at the nanoscale. Variants of atomic force microscopy can be used to measure electronic properties of nanostructures with single electron resolution. Scanning tunneling spectroscopy (STS) provides information about localized density of states using tunneling current measurements. In this work we describe a spectroscopic technique that can be implemented using the AFM. A major advantage of this technique, electrostatic force spectroscopy, is that it can be applied on partially insulating samples where tunneling currents are infinitesimally small. Using a conductive AFM tip both as a bias gate and an electrometer, charging events of localized surface states can be measured with better than single electronic charge sensitivity. Due to the long-range electrostatic interaction, charging events can be observed even when they occur few nanometers below the surface, allowing mapping of local electronic structure in three dimensions and also as a function of energy.