Your favorite library may have "API Documentation" such documents whose functions are available, how you call them, which arguments are required and lot more as per your requirements. However, these days, when someone is referring to an API they are most likely referring to an HTTP API, which is a way of sharing application data over the internet.
The biggest example is Twitter has an API Application Programming Interface that allows you to request tweets in a format that makes it so easy to import into your own application. This is so true power that of HTTP APIs is being able to mash up data from multiple applications into your own application and to even create an application which enhances the experience of using someone else's application.
The APIs you create: Act as a front door for the applications to access your back end systems as well. Application programming interface allows you to use many features like analytics, monetization, authentication, throttling, quota and rate limit, and many other features of API Gateway. API is a gateway which provides the facility to expose your front doors and back end systems in many ways. Front doors and back ends can be even exposed by writing just your business logic in Java and uploading it in Gateway to expose as REST APIs.