In all of my development I create an API as the backend for my apps. My frontend code then uses the responses provided in the way needed for that specific frontend. This means that the API needs to be very clearly defined to make development on the frontends (web, ios, android, etc..) quick and easy. Input parameters, return values, possible endpoints… everything needs to be documented somehow.
Quitte recently Swagger became the new standard in API documentation when it was merged with the OpenAPI specification. What else can be a better than the OpenAPI specification to document your API? I think nothing. Want to know how to use it? Read the Swagger/OpenAPI spec docs.