At the most superficial level, before you see user interfaces and programs, an operating system is all API. Computer source code is the blueprint of a computer program. That is not an analogy. Computer source code is an actual, tangible blueprint. Computer source code is not a program, it is the blueprint for a program. The blueprint describes what a program is supposed to do when it actually runs and what the program will take in as data and give out as data. Each part of the blueprint has names. The blueprint is the full design of the program with the names of the parts within the blueprint. The organization of names forms a pattern, a unique fingerprint for the program. That unique fingerprint is the API.
An operating system is simply a much larger program that runs other programs and does so according to a blueprint. Smaller programs fit into the blueprint. Apple’s blueprint matches up with the blueprint of their hardware and so their overall design is better. Windows has a more dynamic blueprint that is design to adapt to many hardware designs and so their blueprint can be messy sometimes when put in practice.
Linux/BSD has a general blueprint that is like Apple’s but adaptable to hardware like Windows. Linux/BSD are best because their blueprint represents a design trade-off that fuses the worlds of academia, science, engineering, and practical utility as a collaborative design.