1. Write exhaustive automatic tests against the API you are responsible for.
2. Don't write tests for anything else.
If you are responsible for implementing a server/service, the API is the protocol for the server/service. If you are responsible for implementing a module/library, the API is the public interface to your module/library.
The tests are basically a specification for how any implementation of the API needs to behave. So you can give the tests to another developer, who has never seen your implementation, and they should be able to re-implement everything based on your tests.
3. Make sure your API test suite runs fast, runs locally and is easy to use. Effort put into the test suite and tooling pays dividends for a long time.
2. Don't write tests for anything else.
If you are responsible for implementing a server/service, the API is the protocol for the server/service. If you are responsible for implementing a module/library, the API is the public interface to your module/library.
The tests are basically a specification for how any implementation of the API needs to behave. So you can give the tests to another developer, who has never seen your implementation, and they should be able to re-implement everything based on your tests.