How to get magnetic moment of each atom using the Materials Project API?

No problem. Unfortunately, mp-2662 specifically is a structure that does not have this information yet, but to take another MnP example that does have this information:

from pymatgen import MPRester

mpr = MPRester(YOUR_API_KEY_HERE)
structure = mpr.get_structure_by_material_id('mp-999516')
print(structure)
magmoms = structure.site_properties['magmom']
print(magmoms)

This will output:

Full Formula (Mn2 P2)
Reduced Formula: MnP
abc   :   3.339203   3.339494   5.369199
angles:  90.000000  90.000000 119.997123
Sites (4)
  #  SP           a        b     c    magmom
---  ----  --------  -------  ----  --------
  0  Mn    0         0        0.5      1.981
  1  Mn    0         0        0        1.982
  2  P     0.333305  0.66661  0.25    -0.082
  3  P     0.666695  0.33339  0.75    -0.082
[1.981, 1.982, -0.082, -0.082]

(In general, it is the older materials on the Materials Project that do not yet have site-projected magnetic moments. All newer materials should have them.)