Unfortunately, the key links in the popular answers for this question are all currently broken. It is still true, as David H answered, that the Common Core of Data is the official source, but the links to data.gov are broken.
Now, the only relevant thing on data.gov is the page about the School & District Navigator which links to an interactive map that doesn't itself offer data.
However, the Department of Education has a simple interactive tool which helps get access to specific CCD files, "fiscal" or "non-fiscal", at the state, district, or school level.
Along the way, I also found public schools as GIS data from the DHS Homeland Infrastructure Foundation-Level Data (HIFLD) website.
The Department of Education also created a polished "Developer Hub" referencing supported and legacy APIs, but the dates on blog posts for that are all at least 3 years old right now, so it's hard to know what's actively supported -- and in any case, none of the APIs are for K-12 schools.