The brief difference in layman's term is:
- If you are working on an interface or module that provides support to other modules by exposing the members of the stated dependency you should be using 'api'.
- If you are making an application or module that is going to implement or use the stated dependency internally, use 'implementation'.
- 'compile' worked same as 'api', however, if you are only implementing or using any library, 'implementation' will work better and save you resources.
read the answer by @aldok for a comprehensive example.