Quite often this is the kind of question which every developer comes across at least once in their development lifetime where they end up confusing the terms API, Library, Frameworks and SDK and googling such a basic question. Well if you have got this doubt too then kudos! you have actually started thinking like a developer.
I would like to explain these terms with a basic “Car” analogy. That worked for me.
Lets start from outside-in approach-
The car as it is when we buy is a complete package of engine and its parts (which are accessible and inaccessible). We’ll just run around these things and try to correlate the terms which we’re looking for.
Car when it is out for sale it is a complete kit of all the parts and it is “ready-for-action”. Think of it as SDK- it is a kit which has everything you need and can use ( few not allowed to use as well). SDK has a bunch of different software components assembled into a package, such that they’re “ready-for-action” right out of the box. It often includes multiple libraries and can but may not necessarily include plugins, API documentation, even an IDE itself. (Ex: JAVA SDK, iOS development kit)
On the other hand if you dug deep you will come across engine- Engine on the whole again has different other small engines meant for a specific purposes. The same way the engine in the broader sense is much like a framework. It is also a library (or a collection of libraries that work together) and provides a specific coding structure & pattern. (Ex: Spring Framework, Hibernate Framework)
The other small engines in a one large engine i.e, framework can be viewed as libraries. A library has a set of methods/functions that are created by developers themselves and you don’t have to do anything with them but just use them with interfaces as and when required. (Ex: wheels)
At last the interfaces like the buttons in the car through which you can access part of the engine i.e, library is the API. As the name Application Program Interface, it is the part the library which is accessed by users/developers.
I hope this analogy worked for you guys. Comment below to add up on this topic or if it was helpful.