Move spaces API into its own package

[#73928640]