At the moment, the easiest way is to use the MPRester interface in pymatgen. You should find that most structures now have magmom site properties attached with the site-projected magnetic moments.
We’re working on making this information easier to obtain via the API and also on the website, and also making sure that all structures have this information (currently, only a subset have site-projected magnetic moments attached).
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:
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.)