The core levels and valence bands of Y, YH2.1, and YH3 have been studied using X-ray photoemission spectroscopy. For YH2.1 and YH3, hydrogen-induced states appear at binding energies of about 6 eV. YH2.1 shows emission at the Fermi level and the core-level spectra show highly asymmetric lineshape with shoulders at the high-binding-energy side of the main peaks. For YH3, emission at the Fermi level is weak and the core-levels are nearly symmetric, consistent with a semiconductor or a semimetal. The main peaks of the core levels shift to higher binding energies from Y to YH2.1 to YH3. Taking into account different core-hole screening mechanisms in these materials, however, a charge transfer from Y to H is evident in YH2, but no clear further Y to H charge transfer is seen in going from YH2 to YH3. Importance of the Y 5sp-H 1s bond is suggested from the valence-band spectra.