The National Center for Biotechnology Information (NCBI) provides many useful products, including PubMed, PubMed Central, PubChem, Gene, and Genome. In addition to the web interfaces to these products, NCBI also provides an API allowing programmatic access to the underlying databases and search technology.
The NCBI provides a single starting page for API documentation and examples at https://www.ncbi.nlm.nih.gov/home/develop/api/
Most NCBI databases, including PubMed, are hosted on the Entrez platform. All Entrez databases use the same API interfaces, referred to as the Entrez Programming Utilities, or E-utilities. A typical workflow would be to issue an ESearch call to get a list of unique identifiers, and then use the EFetch API to get full records.
NCBI also provides Entrez Direct (EDirect), a set of command line tools for the Entrez API on UNIX or UNIX-like operating environments.
NCBI provides a video overview of the Entrez E-utilities at https://www.youtube.com/watch?v=BCG-M5k-gvE