APIs work by defining a set of rules for how software components should interact. These rules are typically documented in an API documentation that specifies the endpoints, methods, and data formats that can be used. When a request is made to an API, it processes the request and returns the appropriate response, often in the form of JSON or XML data.