An API ("application programming interface") is essentially a structured and pre-defined set of programmatic functions and operations that can be used to access data and use procedures in a particular context. Many companies and organizations with large and complex software and data environments will use APIs internally to enable employees to access and use data efficiently. In many cases, APIs are strictly for internal use only and people outside the company or organization have no ability to use the API for any purpose.
However, some companies provide access to their API to external users. Sometimes API access is free (e.g. Reddit), sometimes it costs money. Additionally, some companies offer a free version of their API with limited functionality as well as a paid version of their API will more robust functionality (e.g. Twitter's "Standard API" vs "Premium API"). Some APIs are relatively "easy" to use in a technical sense, while others are much more challenging.
In brief, if you have a choice between using an API vs. web scraping in order to interact with a website and collect data, ALWAYS START WITH THE API!!! There are two key reasons for this: