How it works
An API is a contract: send a request in this shape and you get a response in that shape. On the web it usually means an HTTP API, where an app calls URLs (endpoints) such as /orders/42 and receives JSON. The provider documents what each endpoint does and issues keys or tokens, so it knows who is calling and can limit or bill them.
The term is broader than the web. Browsers offer APIs to JavaScript (the DOM, fetch, geolocation), operating systems offer them to apps, and libraries offer functions. Web APIs come in several styles: REST (resources and HTTP verbs), GraphQL (one endpoint where the client picks the fields), gRPC (fast binary calls between services) and webhooks, where the provider calls you when something happens.
Related terms
More in How the web works
Requests and responses