In most cases API comes last, after the data and UI. This is just the state of things unless you intentionally building an api service from scratch.
Data stays forever and in many times serves more than one application, UI changes all the time and might connect to more than one data source.
API is the decoupling between those two and in most cases dictated by both, not the other way round.