Library – (1) A collection of programs (subprograms) or data files. Most modern operating systems (OS) have libraries. (2) A set of ready-made software routines (functions). The routines are linked (put) into the program when it is compiled.  There are proprietary or specialized libraries and the opposite which are open standard libraries.

An API is a computerized system or program library that provides support (and thus fulfills) service requests that other computer programs make of it.